From 27b995ad1a3e5e6d27608169f9790d329134b2f5 Mon Sep 17 00:00:00 2001 From: Crypto Chassis Date: Tue, 12 Sep 2023 12:01:26 -0700 Subject: [PATCH 1/3] fix: no correlation Id returned by event notifying orderbook subscription with Gate.io --- .../cross_exchange_arbitrage/CMakeLists.txt | 4 +- .../src/custom_service_class/CMakeLists.txt | 4 +- .../src/enable_library_logging/CMakeLists.txt | 4 +- .../CMakeLists.txt | 4 +- .../CMakeLists.txt | 4 +- .../CMakeLists.txt | 4 +- .../CMakeLists.txt | 4 +- .../generic_private_request/CMakeLists.txt | 4 +- .../src/generic_public_request/CMakeLists.txt | 4 +- .../CMakeLists.txt | 4 +- .../CMakeLists.txt | 4 +- .../market_data_simple_request/CMakeLists.txt | 4 +- .../CMakeLists.txt | 3 -- example/src/market_making/CMakeLists.txt | 4 +- .../CMakeLists.txt | 4 +- example/src/utility_set_timer/CMakeLists.txt | 4 +- .../service/ccapi_market_data_service.h | 6 +-- .../ccapi_market_data_service_binance_base.h | 12 ++--- .../service/ccapi_market_data_service_bybit.h | 12 ++--- ...pi_market_data_service_bybit_derivatives.h | 12 ++--- .../ccapi_market_data_service_gateio_base.h | 52 +++++++++---------- .../ccapi_market_data_service_kucoin_base.h | 12 ++--- .../service/ccapi_market_data_service_mexc.h | 12 ++--- .../ccapi_market_data_service_whitebit.h | 17 +++--- include/ccapi_cpp/service/ccapi_service.h | 1 + 25 files changed, 82 insertions(+), 117 deletions(-) diff --git a/example/src/cross_exchange_arbitrage/CMakeLists.txt b/example/src/cross_exchange_arbitrage/CMakeLists.txt index 56b09ab3..f8ba84f0 100644 --- a/example/src/cross_exchange_arbitrage/CMakeLists.txt +++ b/example/src/cross_exchange_arbitrage/CMakeLists.txt @@ -5,6 +5,4 @@ add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_GEMINI) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/custom_service_class/CMakeLists.txt b/example/src/custom_service_class/CMakeLists.txt index ebad22c1..70dc5334 100644 --- a/example/src/custom_service_class/CMakeLists.txt +++ b/example/src/custom_service_class/CMakeLists.txt @@ -4,6 +4,4 @@ add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_compile_definitions(CCAPI_EXPOSE_INTERNAL) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/enable_library_logging/CMakeLists.txt b/example/src/enable_library_logging/CMakeLists.txt index c961b050..37118d3c 100644 --- a/example/src/enable_library_logging/CMakeLists.txt +++ b/example/src/enable_library_logging/CMakeLists.txt @@ -4,6 +4,4 @@ add_compile_definitions(CCAPI_ENABLE_LOG_TRACE) add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/execution_management_advanced_request/CMakeLists.txt b/example/src/execution_management_advanced_request/CMakeLists.txt index d280b7a6..bb424906 100644 --- a/example/src/execution_management_advanced_request/CMakeLists.txt +++ b/example/src/execution_management_advanced_request/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE_US) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/execution_management_advanced_subscription/CMakeLists.txt b/example/src/execution_management_advanced_subscription/CMakeLists.txt index 8990b70d..8dde0f47 100644 --- a/example/src/execution_management_advanced_subscription/CMakeLists.txt +++ b/example/src/execution_management_advanced_subscription/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_OKX) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/execution_management_simple_request/CMakeLists.txt b/example/src/execution_management_simple_request/CMakeLists.txt index 5d42dfc8..121d8718 100644 --- a/example/src/execution_management_simple_request/CMakeLists.txt +++ b/example/src/execution_management_simple_request/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/execution_management_simple_subscription/CMakeLists.txt b/example/src/execution_management_simple_subscription/CMakeLists.txt index 265e39db..a96a16db 100644 --- a/example/src/execution_management_simple_subscription/CMakeLists.txt +++ b/example/src/execution_management_simple_subscription/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/generic_private_request/CMakeLists.txt b/example/src/generic_private_request/CMakeLists.txt index 25b04951..61a65caf 100644 --- a/example/src/generic_private_request/CMakeLists.txt +++ b/example/src/generic_private_request/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/generic_public_request/CMakeLists.txt b/example/src/generic_public_request/CMakeLists.txt index ad451493..decc6985 100644 --- a/example/src/generic_public_request/CMakeLists.txt +++ b/example/src/generic_public_request/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/market_data_advanced_request/CMakeLists.txt b/example/src/market_data_advanced_request/CMakeLists.txt index f7e6eae2..1da1bddd 100644 --- a/example/src/market_data_advanced_request/CMakeLists.txt +++ b/example/src/market_data_advanced_request/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/market_data_advanced_subscription/CMakeLists.txt b/example/src/market_data_advanced_subscription/CMakeLists.txt index 86e3f374..9558cda9 100644 --- a/example/src/market_data_advanced_subscription/CMakeLists.txt +++ b/example/src/market_data_advanced_subscription/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/market_data_simple_request/CMakeLists.txt b/example/src/market_data_simple_request/CMakeLists.txt index 73e828d4..c94a4f92 100644 --- a/example/src/market_data_simple_request/CMakeLists.txt +++ b/example/src/market_data_simple_request/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/market_data_simple_subscription/CMakeLists.txt b/example/src/market_data_simple_subscription/CMakeLists.txt index bcb8c4b9..7cbc8f2b 100644 --- a/example/src/market_data_simple_subscription/CMakeLists.txt +++ b/example/src/market_data_simple_subscription/CMakeLists.txt @@ -3,6 +3,3 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() diff --git a/example/src/market_making/CMakeLists.txt b/example/src/market_making/CMakeLists.txt index ccbb123a..b980a48f 100644 --- a/example/src/market_making/CMakeLists.txt +++ b/example/src/market_making/CMakeLists.txt @@ -4,6 +4,4 @@ add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/override_exchange_url_at_runtime/CMakeLists.txt b/example/src/override_exchange_url_at_runtime/CMakeLists.txt index af67429a..68cfc8d1 100644 --- a/example/src/override_exchange_url_at_runtime/CMakeLists.txt +++ b/example/src/override_exchange_url_at_runtime/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_OKX) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/example/src/utility_set_timer/CMakeLists.txt b/example/src/utility_set_timer/CMakeLists.txt index dd047376..0073d3ec 100644 --- a/example/src/utility_set_timer/CMakeLists.txt +++ b/example/src/utility_set_timer/CMakeLists.txt @@ -3,6 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_executable(${NAME} main.cpp) -if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP) - add_dependencies(${NAME} boost rapidjson) -endif() +add_dependencies(${NAME} boost rapidjson) diff --git a/include/ccapi_cpp/service/ccapi_market_data_service.h b/include/ccapi_cpp/service/ccapi_market_data_service.h index ac71d1a7..fdbc54d5 100644 --- a/include/ccapi_cpp/service/ccapi_market_data_service.h +++ b/include/ccapi_cpp/service/ccapi_market_data_service.h @@ -390,7 +390,7 @@ class MarketDataService : public Service { void onClose(wspp::connection_hdl hdl) override { CCAPI_LOGGER_FUNCTION_ENTER; WsConnection& wsConnection = this->getWsConnectionFromConnectionPtr(this->serviceContextPtr->tlsClientPtr->get_con_from_hdl(hdl)); - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.erase(wsConnection.id); + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.erase(wsConnection.id); this->exchangeJsonPayloadIdByConnectionIdMap.erase(wsConnection.id); this->instrumentGroupByWsConnectionIdMap.erase(wsConnection.id); this->correlationIdByConnectionIdMap.erase(wsConnection.id); @@ -650,7 +650,7 @@ class MarketDataService : public Service { virtual void onClose(std::shared_ptr wsConnectionPtr, ErrorCode ec) override { CCAPI_LOGGER_FUNCTION_ENTER; WsConnection& wsConnection = *wsConnectionPtr; - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.erase(wsConnection.id); + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.erase(wsConnection.id); this->exchangeJsonPayloadIdByConnectionIdMap.erase(wsConnection.id); this->instrumentGroupByWsConnectionIdMap.erase(wsConnection.id); this->correlationIdByConnectionIdMap.erase(wsConnection.id); @@ -1787,7 +1787,7 @@ class MarketDataService : public Service { std::string getInstrumentTarget; std::string getInstrumentsTarget; std::map exchangeJsonPayloadIdByConnectionIdMap; - std::map>> exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap; + std::map>> exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap; // only needed for generic public subscription std::map correlationIdByConnectionIdMap; std::map>> diff --git a/include/ccapi_cpp/service/ccapi_market_data_service_binance_base.h b/include/ccapi_cpp/service/ccapi_market_data_service_binance_base.h index fd979cfe..ba9585b3 100644 --- a/include/ccapi_cpp/service/ccapi_market_data_service_binance_base.h +++ b/include/ccapi_cpp/service/ccapi_market_data_service_binance_base.h @@ -94,7 +94,7 @@ class MarketDataServiceBinanceBase : public MarketDataService { } document.AddMember("params", params, allocator); document.AddMember("id", rj::Value(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).Move(), allocator); - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = exchangeSubscriptionIdList; this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; rj::StringBuffer stringBuffer; @@ -127,11 +127,11 @@ class MarketDataServiceBinanceBase : public MarketDataService { std::vector correlationIdList; if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.find(wsConnection.id) != this->correlationIdListByConnectionIdChannelIdSymbolIdMap.end()) { int id = std::stoi(document["id"].GetString()); - if (this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.find(wsConnection.id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.end() && - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).find(id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).end()) { - for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).at(id)) { + if (this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.find(wsConnection.id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.end() && + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).find(id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).end()) { + for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).at(id)) { std::string channelId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_CHANNEL_ID]; std::string symbolId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_SYMBOL_ID]; if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).find(channelId) != diff --git a/include/ccapi_cpp/service/ccapi_market_data_service_bybit.h b/include/ccapi_cpp/service/ccapi_market_data_service_bybit.h index af978064..2ea449f5 100644 --- a/include/ccapi_cpp/service/ccapi_market_data_service_bybit.h +++ b/include/ccapi_cpp/service/ccapi_market_data_service_bybit.h @@ -72,7 +72,7 @@ class MarketDataServiceBybit : public MarketDataServiceBybitBase { } document.AddMember("args", args, allocator); document.AddMember("req_id", rj::Value(std::to_string(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).c_str(), allocator).Move(), allocator); - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = exchangeSubscriptionIdList; this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; rj::StringBuffer stringBuffer; @@ -109,11 +109,11 @@ class MarketDataServiceBybit : public MarketDataServiceBybitBase { if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.find(wsConnection.id) != this->correlationIdListByConnectionIdChannelIdSymbolIdMap.end()) { int id = std::stoi(document["req_id"].GetString()); - if (this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.find(wsConnection.id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.end() && - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).find(id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).end()) { - for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).at(id)) { + if (this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.find(wsConnection.id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.end() && + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).find(id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).end()) { + for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).at(id)) { std::string channelId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_CHANNEL_ID]; std::string symbolId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_SYMBOL_ID]; if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).find(channelId) != diff --git a/include/ccapi_cpp/service/ccapi_market_data_service_bybit_derivatives.h b/include/ccapi_cpp/service/ccapi_market_data_service_bybit_derivatives.h index 77d433a6..b3b9f9a6 100644 --- a/include/ccapi_cpp/service/ccapi_market_data_service_bybit_derivatives.h +++ b/include/ccapi_cpp/service/ccapi_market_data_service_bybit_derivatives.h @@ -100,7 +100,7 @@ class MarketDataServiceBybitDerivatives : public MarketDataServiceBybitBase { } document.AddMember("args", args, allocator); document.AddMember("req_id", rj::Value(std::to_string(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).c_str(), allocator).Move(), allocator); - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = exchangeSubscriptionIdList; this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; rj::StringBuffer stringBuffer; @@ -137,11 +137,11 @@ class MarketDataServiceBybitDerivatives : public MarketDataServiceBybitBase { if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.find(wsConnection.id) != this->correlationIdListByConnectionIdChannelIdSymbolIdMap.end()) { int id = std::stoi(document["req_id"].GetString()); - if (this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.find(wsConnection.id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.end() && - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).find(id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).end()) { - for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).at(id)) { + if (this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.find(wsConnection.id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.end() && + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).find(id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).end()) { + for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).at(id)) { std::string channelId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_CHANNEL_ID]; std::string symbolId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_SYMBOL_ID]; if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).find(channelId) != diff --git a/include/ccapi_cpp/service/ccapi_market_data_service_gateio_base.h b/include/ccapi_cpp/service/ccapi_market_data_service_gateio_base.h index f31fad03..00484f87 100644 --- a/include/ccapi_cpp/service/ccapi_market_data_service_gateio_base.h +++ b/include/ccapi_cpp/service/ccapi_market_data_service_gateio_base.h @@ -83,13 +83,12 @@ class MarketDataServiceGateioBase : public MarketDataService { exchangeSubscriptionIdList.push_back(exchangeSubscriptionId); } document.AddMember("payload", payload, allocator); - if (!this->isDerivatives) { - document.AddMember("id", rj::Value(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).Move(), allocator); - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] - [this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = - exchangeSubscriptionIdList; - this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; - } + // if (!this->isDerivatives) { + document.AddMember("id", rj::Value(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).Move(), allocator); + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = + exchangeSubscriptionIdList; + this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; + // } rj::StringBuffer stringBuffer; rj::Writer writer(stringBuffer); document.Accept(writer); @@ -121,15 +120,15 @@ class MarketDataServiceGateioBase : public MarketDataService { std::string exchangeSubscriptionId = std::string(this->websocketChannelOrderBook) + "|" + symbolId; this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_CHANNEL_ID] = channelId; this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_SYMBOL_ID] = symbolId; - if (!this->isDerivatives) { - std::vector exchangeSubscriptionIdList; - exchangeSubscriptionIdList.push_back(exchangeSubscriptionId); - document.AddMember("id", rj::Value(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).Move(), allocator); - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] - [this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = - exchangeSubscriptionIdList; - this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; - } + // if (!this->isDerivatives) { + std::vector exchangeSubscriptionIdList; + exchangeSubscriptionIdList.push_back(exchangeSubscriptionId); + document.AddMember("id", rj::Value(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).Move(), allocator); + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id] + [this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = + exchangeSubscriptionIdList; + this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; + // } rj::StringBuffer stringBuffer; rj::Writer writer(stringBuffer); document.Accept(writer); @@ -165,20 +164,19 @@ class MarketDataServiceGateioBase : public MarketDataService { if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.find(wsConnection.id) != this->correlationIdListByConnectionIdChannelIdSymbolIdMap.end()) { int id = std::stoi(document["id"].GetString()); - if (this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.find(wsConnection.id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.end() && - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).find(id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).end()) { - for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).at(id)) { + if (this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.find(wsConnection.id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.end() && + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).find(id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).end()) { + for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).at(id)) { auto splitted = UtilString::split(exchangeSubscriptionId, '|'); std::string channelId = splitted.at(0); std::string symbolId = splitted.at(1); - if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).find(channelId) != - this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).end()) { - if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).at(channelId).find(symbolId) != - this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).at(channelId).end()) { - std::vector correlationIdList_2 = - this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).at(channelId).at(symbolId); + const auto& it = this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).lower_bound(channelId); + if (it != this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).end()) { + const std::string& k = it->first; + if (k.compare(0, channelId.size(), channelId) == 0) { + std::vector correlationIdList_2 = it->second.at(symbolId); correlationIdList.insert(correlationIdList.end(), correlationIdList_2.begin(), correlationIdList_2.end()); } } diff --git a/include/ccapi_cpp/service/ccapi_market_data_service_kucoin_base.h b/include/ccapi_cpp/service/ccapi_market_data_service_kucoin_base.h index 2c34e13d..4ce17a4e 100644 --- a/include/ccapi_cpp/service/ccapi_market_data_service_kucoin_base.h +++ b/include/ccapi_cpp/service/ccapi_market_data_service_kucoin_base.h @@ -176,7 +176,7 @@ class MarketDataServiceKucoinBase : public MarketDataService { for (const auto& symbol : symbolList) { exchangeSubscriptionIdList.push_back(topic + ":" + symbol); } - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = exchangeSubscriptionIdList; this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; document.AddMember("id", rj::Value(requestId.c_str(), allocator).Move(), allocator); @@ -400,11 +400,11 @@ class MarketDataServiceKucoinBase : public MarketDataService { if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.find(wsConnection.id) != this->correlationIdListByConnectionIdChannelIdSymbolIdMap.end()) { int id = std::stoi(document["id"].GetString()); - if (this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.find(wsConnection.id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.end() && - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).find(id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).end()) { - auto exchangeSubscriptionIdList = this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).at(id); + if (this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.find(wsConnection.id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.end() && + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).find(id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).end()) { + auto exchangeSubscriptionIdList = this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).at(id); for (const auto& exchangeSubscriptionId : exchangeSubscriptionIdList) { auto splitted = UtilString::split(exchangeSubscriptionId, ":"); auto channelId = splitted.at(0); diff --git a/include/ccapi_cpp/service/ccapi_market_data_service_mexc.h b/include/ccapi_cpp/service/ccapi_market_data_service_mexc.h index 5cebfd21..952339f5 100644 --- a/include/ccapi_cpp/service/ccapi_market_data_service_mexc.h +++ b/include/ccapi_cpp/service/ccapi_market_data_service_mexc.h @@ -71,7 +71,7 @@ class MarketDataServiceMexc : public MarketDataService { } document.AddMember("params", params, allocator); document.AddMember("id", rj::Value(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).Move(), allocator); - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = exchangeSubscriptionIdList; this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; rj::StringBuffer stringBuffer; @@ -126,11 +126,11 @@ class MarketDataServiceMexc : public MarketDataService { std::string msg = document["msg"].GetString(); if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.find(wsConnection.id) != this->correlationIdListByConnectionIdChannelIdSymbolIdMap.end()) { int id = std::stoi(document["id"].GetString()); - if (this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.find(wsConnection.id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.end() && - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).find(id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).end()) { - for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).at(id)) { + if (this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.find(wsConnection.id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.end() && + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).find(id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).end()) { + for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).at(id)) { std::string channelId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_CHANNEL_ID]; std::string symbolId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_SYMBOL_ID]; if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).find(channelId) != diff --git a/include/ccapi_cpp/service/ccapi_market_data_service_whitebit.h b/include/ccapi_cpp/service/ccapi_market_data_service_whitebit.h index 52cd9196..52e336a5 100644 --- a/include/ccapi_cpp/service/ccapi_market_data_service_whitebit.h +++ b/include/ccapi_cpp/service/ccapi_market_data_service_whitebit.h @@ -91,8 +91,8 @@ class MarketDataServiceWhitebit : public MarketDataService { sendStringList.push_back(sendString); this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_CHANNEL_ID] = channelId; this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_SYMBOL_ID] = symbolId; - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] - [this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = { + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id] + [this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = { exchangeSubscriptionId}; this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; } @@ -118,8 +118,7 @@ class MarketDataServiceWhitebit : public MarketDataService { document.Accept(writer); std::string sendString = stringBuffer.GetString(); sendStringList.push_back(sendString); - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] - [this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] = exchangeSubscriptionIdList; this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1; } @@ -216,11 +215,11 @@ class MarketDataServiceWhitebit : public MarketDataService { std::vector correlationIdList; if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.find(wsConnection.id) != this->correlationIdListByConnectionIdChannelIdSymbolIdMap.end()) { - if (this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.find(wsConnection.id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.end() && - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).find(id) != - this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).end()) { - for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).at(id)) { + if (this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.find(wsConnection.id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.end() && + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).find(id) != + this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).end()) { + for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).at(id)) { std::string channelId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_CHANNEL_ID]; std::string symbolId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_SYMBOL_ID]; diff --git a/include/ccapi_cpp/service/ccapi_service.h b/include/ccapi_cpp/service/ccapi_service.h index 8f52a82e..a44cd1ac 100644 --- a/include/ccapi_cpp/service/ccapi_service.h +++ b/include/ccapi_cpp/service/ccapi_service.h @@ -1392,6 +1392,7 @@ class Service : public std::enable_shared_from_this { memcpy(writeMessageBuffer.data() + n, data, dataSize); writeMessageBufferBoundary.push_back(dataSize); n += dataSize; + CCAPI_LOGGER_TRACE("connectionId = " + connectionId); CCAPI_LOGGER_DEBUG("about to send " + std::string(data, dataSize)); CCAPI_LOGGER_TRACE("writeMessageBufferWrittenLength = " + toString(writeMessageBufferWrittenLength)); if (writeMessageBufferWrittenLength == 0) { From 44168be59c96ceeaa1a56d2d523a05e4e15b33e7 Mon Sep 17 00:00:00 2001 From: Crypto Chassis Date: Tue, 12 Sep 2023 12:05:25 -0700 Subject: [PATCH 2/3] ci: fix build error --- example/src/market_data_simple_subscription/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/example/src/market_data_simple_subscription/CMakeLists.txt b/example/src/market_data_simple_subscription/CMakeLists.txt index 7cbc8f2b..1305df16 100644 --- a/example/src/market_data_simple_subscription/CMakeLists.txt +++ b/example/src/market_data_simple_subscription/CMakeLists.txt @@ -3,3 +3,4 @@ project(${NAME}) add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE) add_executable(${NAME} main.cpp) +add_dependencies(${NAME} boost rapidjson) From 99673148c9ac3139af6e0d49c3b7217712fc3335 Mon Sep 17 00:00:00 2001 From: Crypto Chassis Date: Tue, 12 Sep 2023 13:46:40 -0700 Subject: [PATCH 3/3] ci: fix build error --- .github/workflows/test.yml | 114 ++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8a240fd8..0f2c8e7d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -164,7 +164,7 @@ jobs: COMMAND npm install -g node-gyp ) - - name: Configure + - name: Configure 1 shell: cmake -P {0} run: | set(ENV{CC} ${{ matrix.config.cc }}) @@ -207,7 +207,7 @@ jobs: execute_process( COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake -DBUILD_TEST_BUILD=ON - -DBUILD_TEST_UNIT=ON + -DBUILD_TEST_UNIT=OFF -S test -B test/build -D CMAKE_BUILD_TYPE=$ENV{CMAKE_BUILD_TYPE} @@ -291,7 +291,7 @@ jobs: message(FATAL_ERROR "Bad exit status") endif() - - name: Build + - name: Build 1 shell: cmake -P {0} run: | set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") @@ -380,6 +380,114 @@ jobs: message(FATAL_ERROR "Bad exit status") endif() + execute_process( + COMMAND rm -rf test/build + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + + # execute_process(COMMAND ccache -s) + + - name: Configure 2 + shell: cmake -P {0} + run: | + set(ENV{CC} ${{ matrix.config.cc }}) + set(ENV{CXX} ${{ matrix.config.cxx }}) + if ("${{ runner.os }}" STREQUAL "macOS") + set(ENV{OPENSSL_ROOT_DIR} "/usr/local/Cellar/openssl") + elseif ("${{ runner.os }}" STREQUAL "Windows") + set(ENV{OPENSSL_ROOT_DIR} "C:/vcpkg/installed/x64-windows-static") + # set(ENV{CMAKE_TOOLCHAIN_FILE} "C:/vcpkg/scripts/buildsystems/vcpkg.cmake") + endif() + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + execute_process( + COMMAND "${{ matrix.config.environment_script }}" && set + OUTPUT_FILE environment_script_output.txt + ) + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + + set(path_separator ":") + if ("${{ runner.os }}" STREQUAL "Windows") + set(path_separator ";") + endif() + set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") + + if ("$ENV{GITHUB_EVENT_NAME}" STREQUAL "push") + set(ENV{CMAKE_BUILD_TYPE} "Release") + set(ENV{DOTNET_BUILD_CONFIGURATION} "Release") + set(ENV{NODE_GYP_BUILD_MODE} "release") + else() + set(ENV{CMAKE_BUILD_TYPE} "Debug") + set(ENV{DOTNET_BUILD_CONFIGURATION} "Debug") + set(ENV{NODE_GYP_BUILD_MODE} "debug") + endif() + + execute_process( + COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake + -DBUILD_TEST_BUILD=OFF + -DBUILD_TEST_UNIT=ON + -S test + -B test/build + -D CMAKE_BUILD_TYPE=$ENV{CMAKE_BUILD_TYPE} + -G Ninja + -D CMAKE_MAKE_PROGRAM=ninja + # -D CMAKE_C_COMPILER_LAUNCHER=ccache + # -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + + - name: Build 2 + shell: cmake -P {0} + run: | + set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") + + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + + set(path_separator ":") + if ("${{ runner.os }}" STREQUAL "Windows") + set(path_separator ";") + endif() + set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") + + # file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}" ccache_basedir) + # set(ENV{CCACHE_BASEDIR} "${ccache_basedir}") + # set(ENV{CCACHE_DIR} "${ccache_basedir}/.ccache") + # set(ENV{CCACHE_COMPRESS} "true") + # set(ENV{CCACHE_COMPRESSLEVEL} "6") + # set(ENV{CCACHE_MAXSIZE} "400M") + # if ("${{ matrix.config.cxx }}" STREQUAL "cl") + # set(ENV{CCACHE_MAXSIZE} "600M") + # endif() + # + # execute_process(COMMAND ccache -p) + # execute_process(COMMAND ccache -z) + + execute_process( + COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake --build test/build -j 2 + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + # execute_process(COMMAND ccache -s) - name: Test