Skip to content

Commit 2e3926d

Browse files
Adding version tracking for default configs and updating config test
1 parent 589affd commit 2e3926d

File tree

5 files changed

+352
-258
lines changed

5 files changed

+352
-258
lines changed

CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ set(CMAKE_CXX_STANDARD 11)
99

1010
option(RUNCPP2_UPDATE_DEFAULT_YAMLS "Update default yaml files" OFF)
1111

12+
set(RUNCPP2_CONFIG_VERSION "1" CACHE STRING "Default Config Version")
13+
1214
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
1315
option(RUNCPP2_WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
1416
option(RUNCPP2_BUILD_TESTS "Build runcpp2 tests" ON)
@@ -55,17 +57,18 @@ function(get_version_from_git OUTPUT_VARIABLE)
5557
)
5658

5759
if(TAG_ON_COMMIT EQUAL 0)
58-
set(VERSION ${GIT_TAG})
60+
set(VERSION "${GIT_TAG}")
5961
else()
6062
set(VERSION "${GIT_TAG}-${GIT_COMMIT_HASH}")
6163
endif()
6264
else()
6365
# No tags found, use v0.0.0 with commit hash
6466
# set(VERSION "v0.0.0-${GIT_COMMIT_HASH}")
67+
6568
message(FATAL_ERROR "Failed to get tag: ${GIT_TAG}")
6669
endif()
6770

68-
set(${OUTPUT_VARIABLE} ${VERSION} PARENT_SCOPE)
71+
set(${OUTPUT_VARIABLE} "${VERSION}" PARENT_SCOPE)
6972
endfunction()
7073

7174
# Call the function and store the result
@@ -211,8 +214,9 @@ endif()
211214

212215
target_compile_options(runcpp2 PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
213216

214-
# Define the version macro
215-
target_compile_definitions(runcpp2 PUBLIC RUNCPP2_VERSION="${RUNCPP2_PROJECT_VERSION}")
217+
# Define the runcpp2 and default config version macro
218+
target_compile_definitions(runcpp2 PUBLIC RUNCPP2_VERSION="${RUNCPP2_PROJECT_VERSION}"
219+
RUNCPP2_CONFIG_VERSION=${RUNCPP2_CONFIG_VERSION})
216220

217221
# =========================================================================
218222
# runcpp2 executable
@@ -233,6 +237,7 @@ target_link_libraries(runcpp2_override PRIVATE ${RUNCPP2_PRIVATE_LINK_LIBS})
233237
target_link_libraries(runcpp2_override PUBLIC ${RUNCPP2_PUBLIC_LINK_LIBS})
234238
target_compile_options(runcpp2_override PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
235239
target_compile_definitions(runcpp2_override PUBLIC RUNCPP2_VERSION="${RUNCPP2_PROJECT_VERSION}"
240+
RUNCPP2_CONFIG_VERSION=${RUNCPP2_CONFIG_VERSION}
236241
INTERNAL_RUNCPP2_UNIT_TESTS=1)
237242
if(RUNCPP2_BUILD_TESTS)
238243
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Src/Tests")

Include/runcpp2/ConfigParsing.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33

44
#include "runcpp2/Data/Profile.hpp"
55
#include "runcpp2/Data/ScriptInfo.hpp"
6+
7+
#include "ghc/filesystem.hpp"
8+
69
#include <string>
710
#include <vector>
811
namespace runcpp2
912
{
1013
std::string GetConfigFilePath();
1114

12-
bool WriteDefaultConfig(const std::string& userConfigPath);
15+
bool WriteDefaultConfigs( const ghc::filesystem::path& userConfigPath,
16+
const bool writeUserConfig,
17+
const bool writeDefaultConfigs);
1318

1419
bool ReadUserConfig(std::vector<Data::Profile>& outProfiles,
1520
std::string& outPreferredProfile,

0 commit comments

Comments
 (0)