Skip to content

Commit e2700f2

Browse files
authored
Merge pull request #7 from mccaffers/dev/improve_code_coverage
Refactoring include out of the source folder, added in an SQL manager
2 parents 19478c2 + 5036f9f commit e2700f2

28 files changed

Lines changed: 84 additions & 41 deletions

.github/workflows/brew.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ check_and_install() {
1111
}
1212

1313
# Install packages if they don't exist
14-
check_and_install postgresql # Check and install PostgreSQL
14+
check_and_install postgresql # Check and install PostgreSQL (which includes libpq)
1515
check_and_install pkg-config # Check and install pkg-config

.github/workflows/build.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ cd ./external/libpqxx
1111
mkdir -p build
1212
cd ./build
1313

14-
# Generate build system files using CMake
15-
# '..' points to the libpqxx root directory containing CMakeLists.txt
16-
cmake ..
14+
# Expose paths so CMake finds libpq
15+
export PATH="$(brew --prefix libpq)/bin:$PATH"
16+
export PKG_CONFIG_PATH="$(brew --prefix libpq)/lib/pkgconfig:$PKG_CONFIG_PATH"
17+
export PostgreSQL_ROOT="$(brew --prefix libpq)"
1718

18-
# Configure the build with specific C++ compiler flags:
19-
# -std=c++20: Use C++20 standard
20-
# -O3: Enable maximum optimization
21-
# --enable-silent-rules: Reduce build output verbosity
22-
./configure CXXFLAGS="-std=c++20 -O3" --enable-silent-rules
19+
# 1. Generate build files (Passing your CXX flags directly to CMake instead of configure)
20+
cmake .. -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release
2321

24-
# Compile libpqxx using generated build files
22+
# 2. Compile libpqxx
2523
make

.github/workflows/sonarcloud.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
-derivedDataPath "${RUNNER_TEMP}/Build/DerivedData"
6363
HEADER_SEARCH_PATHS="./external/libpqxx/include/pqxx/internal ./external/libpqxx/include/ ./external/libpqxx/build/include/ ./external/"
6464
LIBRARY_SEARCH_PATHS="./external/libpqxx/src/ ./external/libpqxx/build/src/"
65-
OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L/opt/homebrew/Cellar/pkgconf/2.3.0_1/lib -L/opt/homebrew/Cellar/pkgconf/2.3.0_1/lib/pkgconfig -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14 -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14/pgxs -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14/pkgconfig"
65+
OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L$(brew --prefix pkgconf)/lib -L$(brew --prefix pkgconf)/lib/pkgconfig -L$(brew --prefix postgresql@18)/lib/postgresql -L$(brew --prefix postgresql@18)/lib/postgresql/pgxs -L$(brew --prefix postgresql@18)/lib/postgresql/pkgconfig"
6666
clean build test
6767
| xcpretty -r junit && exit ${PIPESTATUS[0]}
6868
- name: Convert coverage report to sonarqube format

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ TestResult
3939
xcuserdata/
4040
xcuserstate/
4141
TestResult.xcresult/
42-
sonarqube-generic-coverage.xml
42+
sonarqube-generic-coverage.xml
43+
external/libpqxx

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ add_subdirectory(external/libpqxx EXCLUDE_FROM_ALL)
3737

3838
# Include directories
3939
include_directories(
40-
${CMAKE_SOURCE_DIR}/source/include
41-
${CMAKE_SOURCE_DIR}/source/include/utilities
42-
${CMAKE_SOURCE_DIR}/source/include/models
43-
${CMAKE_SOURCE_DIR}/source/include/trading
44-
${CMAKE_SOURCE_DIR}/source/include/trading_definitions
40+
${CMAKE_SOURCE_DIR}/include
41+
${CMAKE_SOURCE_DIR}/include/utilities
42+
${CMAKE_SOURCE_DIR}/include/models
43+
${CMAKE_SOURCE_DIR}/include/trading
44+
${CMAKE_SOURCE_DIR}/include/trading_definitions
4545
${CMAKE_SOURCE_DIR}/external
4646
)
4747

backtesting-engine-cpp.xcodeproj/project.pbxproj

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
940A61142C92CE210083FEB8 /* configManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 940A61112C92CE210083FEB8 /* configManager.cpp */; };
1212
940A61172C92CE960083FEB8 /* serviceA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 940A61152C92CE960083FEB8 /* serviceA.cpp */; };
1313
940A61182C92CE960083FEB8 /* serviceA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 940A61152C92CE960083FEB8 /* serviceA.cpp */; };
14+
941408AE2D59F93F000ED1F9 /* sqlManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 941408AD2D59F93F000ED1F9 /* sqlManager.cpp */; };
15+
941408AF2D59F93F000ED1F9 /* sqlManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 941408AD2D59F93F000ED1F9 /* sqlManager.cpp */; };
1416
941B549A2D3BBADE00E3BF64 /* trading_definitions_json.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 941B54992D3BBADD00E3BF64 /* trading_definitions_json.cpp */; };
1517
941B549B2D3BBADE00E3BF64 /* trading_definitions_json.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 941B54992D3BBADD00E3BF64 /* trading_definitions_json.cpp */; };
1618
94280BA32D2FC00200F1CF56 /* base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94280BA22D2FC00200F1CF56 /* base64.cpp */; };
@@ -51,6 +53,8 @@
5153
940A61122C92CE210083FEB8 /* configManager.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = configManager.hpp; sourceTree = "<group>"; };
5254
940A61152C92CE960083FEB8 /* serviceA.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = serviceA.cpp; sourceTree = "<group>"; };
5355
940A61162C92CE960083FEB8 /* serviceA.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = serviceA.hpp; sourceTree = "<group>"; };
56+
941408AD2D59F93F000ED1F9 /* sqlManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = sqlManager.cpp; sourceTree = "<group>"; };
57+
941408B02D59F954000ED1F9 /* sqlManager.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = sqlManager.hpp; sourceTree = "<group>"; };
5458
941B54902D3BBA4900E3BF64 /* ohlc_variables.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ohlc_variables.hpp; sourceTree = "<group>"; };
5559
941B54912D3BBA5600E3BF64 /* ohlc_rsi_variables.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ohlc_rsi_variables.hpp; sourceTree = "<group>"; };
5660
941B54922D3BBA6500E3BF64 /* trading_variables.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = trading_variables.hpp; sourceTree = "<group>"; };
@@ -1317,6 +1321,7 @@
13171321
94CD849E2D2D22C900041BBA /* external */,
13181322
944D0DD22C8C3704004DD0FC /* images */,
13191323
944D0DCE2C8C3704004DD0FC /* scripts */,
1324+
94DE4F772C8C3E7C00FE48FF /* include */,
13201325
9470B5A22C8C5AD0007D9CC6 /* source */,
13211326
9470B5AD2C8C5B99007D9CC6 /* tests */,
13221327
948A9CEC2C906ADB00E23669 /* resources */,
@@ -1395,16 +1400,16 @@
13951400
9470B5A22C8C5AD0007D9CC6 /* source */ = {
13961401
isa = PBXGroup;
13971402
children = (
1398-
943398232D57E53400287A2D /* jsonParser.cpp */,
13991403
94674B8C2D533E7800973137 /* models */,
14001404
94674B862D533B4000973137 /* trading */,
1401-
94DE4F772C8C3E7C00FE48FF /* include */,
14021405
941B54982D3BBAD800E3BF64 /* trading_definitions */,
14031406
94280BA72D2FC29F00F1CF56 /* utilities */,
14041407
9470B5A32C8C5AD0007D9CC6 /* main.cpp */,
14051408
940A61112C92CE210083FEB8 /* configManager.cpp */,
14061409
940A61152C92CE960083FEB8 /* serviceA.cpp */,
14071410
94CD8B9F2D2E8CE500041BBA /* databaseConnection.cpp */,
1411+
943398232D57E53400287A2D /* jsonParser.cpp */,
1412+
941408AD2D59F93F000ED1F9 /* sqlManager.cpp */,
14081413
);
14091414
path = source;
14101415
sourceTree = "<group>";
@@ -3510,6 +3515,7 @@
35103515
94DE4F772C8C3E7C00FE48FF /* include */ = {
35113516
isa = PBXGroup;
35123517
children = (
3518+
941408B02D59F954000ED1F9 /* sqlManager.hpp */,
35133519
943398222D57E52900287A2D /* jsonParser.hpp */,
35143520
94674B842D533B2F00973137 /* trading */,
35153521
942966D72D48E84100532862 /* models */,
@@ -3616,6 +3622,7 @@
36163622
isa = PBXSourcesBuildPhase;
36173623
buildActionMask = 2147483647;
36183624
files = (
3625+
941408AE2D59F93F000ED1F9 /* sqlManager.cpp in Sources */,
36193626
9470B5A42C8C5AD0007D9CC6 /* main.cpp in Sources */,
36203627
943398252D57E53400287A2D /* jsonParser.cpp in Sources */,
36213628
94280BA32D2FC00200F1CF56 /* base64.cpp in Sources */,
@@ -3633,6 +3640,7 @@
36333640
buildActionMask = 2147483647;
36343641
files = (
36353642
94CD8BA12D2E8CE500041BBA /* databaseConnection.cpp in Sources */,
3643+
941408AF2D59F93F000ED1F9 /* sqlManager.cpp in Sources */,
36363644
943398242D57E53400287A2D /* jsonParser.cpp in Sources */,
36373645
94280BA42D2FC00200F1CF56 /* base64.cpp in Sources */,
36383646
94674B8D2D533E7800973137 /* trade.cpp in Sources */,
@@ -3777,9 +3785,8 @@
37773785
);
37783786
INCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES = "";
37793787
LIBRARY_SEARCH_PATHS = (
3780-
"\"$(SRCROOT)/external/libpqxx/src\"",
3781-
"$(SRCROOT)/build/external/libpqxx/src",
3782-
"/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14",
3788+
"\"$(SRCROOT)/external/libpqxx/build/src\"",
3789+
"/opt/homebrew/Cellar/postgresql@18/18.3/lib/postgresql",
37833790
);
37843791
OTHER_LDFLAGS = "";
37853792
OTHER_LIBTOOLFLAGS = "";
@@ -3800,9 +3807,8 @@
38003807
);
38013808
INCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES = "";
38023809
LIBRARY_SEARCH_PATHS = (
3803-
"\"$(SRCROOT)/external/libpqxx/src\"",
3804-
"$(SRCROOT)/build/external/libpqxx/src",
3805-
"/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14",
3810+
"\"$(SRCROOT)/external/libpqxx/build/src\"",
3811+
"/opt/homebrew/Cellar/postgresql@18/18.3/lib/postgresql",
38063812
);
38073813
OTHER_LDFLAGS = "";
38083814
OTHER_LIBTOOLFLAGS = "";
@@ -3823,9 +3829,8 @@
38233829
"\"$(SRCROOT)/external/",
38243830
);
38253831
LIBRARY_SEARCH_PATHS = (
3826-
"\"$(SRCROOT)/external/libpqxx/src\"",
3827-
"$(PROJECT_DIR)/build/external/libpqxx/src",
3828-
"/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14",
3832+
"\"$(SRCROOT)/external/libpqxx/build/src\"",
3833+
"/opt/homebrew/Cellar/postgresql@18/18.3/lib/postgresql",
38293834
);
38303835
MARKETING_VERSION = 1.0;
38313836
PRODUCT_BUNDLE_IDENTIFIER = com.mccaffers.tests;
@@ -3846,9 +3851,8 @@
38463851
"\"$(SRCROOT)/external/",
38473852
);
38483853
LIBRARY_SEARCH_PATHS = (
3849-
"\"$(SRCROOT)/external/libpqxx/src\"",
3850-
"$(PROJECT_DIR)/build/external/libpqxx/src",
3851-
"/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14",
3854+
"\"$(SRCROOT)/external/libpqxx/build/src\"",
3855+
"/opt/homebrew/Cellar/postgresql@18/18.3/lib/postgresql",
38523856
);
38533857
MARKETING_VERSION = 1.0;
38543858
PRODUCT_BUNDLE_IDENTIFIER = com.mccaffers.tests;

backtesting-engine-cpp.xcodeproj/xcshareddata/xcschemes/source.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
</BuildableProductRunnable>
5959
<CommandLineArguments>
6060
<CommandLineArgument
61-
argument = "100.85.44.114"
61+
argument = "localhost"
6262
isEnabled = "YES">
6363
</CommandLineArgument>
6464
<CommandLineArgument

0 commit comments

Comments
 (0)