Skip to content

Commit bc0a16e

Browse files
Merge pull request #55 from Neko-Box-Coder/InvalidateCacheWithBuildType
Invalidate cache when build type has changed and minor refactoring
2 parents c884545 + 5615729 commit bc0a16e

File tree

18 files changed

+283
-254
lines changed

18 files changed

+283
-254
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@
2828
[submodule "variant"]
2929
path = External/variant
3030
url = https://github.com/mpark/variant.git
31+
[submodule "MacroPowerToys"]
32+
path = External/MacroPowerToys
33+
url = https://github.com/Neko-Box-Coder/MacroPowerToys.git

CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ if(RUNCPP2_BUILD_TESTS)
8989
endif()
9090
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/CppOverride")
9191

92+
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/MacroPowerToys")
93+
9294

9395
# =========================================================================
9496
# Generate yaml files as c
@@ -169,9 +171,12 @@ set(RUNCPP2_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/Profile.
169171

170172
add_library(runcpp2 STATIC ${RUNCPP2_SOURCE_FILES})
171173

174+
set(RUNCPP2_PRIVATE_LINK_LIBS ssLogger System2 CppOverride dylib)
175+
set(RUNCPP2_PUBLIC_LINK_LIBS ghc_filesystem ryml::ryml mpark_variant MacroPowerToys)
176+
172177
target_include_directories(runcpp2 PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")
173-
target_link_libraries(runcpp2 PRIVATE ssLogger System2 CppOverride dylib)
174-
target_link_libraries(runcpp2 PUBLIC ghc_filesystem ryml::ryml mpark_variant)
178+
target_link_libraries(runcpp2 PRIVATE ${RUNCPP2_PRIVATE_LINK_LIBS})
179+
target_link_libraries(runcpp2 PUBLIC ${RUNCPP2_PUBLIC_LINK_LIBS})
175180

176181
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
177182
# TODO: Try to change to /Wall
@@ -208,7 +213,7 @@ target_compile_definitions(runcpp2 PUBLIC RUNCPP2_VERSION="${RUNCPP2_PROJECT_VER
208213

209214
add_executable(runcpp2_main "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/main.cpp")
210215
target_compile_options(runcpp2_main PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
211-
target_link_libraries(runcpp2_main PRIVATE runcpp2 ssLogger ghc_filesystem)
216+
target_link_libraries(runcpp2_main PRIVATE runcpp2 ssLogger)
212217
set_target_properties(runcpp2_main PROPERTIES OUTPUT_NAME "runcpp2")
213218

214219
# =========================================================================
@@ -217,8 +222,8 @@ set_target_properties(runcpp2_main PROPERTIES OUTPUT_NAME "runcpp2")
217222

218223
add_library(runcpp2_override STATIC ${RUNCPP2_SOURCE_FILES})
219224
target_include_directories(runcpp2_override PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")
220-
target_link_libraries(runcpp2_override PRIVATE ssLogger System2 CppOverride dylib)
221-
target_link_libraries(runcpp2_override PUBLIC ghc_filesystem ryml::ryml mpark_variant)
225+
target_link_libraries(runcpp2_override PRIVATE ${RUNCPP2_PRIVATE_LINK_LIBS})
226+
target_link_libraries(runcpp2_override PUBLIC ${RUNCPP2_PUBLIC_LINK_LIBS})
222227
target_compile_options(runcpp2_override PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
223228
target_compile_definitions(runcpp2_override PUBLIC RUNCPP2_VERSION="${RUNCPP2_PROJECT_VERSION}"
224229
INTERNAL_RUNCPP2_UNIT_TESTS=1)

External/MacroPowerToys

Submodule MacroPowerToys added at a18dc4d

Include/runcpp2/CompilingLinking.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace runcpp2
2222
const Data::ScriptInfo& scriptInfo,
2323
const std::vector<Data::DependencyInfo*>& availableDependencies,
2424
const Data::Profile& profile,
25-
bool buildExecutable,
2625
const int maxThreads);
2726

2827
//TODO: Convert string paths to filesystem paths
@@ -36,7 +35,6 @@ namespace runcpp2
3635
const std::vector<Data::DependencyInfo*>& availableDependencies,
3736
const Data::Profile& profile,
3837
const std::vector<std::string>& compiledObjectsPaths,
39-
bool buildExecutable,
4038
const int maxThreads);
4139
}
4240

Include/runcpp2/Data/BuildType.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,29 @@ namespace runcpp2
1313
STATIC,
1414
SHARED,
1515
OBJECTS,
16+
INTERNAL_EXECUTABLE_EXECUTABLE,
17+
INTERNAL_EXECUTABLE_SHARED,
1618
COUNT
1719
};
1820

1921
inline std::string BuildTypeToString(BuildType buildType)
2022
{
21-
static_assert(static_cast<int>(BuildType::COUNT) == 4, "Add new type to be processed");
23+
static_assert(static_cast<int>(BuildType::COUNT) == 6, "Add new type to be processed");
2224

2325
switch(buildType)
2426
{
2527
case BuildType::EXECUTABLE:
2628
return "Executable";
27-
2829
case BuildType::STATIC:
2930
return "Static";
30-
3131
case BuildType::SHARED:
3232
return "Shared";
33-
3433
case BuildType::OBJECTS:
3534
return "Objects";
36-
35+
case BuildType::INTERNAL_EXECUTABLE_EXECUTABLE:
36+
return "InternalExecutable";
37+
case BuildType::INTERNAL_EXECUTABLE_SHARED:
38+
return "InternalExecutableShared";
3739
default:
3840
return "";
3941
}
@@ -49,10 +51,14 @@ namespace runcpp2
4951
return BuildType::SHARED;
5052
else if(buildTypeStr == "Objects")
5153
return BuildType::OBJECTS;
54+
else if(buildTypeStr == "InternalExecutable")
55+
return BuildType::INTERNAL_EXECUTABLE_EXECUTABLE;
56+
else if(buildTypeStr == "InternalExecutableShared")
57+
return BuildType::INTERNAL_EXECUTABLE_SHARED;
5258

5359
return BuildType::COUNT;
5460
}
5561
}
5662
}
5763

58-
#endif
64+
#endif

Include/runcpp2/Data/BuildTypeHelper.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ namespace runcpp2
1818
const std::string& scriptName,
1919
const Profile& profile,
2020
const BuildType buildType,
21-
const bool asExecutable,
2221
std::vector<ghc::filesystem::path>& outPaths,
2322
std::vector<bool>& outIsRunnable);
2423
}

Include/runcpp2/Data/ScriptInfo.hpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#ifndef RUNCPP2_DATA_SCRIPT_INFO_HPP
22
#define RUNCPP2_DATA_SCRIPT_INFO_HPP
33

4-
54
#include "runcpp2/Data/DependencyInfo.hpp"
65
#include "runcpp2/Data/ProfilesFlagsOverride.hpp"
76
#include "runcpp2/Data/ProfilesProcessPaths.hpp"
87
#include "runcpp2/Data/ProfilesDefines.hpp"
98
#include "runcpp2/Data/ProfilesCommands.hpp"
109
#include "runcpp2/Data/BuildType.hpp"
1110

11+
#define RUNCPP2_CURRENT_CLASS_NAME ScriptInfo
12+
#include "runcpp2/MacroUtil.hpp"
13+
1214
#if !defined(NOMINMAX)
1315
#define NOMINMAX 1
1416
#endif
@@ -26,25 +28,29 @@ namespace runcpp2
2628
class ScriptInfo
2729
{
2830
public:
29-
std::string Language;
30-
bool PassScriptPath = false;
31-
BuildType CurrentBuildType = BuildType::EXECUTABLE;
32-
std::unordered_map<PlatformName, std::vector<ProfileName>> RequiredProfiles;
33-
34-
std::unordered_map<PlatformName, ProfilesFlagsOverride> OverrideCompileFlags;
35-
std::unordered_map<PlatformName, ProfilesFlagsOverride> OverrideLinkFlags;
36-
37-
std::unordered_map<PlatformName, ProfilesProcessPaths> OtherFilesToBeCompiled;
38-
std::unordered_map<PlatformName, ProfilesProcessPaths> IncludePaths;
39-
40-
std::vector<DependencyInfo> Dependencies;
31+
RUNCPP2_FIELD_BEGIN();
4132

42-
std::unordered_map<PlatformName, ProfilesDefines> Defines;
33+
RUNCPP2_FIELD std::string Language;
34+
RUNCPP2_FIELD bool PassScriptPath = false;
35+
RUNCPP2_FIELD BuildType CurrentBuildType = BuildType::EXECUTABLE;
36+
RUNCPP2_FIELD std::unordered_map< PlatformName,
37+
std::vector<ProfileName>> RequiredProfiles;
38+
RUNCPP2_FIELD std::unordered_map< PlatformName,
39+
ProfilesFlagsOverride> OverrideCompileFlags;
40+
RUNCPP2_FIELD std::unordered_map< PlatformName,
41+
ProfilesFlagsOverride> OverrideLinkFlags;
42+
RUNCPP2_FIELD std::unordered_map< PlatformName,
43+
ProfilesProcessPaths> OtherFilesToBeCompiled;
44+
RUNCPP2_FIELD std::unordered_map< PlatformName,
45+
ProfilesProcessPaths> IncludePaths;
46+
RUNCPP2_FIELD std::vector<DependencyInfo> Dependencies;
47+
RUNCPP2_FIELD std::unordered_map<PlatformName, ProfilesDefines> Defines;
48+
RUNCPP2_FIELD std::unordered_map<PlatformName, ProfilesCommands> Setup;
49+
RUNCPP2_FIELD std::unordered_map<PlatformName, ProfilesCommands> PreBuild;
50+
RUNCPP2_FIELD std::unordered_map<PlatformName, ProfilesCommands> PostBuild;
51+
RUNCPP2_FIELD std::unordered_map<PlatformName, ProfilesCommands> Cleanup;
4352

44-
std::unordered_map<PlatformName, ProfilesCommands> Setup;
45-
std::unordered_map<PlatformName, ProfilesCommands> PreBuild;
46-
std::unordered_map<PlatformName, ProfilesCommands> PostBuild;
47-
std::unordered_map<PlatformName, ProfilesCommands> Cleanup;
53+
static constexpr int FieldsCount = RUNCPP2_FIELD_COUNT;
4854

4955
//Internal tracking
5056
bool Populated = false;
@@ -54,6 +60,7 @@ namespace runcpp2
5460

5561
bool ParseYAML_Node(ryml::ConstNodeRef node);
5662
std::string ToString(std::string indentation) const;
63+
bool IsAllCompiledCacheInvalidated(const ScriptInfo& other) const;
5764
bool Equals(const ScriptInfo& other) const;
5865
};
5966
}

Include/runcpp2/Data/StageInfo.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ namespace runcpp2
5858
std::string& inOutSubstitutedString) const;
5959

6060
bool ConstructCommand( const SubstitutionMap& substitutionMap,
61-
const bool isExecutable,
6261
const BuildType buildType,
6362
std::string& outCommand) const;
6463

Include/runcpp2/MacroUtil.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "MacroPowerToys.h"
2+
3+
#if !defined(RUNCPP2_CURRENT_CLASS_NAME)
4+
#error "RUNCPP2_CURRENT_CLASS_NAME needs to be defined"
5+
#else
6+
#if defined(RUNCPP2_FIELD_BEGIN)
7+
#undef RUNCPP2_FIELD_BEGIN
8+
#undef RUNCPP2_FIELD
9+
#undef RUNCPP2_FIELD_END
10+
#endif
11+
12+
#define RUNCPP2_FIELD_BEGIN() MPT_START_COUNTER_AND_INCREMENT( RUNCPP2_CURRENT_CLASS_NAME )
13+
14+
#define RUNCPP2_FIELD MPT_INCREMENT_COUNTER();
15+
16+
#define RUNCPP2_FIELD_COUNT MPT_GET_COUNT_AND_INCREMENT( RUNCPP2_CURRENT_CLASS_NAME ) - 1
17+
18+
#undef RUNCPP2_CURRENT_CLASS_NAME
19+
#endif
20+

Include/runcpp2/PipelineSteps.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace runcpp2
4040
ParseAndValidateScriptInfo( const ghc::filesystem::path& absoluteScriptPath,
4141
const ghc::filesystem::path& scriptDirectory,
4242
const std::string& scriptName,
43+
const bool buildExecutable,
4344
Data::ScriptInfo& outScriptInfo);
4445

4546
PipelineResult HandleCleanup( const Data::ScriptInfo& scriptInfo,
@@ -67,7 +68,7 @@ namespace runcpp2
6768
const ghc::filesystem::path& absoluteScriptPath,
6869
const Data::ScriptInfo* lastScriptInfo,
6970
const int maxThreads,
70-
bool& outRecompileNeeded,
71+
bool& outAllRecompileNeeded,
7172
bool& outRelinkNeeded,
7273
std::vector<std::string>& outChangedDependencies);
7374

0 commit comments

Comments
 (0)