Skip to content

Commit dd3a2ec

Browse files
Merge pull request #57 from Neko-Box-Coder/ConfigVersionTracking
Adding config version tracking, Updating CppOverride
2 parents 33e3d26 + eb1f814 commit dd3a2ec

File tree

16 files changed

+1284
-1093
lines changed

16 files changed

+1284
-1093
lines changed

CMakeLists.txt

Lines changed: 10 additions & 5 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
@@ -203,16 +206,17 @@ else()
203206
"-Wno-switch"
204207
"-Wno-gnu-zero-variadic-macro-arguments"
205208
"-Wextra"
206-
"-pedantic")
209+
"-Wpedantic")
207210
if (RUNCPP2_WARNINGS_AS_ERRORS)
208211
list(APPEND RUNCPP2_STANDARD_COMPILE_FLAGS "-Werror")
209212
endif()
210213
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")

External/CppOverride

Submodule CppOverride updated 87 files

Include/Tests/BuildsManager/MockComponents.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ namespace ghc
1717
{
1818
namespace filesystem
1919
{
20-
CO_OVERRIDE_METHOD( OverrideInstance,
20+
CO_INSERT_METHOD( OverrideInstance,
2121
bool,
2222
Mock_exists,
2323
(const path&, std::error_code&),
2424
/* no prepend */,
2525
noexcept)
2626

27-
CO_OVERRIDE_METHOD( OverrideInstance,
27+
CO_INSERT_METHOD( OverrideInstance,
2828
bool,
2929
Mock_create_directories,
3030
(const path&, std::error_code&),
3131
/* no prepend */,
3232
noexcept)
3333

34-
CO_OVERRIDE_METHOD( OverrideInstance,
34+
CO_INSERT_METHOD( OverrideInstance,
3535
bool,
3636
Mock_remove_all,
3737
(const path&, std::error_code&),
@@ -45,21 +45,21 @@ namespace std
4545
class Mock_ifstream
4646
{
4747
public:
48-
CO_OVERRIDE_MEMBER_METHOD_CTOR(OverrideInstance, Mock_ifstream, const ghc::filesystem::path&)
49-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, std::string, rdbuf, ())
50-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, bool, is_open, ())
51-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, void, close, ())
48+
CO_INSERT_MEMBER_METHOD_CTOR(OverrideInstance, Mock_ifstream, const ghc::filesystem::path&)
49+
CO_INSERT_MEMBER_METHOD(OverrideInstance, std::string, rdbuf, ())
50+
CO_INSERT_MEMBER_METHOD(OverrideInstance, bool, is_open, ())
51+
CO_INSERT_MEMBER_METHOD(OverrideInstance, void, close, ())
5252
};
5353

5454
class Mock_ofstream
5555
{
5656
public:
5757
std::stringstream StringStream;
5858

59-
CO_OVERRIDE_MEMBER_METHOD_CTOR(OverrideInstance, Mock_ofstream, const ghc::filesystem::path&)
59+
CO_INSERT_MEMBER_METHOD_CTOR(OverrideInstance, Mock_ofstream, const ghc::filesystem::path&)
6060

61-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, bool, is_open, ())
62-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, void, close, ())
61+
CO_INSERT_MEMBER_METHOD(OverrideInstance, bool, is_open, ())
62+
CO_INSERT_MEMBER_METHOD(OverrideInstance, void, close, ())
6363

6464
template<typename T>
6565
friend Mock_ofstream& operator<<(Mock_ofstream&, T const&);
@@ -70,7 +70,7 @@ namespace std
7070
{
7171
static_assert(std::is_same<T, std::string>::value, "We are only mocking std string");
7272
public:
73-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, std::size_t, operator(), (T))
73+
CO_INSERT_MEMBER_METHOD(OverrideInstance, std::size_t, operator(), (T))
7474
};
7575

7676
template<typename T>

Include/Tests/ConfigParsing/MockComponents.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ namespace ghc
1616
{
1717
namespace filesystem
1818
{
19-
CO_OVERRIDE_METHOD( OverrideInstance,
19+
CO_INSERT_METHOD( OverrideInstance,
2020
bool,
2121
Mock_exists,
2222
(const std::string&, std::error_code&),
2323
/* no prepend */,
2424
noexcept)
2525

26-
CO_OVERRIDE_METHOD( OverrideInstance,
26+
CO_INSERT_METHOD( OverrideInstance,
2727
bool,
2828
Mock_is_directory,
2929
(const std::string&, std::error_code&),
@@ -37,12 +37,11 @@ namespace std
3737
class Mock_ifstream
3838
{
3939
public:
40-
CO_OVERRIDE_MEMBER_METHOD_CTOR( OverrideInstance,
41-
Mock_ifstream,
42-
const ghc::filesystem::path&)
43-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, bool, operator!, ())
44-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, std::string, rdbuf, ())
45-
CO_OVERRIDE_METHOD( OverrideInstance,
40+
CO_INSERT_MEMBER_METHOD_CTOR(OverrideInstance, Mock_ifstream, const ghc::filesystem::path&)
41+
CO_INSERT_MEMBER_METHOD_DTOR(OverrideInstance, Mock_ifstream)
42+
CO_INSERT_MEMBER_METHOD(OverrideInstance, bool, operator!, ())
43+
CO_INSERT_MEMBER_METHOD(OverrideInstance, std::string, rdbuf, ())
44+
CO_INSERT_METHOD( OverrideInstance,
4645
Mock_ifstream&,
4746
operator<<,
4847
(Mock_ifstream&, T const&),

Include/Tests/IncludeManager/MockComponents.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ namespace ghc
1616
{
1717
namespace filesystem
1818
{
19-
CO_OVERRIDE_METHOD( OverrideInstance,
19+
CO_INSERT_METHOD( OverrideInstance,
2020
bool,
2121
Mock_exists,
2222
(const path&, std::error_code&),
2323
/* no prepend */,
2424
noexcept)
2525

26-
CO_OVERRIDE_METHOD( OverrideInstance,
26+
CO_INSERT_METHOD( OverrideInstance,
2727
bool,
2828
Mock_create_directories,
2929
(const path&, std::error_code&),
3030
/* no prepend */,
3131
noexcept)
3232

33-
CO_OVERRIDE_METHOD( OverrideInstance,
33+
CO_INSERT_METHOD( OverrideInstance,
3434
file_time_type,
3535
Mock_last_write_time,
3636
(const path&, std::error_code&),
@@ -44,18 +44,18 @@ namespace std
4444
class Mock_ifstream
4545
{
4646
public:
47-
CO_OVERRIDE_MEMBER_METHOD_CTOR(OverrideInstance, Mock_ifstream, const ghc::filesystem::path&)
48-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, bool, is_open, ())
47+
CO_INSERT_MEMBER_METHOD_CTOR(OverrideInstance, Mock_ifstream, const ghc::filesystem::path&)
48+
CO_INSERT_MEMBER_METHOD(OverrideInstance, bool, is_open, ())
4949
};
5050

5151
class Mock_ofstream
5252
{
5353
public:
5454
std::stringstream StringStream;
5555

56-
CO_OVERRIDE_MEMBER_METHOD_CTOR(OverrideInstance, Mock_ofstream, const ghc::filesystem::path&)
57-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, bool, is_open, ())
58-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, void, close, ())
56+
CO_INSERT_MEMBER_METHOD_CTOR(OverrideInstance, Mock_ofstream, const ghc::filesystem::path&)
57+
CO_INSERT_MEMBER_METHOD(OverrideInstance, bool, is_open, ())
58+
CO_INSERT_MEMBER_METHOD(OverrideInstance, void, close, ())
5959

6060
template<typename T>
6161
friend Mock_ofstream& operator<<(Mock_ofstream&, T const&);
@@ -66,7 +66,7 @@ namespace std
6666
{
6767
static_assert(std::is_same<T, std::string>::value, "We are only mocking std string");
6868
public:
69-
CO_OVERRIDE_MEMBER_METHOD(OverrideInstance, std::size_t, operator(), (T))
69+
CO_INSERT_MEMBER_METHOD(OverrideInstance, std::size_t, operator(), (T))
7070
};
7171

7272
template<typename T>
@@ -84,7 +84,7 @@ namespace std
8484

8585
inline bool Mock_getline(Mock_ifstream& stream, std::string& line)
8686
{
87-
CO_OVERRIDE_IMPL(OverrideInstance, bool, (stream, line));
87+
CO_INSERT_IMPL(OverrideInstance, bool, (stream, line));
8888
return false;
8989
}
9090
}

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)