Skip to content

Commit e4e8e13

Browse files
committed
Refactoring build pipeline
1 parent 27f82f1 commit e4e8e13

7 files changed

Lines changed: 46 additions & 8 deletions

File tree

.github/workflows/build.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export PKG_CONFIG_PATH="$(brew --prefix libpq)/lib/pkgconfig:$PKG_CONFIG_PATH"
1717
export PostgreSQL_ROOT="$(brew --prefix libpq)"
1818

1919
# 1. Generate build files (Passing your CXX flags directly to CMake instead of configure)
20-
cmake .. -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release
20+
cmake .. \
21+
-DCMAKE_CXX_STANDARD=20 \
22+
-DCMAKE_BUILD_TYPE=Release \
23+
-DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path) \
24+
-DSKIP_BUILD_TEST=ON
2125

2226
# 2. Compile libpqxx
23-
make
27+
make -j$(sysctl -n hw.logicalcpu)

.github/workflows/sonarcloud.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ jobs:
3535

3636
# Step 4: Build project external libraries
3737
- name: Build C++ Libraries
38-
run: bash ./.github/workflows/build.sh
38+
run: bash ./scripts/build_dep.sh
39+
# run: bash ./.github/workflows/build.sh
3940

4041
# Step 5: Configure Xcode version
4142
- name: Select Xcode version
@@ -92,7 +93,7 @@ jobs:
9293
cmake --version
9394
- name: Build C++ Libraries
9495
run: >
95-
bash ./.github/workflows/build.sh
96+
sh ./scripts/build.sh
9697
- name: Install Python 3.12 for gcovr
9798
uses: actions/setup-python@v5
9899
with:

.vscode/c_cpp_properties.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Mac",
5+
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
6+
"includePath": [
7+
"${workspaceFolder}/external/libpqxx/include"
8+
]
9+
}
10+
],
11+
"version": 4
12+
}

scripts/build.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ fi
1212
# Step 2: Navigate to the build directory
1313
cd "$BUILD_DIR" || exit
1414

15-
# Step 3: Run CMake to configure the project
16-
cmake ..
15+
# Expose paths so CMake finds libpq
16+
export PATH="$(brew --prefix libpq)/bin:$PATH"
17+
export PKG_CONFIG_PATH="$(brew --prefix libpq)/lib/pkgconfig:$PKG_CONFIG_PATH"
18+
export PostgreSQL_ROOT="$(brew --prefix libpq)"
19+
20+
# 1. Generate build files (Passing your CXX flags directly to CMake instead of configure)
21+
cmake .. \
22+
-DCMAKE_CXX_STANDARD=20 \
23+
-DCMAKE_BUILD_TYPE=Release \
24+
-DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path) \
25+
-DSKIP_BUILD_TEST=ON
1726

1827
# Step 4: Compile the project
1928
cmake --build .

scripts/build_dep.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ cd ./external/libpqxx
33
mkdir -p build
44
cd ./build
55

6+
# Expose paths so CMake finds libpq
67
export PATH="$(brew --prefix libpq)/bin:$PATH"
78
export PKG_CONFIG_PATH="$(brew --prefix libpq)/lib/pkgconfig:$PKG_CONFIG_PATH"
89
export PostgreSQL_ROOT="$(brew --prefix libpq)"
910

10-
cmake .. -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release
11+
# 1. Generate build files (Passing your CXX flags directly to CMake instead of configure)
12+
cmake .. \
13+
-DCMAKE_CXX_STANDARD=20 \
14+
-DCMAKE_BUILD_TYPE=Release \
15+
-DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path) \
16+
-DSKIP_BUILD_TEST=ON
1117
make

source/databaseConnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ std::vector<PriceData> DatabaseConnection::streamQuery(const std::string& query)
5757
std::vector<PriceData> results(result.size());
5858

5959
for (std::size_t i = 0; i < result.size(); ++i) {
60-
const auto& row = result[i];
60+
const auto& row = result[static_cast<pqxx::result::size_type>(i)];
6161
double ask, bid;
6262
auto symbol = row[0].view();
6363
auto sv1 = row[1].view();

source/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,24 @@ using json = nlohmann::json;
3232
// argv[2] — Base64-encoded JSON strategy configuration
3333
int main(int argc, const char * argv[]) {
3434

35+
// Validate required command-line arguments before proceeding
3536
if (argc < 3) {
3637
std::cerr << "Usage: " << argv[0] << " <questdb-host> <base64-config>" << std::endl;
3738
return 1;
3839
}
40+
41+
// Connect to QuestDB on the default port (8812) using default credentials
3942
DatabaseConnection db(argv[1], 8812, "qdb", "admin", "quest");
4043

44+
// Decode and apply the strategy configuration from Base64-encoded JSON
4145
JsonParser::parseConfigurationFromBase64(argv[2]);
4246

47+
// Define the instruments to backtest and stream their historical tick data
4348
std::vector<std::string> symbols = {"AUSIDXAUD", "EURUSD"};
4449
std::vector<PriceData> ticks = SqlManager::streamPriceData(db, symbols, 1);
4550
printf("Total ticks streamed: %zu\n", ticks.size());
4651

52+
// Execute the backtest by replaying all ticks through the strategy logic
4753
Operations::run(ticks);
4854

4955
return 0;

0 commit comments

Comments
 (0)