Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove static modelName #113

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 86 additions & 41 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,28 @@ jobs:
fetch-depth: 5
- name: Nightly default
run: rustup default nightly
- name: Prepare vcpkg
if: runner.os != 'Windows'
uses: friendlyanon/setup-vcpkg@v1
with: { committish: 51b14cd4e1230dd51c11ffeff6f7d53c61cc5297 }
- uses: actions/cache@v2
id: cache
with:
path: |
/home/runner/.hunter
/Users/runner/.hunter/
/home/runner/vcpkg
/Users/runner/vcpkg/
ccache
key: hunter-clang-v3-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
deps/
c:/vcpkg
!c:/vcpkg/.git
!c:/vcpkg/buildtrees
!c:/vcpkg/packages
!c:/vcpkg/downloads
key: vcpkg-clang-v3-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
restore-keys: |
hunter-clang-v3-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
hunter-clang-v3-notest-${{ runner.temp }}-${{ github.base_ref }}-
hunter-clang-v3-notest-${{ runner.temp }}-
vcpkg-clang-v3-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
vcpkg-clang-v3-notest-${{ runner.temp }}-${{ github.base_ref }}-
vcpkg-clang-v3-notest-${{ runner.temp }}-
- name: install macOS dependencies
if: runner.os == 'macOS'
run: brew install ccache
Expand All @@ -48,10 +58,10 @@ jobs:
run: sudo apt install -y git curl openssl build-essential clang cmake ccache
- name: configure
if: runner.os == 'macOS'
run: export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) && CC=/usr/bin/clang CXX=/usr/bin/clang++ mkdir build && cd build && cmake ../ -DTESTS=ON
run: export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) && CC=/usr/bin/clang CXX=/usr/bin/clang++ mkdir build && cd build && cmake ../ -DTESTS=ON -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
- name: configure
if: runner.os == 'Linux'
run: CC=/usr/bin/clang CXX=/usr/bin/clang++ mkdir build && cd build && cmake ../
run: CC=/usr/bin/clang CXX=/usr/bin/clang++ mkdir build && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake ../
- name: compile
run: cd build && make -j2
# - name: run test
Expand All @@ -66,15 +76,28 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: Prepare vcpkg
if: runner.os != 'Windows'
uses: friendlyanon/setup-vcpkg@v1
with: { committish: 51b14cd4e1230dd51c11ffeff6f7d53c61cc5297 }
- uses: actions/cache@v2
id: cache
with:
path: /home/runner/.hunter
key: hunter-gcc-v2-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
path: |
/home/runner/vcpkg
/Users/runner/vcpkg/
ccache
deps/
c:/vcpkg
!c:/vcpkg/.git
!c:/vcpkg/buildtrees
!c:/vcpkg/packages
!c:/vcpkg/downloads
key: vcpkg-gcc-v2-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
restore-keys: |
hunter-gcc-v2-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
hunter-gcc-v2-notest-${{ runner.temp }}-${{ github.base_ref }}-
hunter-gcc-v2-notest-${{ runner.temp }}-
vcpkg-gcc-v2-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
vcpkg-gcc-v2-notest-${{ runner.temp }}-${{ github.base_ref }}-
vcpkg-gcc-v2-notest-${{ runner.temp }}-
- uses: actions/cache@v2
id: ccache
with:
Expand All @@ -87,7 +110,7 @@ jobs:
- name: install Ubuntu dependencies
run: sudo apt install -y git curl openssl build-essential cmake ccache
- name: configure
run: mkdir -p build && cd build && cmake ../
run: mkdir -p build && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake ../
- name: compile
run: cd build && make -j4
# - name: run test
Expand All @@ -98,45 +121,67 @@ jobs:
container:
image: docker.io/centos:7
volumes:
- /github/home/.hunter:/github/home/.hunter
- /github/home/vcpkg:/github/home/vcpkg
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: install rust language
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-06-17
override: true
- uses: actions/cache@v2
id: cache
with:
path: |
/home/runner/.hunter
/github/home/.hunter
/home/runner/.hunter/_Base/Download/
/github/home/.hunter/_Base/Download/
deps/src
ccache
key: hunter-centos-v2-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
restore-keys: |
hunter-centos-v2-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
hunter-centos-v2-notest-${{ runner.temp }}-${{ github.base_ref }}-
hunter-centos-v2-notest-${{ runner.temp }}-
- name: install CentOS dependencies
- name: pre-push
run: |
# Sigh.
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/mirrorlist.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
# Avoid https://github.com/actions/checkout/issues/1590
curl -L -o bcos-boostssl.tar.gz https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz
tar xvf bcos-boostssl.tar.gz
cd bcos-boostssl-${GITHUB_SHA}
yum install -y -q epel-release centos-release-scl flex bison patch glibc-static glibc-devel libzstd-devel
yum install -y -q devtoolset-11 llvm-toolset-7.0 rh-perl530-perl cmake3 zlib-devel ccache python-devel python3-devel python3-pip automake openssl
yum reinstall -y -q https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
yum install -y -q git

- name: configure
run: |
source /opt/rh/devtoolset-7/enable
mkdir -p build && cd build
cmake3 ../ -DHUNTER_STATUS_DEBUG=ON
cmake3 ../
- name: compile
run: |
source /opt/rh/devtoolset-7/enable
mkdir -p build && cd build
make -j4

build_with_windows:
name: build_with_windows
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2019]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 5
- uses: actions/cache@v2
id: cache
with:
path: |
/home/runner/vcpkg
/github/home/vcpkg
/Users/runner/vcpkg
/home/runner/vcpkg/_Base/Download/
/github/home/vcpkg/_Base/Download/
/Users/runner/vcpkg/_Base/Download/
C:/vcpkg/
C:/vcpkg/_Base/Download/
ccache
key: vcpkg-msvc-v3-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
restore-keys: |
vcpkg-msvc-v3-notest-${{ runner.temp }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
vcpkg-msvc-v3-notest-${{ runner.temp }}-${{ github.base_ref }}-
vcpkg-msvc-v3-notest-${{ runner.temp }}-
- name: Add MSbuild to PATH
uses: microsoft/[email protected]
- name: configure
if: runner.os == 'Windows'
run: mkdir -p build && cd build && cmake -G "Visual Studio 16 2019" -A x64 -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake ../
- name: compile
run:
cd build && MSBuild /version && MSBuild bcos-boostssl.sln /p:Configuration=Release /p:Platform=x64
2 changes: 1 addition & 1 deletion bcos-boostssl/context/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


#define CONTEXT_LOG(LEVEL) BCOS_LOG(LEVEL) << LOG_BADGE(m_moduleName) << "[BOOSTSSL][CTX]"
#define NODEINFO_LOG(LEVEL) BCOS_LOG(LEVEL) << LOG_BADGE(m_moduleName) << "[BOOSTSSL][NODEINFO]"
#define NODEINFO_LOG(LEVEL) BCOS_LOG(LEVEL) << "[BOOSTSSL][NODEINFO]"

namespace bcos
{ // namespace bcos
Expand Down
5 changes: 0 additions & 5 deletions bcos-boostssl/context/NodeInfoTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ namespace boostssl
{
namespace context
{
static std::string m_moduleName = "DEFAULT";

class NodeInfoTools
{
public:
Expand All @@ -42,9 +40,6 @@ class NodeInfoTools

static std::function<bool(bool, boost::asio::ssl::verify_context&)> newVerifyCallback(
std::shared_ptr<std::string> nodeIDOut);

static std::string moduleName() { return m_moduleName; }
static void setModuleName(std::string _moduleName) { m_moduleName = _moduleName; }
};

} // namespace context
Expand Down
5 changes: 2 additions & 3 deletions bcos-boostssl/websocket/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <boost/beast/websocket.hpp>

#define BOOST_SSL_LOG(LEVEL) BCOS_LOG(LEVEL) << "[BOOSTSSL]"
#define WEBSOCKET_TOOL(LEVEL) BCOS_LOG(LEVEL) << LOG_BADGE(m_moduleName) << "[WS][TOOL]"
#define WEBSOCKET_TOOL(LEVEL) BCOS_LOG(LEVEL) << "[WS][TOOL]"
#define WEBSOCKET_CONNECTOR(LEVEL) BCOS_LOG(LEVEL) << LOG_BADGE(m_moduleName) << "[WS][CONNECTOR]"
#define WEBSOCKET_VERSION(LEVEL) BCOS_LOG(LEVEL) << LOG_BADGE(m_moduleName) << "[WS][VERSION]"
#define WEBSOCKET_SESSION(LEVEL) BCOS_LOG(LEVEL) << LOG_BADGE(m_moduleName) << "[WS][SESSION]"
Expand All @@ -36,8 +36,7 @@
#define WEBSOCKET_STREAM(LEVEL) BCOS_LOG(LEVEL) << LOG_BADGE(m_moduleName) << "[WS][STREAM]"
#define WEBSOCKET_SSL_STREAM(LEVEL) \
BCOS_LOG(LEVEL) << LOG_BADGE(m_moduleName) << "[WS][SSL][STREAM]"
#define WEBSOCKET_INITIALIZER(LEVEL) \
BCOS_LOG(LEVEL) << LOG_BADGE(m_moduleName) << "[WS][INITIALIZER]"
#define WEBSOCKET_INITIALIZER(LEVEL) BCOS_LOG(LEVEL) << "[WS][INITIALIZER]"

namespace bcos
{
Expand Down
22 changes: 12 additions & 10 deletions bcos-boostssl/websocket/WsInitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ using namespace bcos::boostssl::http;
void WsInitializer::initWsService(WsService::Ptr _wsService)
{
std::shared_ptr<WsConfig> _config = m_config;
std::string m_moduleName = _config->moduleName();
auto messageFactory = m_messageFactory;
if (!messageFactory)
{
Expand Down Expand Up @@ -76,9 +75,7 @@ void WsInitializer::initWsService(WsService::Ptr _wsService)
auto threadPool = std::make_shared<ThreadPool>("t_ws_pool", threadPoolSize);

// init module_name for log
WsTools::setModuleName(m_moduleName);
NodeInfoTools::setModuleName(m_moduleName);
connector->setModuleName(m_moduleName);
connector->setModuleName(_config->moduleName());

std::shared_ptr<boost::asio::ssl::context> srvCtx = nullptr;
std::shared_ptr<boost::asio::ssl::context> clientCtx = nullptr;
Expand All @@ -87,8 +84,8 @@ void WsInitializer::initWsService(WsService::Ptr _wsService)
auto contextBuilder = std::make_shared<ContextBuilder>();

// init module_name for log
contextBuilder->setModuleName(m_moduleName);
_config->contextConfig()->setModuleName(m_moduleName);
contextBuilder->setModuleName(_config->moduleName());
_config->contextConfig()->setModuleName(_config->moduleName());

srvCtx = contextBuilder->buildSslContext(true, *_config->contextConfig());
clientCtx = contextBuilder->buildSslContext(false, *_config->contextConfig());
Expand All @@ -97,7 +94,8 @@ void WsInitializer::initWsService(WsService::Ptr _wsService)
if (_config->asServer())
{
WEBSOCKET_INITIALIZER(INFO)
<< LOG_BADGE("initWsService") << LOG_DESC("start websocket service as server");
<< LOG_BADGE("initWsService") << LOG_DESC("start websocket service as server")
<< LOG_KV("module", _config->moduleName());

if (!WsTools::validIP(_config->listenIP()))
{
Expand All @@ -114,7 +112,7 @@ void WsInitializer::initWsService(WsService::Ptr _wsService)

auto httpServerFactory = std::make_shared<HttpServerFactory>();
auto httpServer = httpServerFactory->buildHttpServer(_config->listenIP(),
_config->listenPort(), ioServicePool->getIOService(), srvCtx, m_moduleName);
_config->listenPort(), ioServicePool->getIOService(), srvCtx, _config->moduleName());
httpServer->setIOServicePool(ioServicePool);
httpServer->setDisableSsl(_config->disableSsl());
httpServer->setThreadPool(threadPool);
Expand All @@ -139,6 +137,7 @@ void WsInitializer::initWsService(WsService::Ptr _wsService)
auto connectPeers = _config->connectPeers();
WEBSOCKET_INITIALIZER(INFO)
<< LOG_BADGE("initWsService") << LOG_DESC("start websocket service as client")
<< LOG_KV("module", _config->moduleName())
<< LOG_KV("connected endpoints size", connectPeers ? connectPeers->size() : 0);

if (connectPeers)
Expand All @@ -164,6 +163,7 @@ void WsInitializer::initWsService(WsService::Ptr _wsService)

WEBSOCKET_INITIALIZER(INFO)
<< LOG_BADGE("initWsService") << LOG_DESC("domain name has been set")
<< LOG_KV("module", _config->moduleName())
<< LOG_KV("host", peer.address());
}

Expand All @@ -181,7 +181,8 @@ void WsInitializer::initWsService(WsService::Ptr _wsService)
else
{
WEBSOCKET_INITIALIZER(WARNING)
<< LOG_BADGE("initWsService") << LOG_DESC("there has no connected server config");
<< LOG_BADGE("initWsService") << LOG_DESC("there has no connected server config")
<< LOG_KV("module", _config->moduleName());
}
}

Expand All @@ -196,7 +197,8 @@ void WsInitializer::initWsService(WsService::Ptr _wsService)

WEBSOCKET_INITIALIZER(INFO)
<< LOG_BADGE("initWsService") << LOG_DESC("initializer for websocket service")
<< LOG_KV("listenIP", _config->listenIP()) << LOG_KV("listenPort", _config->listenPort())
<< LOG_KV("module", _config->moduleName()) << LOG_KV("listenIP", _config->listenIP())
<< LOG_KV("listenPort", _config->listenPort())
<< LOG_KV("disableSsl", _config->disableSsl()) << LOG_KV("server", _config->asServer())
<< LOG_KV("client", _config->asClient())
<< LOG_KV("threadPoolSize", _config->threadPoolSize())
Expand Down
4 changes: 0 additions & 4 deletions bcos-boostssl/websocket/WsTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ namespace boostssl
{
namespace ws
{
static std::string m_moduleName = "DEFAULT";
class WsTools
{
public:
Expand All @@ -54,9 +53,6 @@ class WsTools
static bool stringToEndPoint(const std::string& peer, NodeIPEndpoint& _endpoint);

static void close(boost::asio::ip::tcp::socket& skt);

static std::string moduleName() { return m_moduleName; }
static void setModuleName(std::string _moduleName) { m_moduleName = _moduleName; }
};
} // namespace ws
} // namespace boostssl
Expand Down
8 changes: 8 additions & 0 deletions cmake/CompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
add_compile_definitions(NOMINMAX)
add_compile_options(-bigobj)
# MSVC only support static build
set(CMAKE_CXX_FLAGS_DEBUG "/MTd /DEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /Os")
set(CMAKE_CXX_FLAGS_RELEASE "/MT")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /DEBUG")
link_libraries(ws2_32 Crypt32 userenv)
else ()
message(WARNING "Your compiler is not tested, if you run into any issues, we'd welcome any patches.")
endif ()
Expand Down
4 changes: 2 additions & 2 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"kind": "git",
"repository": "https://github.com/FISCO-BCOS/registry",
"baseline": "944d6fd57320b9a8c76c5775456a37b152d2d217",
"baseline": "d1aa5ece461d69d102e6a98ab222f684454bdb71",
"packages": [
"tbb",
"boost-beast",
Expand All @@ -13,4 +13,4 @@
]
}
]
}
}
Loading