Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
[submodule "variant"]
path = External/variant
url = https://github.com/mpark/variant.git
[submodule "MacroPowerToys"]
path = External/MacroPowerToys
url = https://github.com/Neko-Box-Coder/MacroPowerToys.git
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ if(RUNCPP2_BUILD_TESTS)
endif()
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/CppOverride")

add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/MacroPowerToys")


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

add_library(runcpp2 STATIC ${RUNCPP2_SOURCE_FILES})

set(RUNCPP2_PRIVATE_LINK_LIBS ssLogger System2 CppOverride dylib)
set(RUNCPP2_PUBLIC_LINK_LIBS ghc_filesystem ryml::ryml mpark_variant MacroPowerToys)

target_include_directories(runcpp2 PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")
target_link_libraries(runcpp2 PRIVATE ssLogger System2 CppOverride dylib)
target_link_libraries(runcpp2 PUBLIC ghc_filesystem ryml::ryml mpark_variant)
target_link_libraries(runcpp2 PRIVATE ${RUNCPP2_PRIVATE_LINK_LIBS})
target_link_libraries(runcpp2 PUBLIC ${RUNCPP2_PUBLIC_LINK_LIBS})

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

add_executable(runcpp2_main "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/main.cpp")
target_compile_options(runcpp2_main PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
target_link_libraries(runcpp2_main PRIVATE runcpp2 ssLogger ghc_filesystem)
target_link_libraries(runcpp2_main PRIVATE runcpp2 ssLogger)
set_target_properties(runcpp2_main PROPERTIES OUTPUT_NAME "runcpp2")

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

add_library(runcpp2_override STATIC ${RUNCPP2_SOURCE_FILES})
target_include_directories(runcpp2_override PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")
target_link_libraries(runcpp2_override PRIVATE ssLogger System2 CppOverride dylib)
target_link_libraries(runcpp2_override PUBLIC ghc_filesystem ryml::ryml mpark_variant)
target_link_libraries(runcpp2_override PRIVATE ${RUNCPP2_PRIVATE_LINK_LIBS})
target_link_libraries(runcpp2_override PUBLIC ${RUNCPP2_PUBLIC_LINK_LIBS})
target_compile_options(runcpp2_override PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
target_compile_definitions(runcpp2_override PUBLIC RUNCPP2_VERSION="${RUNCPP2_PROJECT_VERSION}"
INTERNAL_RUNCPP2_UNIT_TESTS=1)
Expand Down
1 change: 1 addition & 0 deletions External/MacroPowerToys
Submodule MacroPowerToys added at a18dc4
2 changes: 0 additions & 2 deletions Include/runcpp2/CompilingLinking.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace runcpp2
const Data::ScriptInfo& scriptInfo,
const std::vector<Data::DependencyInfo*>& availableDependencies,
const Data::Profile& profile,
bool buildExecutable,
const int maxThreads);

//TODO: Convert string paths to filesystem paths
Expand All @@ -36,7 +35,6 @@ namespace runcpp2
const std::vector<Data::DependencyInfo*>& availableDependencies,
const Data::Profile& profile,
const std::vector<std::string>& compiledObjectsPaths,
bool buildExecutable,
const int maxThreads);
}

Expand Down
18 changes: 12 additions & 6 deletions Include/runcpp2/Data/BuildType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,29 @@ namespace runcpp2
STATIC,
SHARED,
OBJECTS,
INTERNAL_EXECUTABLE_EXECUTABLE,
INTERNAL_EXECUTABLE_SHARED,
COUNT
};

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

switch(buildType)
{
case BuildType::EXECUTABLE:
return "Executable";

case BuildType::STATIC:
return "Static";

case BuildType::SHARED:
return "Shared";

case BuildType::OBJECTS:
return "Objects";

case BuildType::INTERNAL_EXECUTABLE_EXECUTABLE:
return "InternalExecutable";
case BuildType::INTERNAL_EXECUTABLE_SHARED:
return "InternalExecutableShared";
default:
return "";
}
Expand All @@ -49,10 +51,14 @@ namespace runcpp2
return BuildType::SHARED;
else if(buildTypeStr == "Objects")
return BuildType::OBJECTS;
else if(buildTypeStr == "InternalExecutable")
return BuildType::INTERNAL_EXECUTABLE_EXECUTABLE;
else if(buildTypeStr == "InternalExecutableShared")
return BuildType::INTERNAL_EXECUTABLE_SHARED;

return BuildType::COUNT;
}
}
}

#endif
#endif
1 change: 0 additions & 1 deletion Include/runcpp2/Data/BuildTypeHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace runcpp2
const std::string& scriptName,
const Profile& profile,
const BuildType buildType,
const bool asExecutable,
std::vector<ghc::filesystem::path>& outPaths,
std::vector<bool>& outIsRunnable);
}
Expand Down
43 changes: 25 additions & 18 deletions Include/runcpp2/Data/ScriptInfo.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#ifndef RUNCPP2_DATA_SCRIPT_INFO_HPP
#define RUNCPP2_DATA_SCRIPT_INFO_HPP


#include "runcpp2/Data/DependencyInfo.hpp"
#include "runcpp2/Data/ProfilesFlagsOverride.hpp"
#include "runcpp2/Data/ProfilesProcessPaths.hpp"
#include "runcpp2/Data/ProfilesDefines.hpp"
#include "runcpp2/Data/ProfilesCommands.hpp"
#include "runcpp2/Data/BuildType.hpp"

#define RUNCPP2_CURRENT_CLASS_NAME ScriptInfo
#include "runcpp2/MacroUtil.hpp"

#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif
Expand All @@ -26,25 +28,29 @@ namespace runcpp2
class ScriptInfo
{
public:
std::string Language;
bool PassScriptPath = false;
BuildType CurrentBuildType = BuildType::EXECUTABLE;
std::unordered_map<PlatformName, std::vector<ProfileName>> RequiredProfiles;

std::unordered_map<PlatformName, ProfilesFlagsOverride> OverrideCompileFlags;
std::unordered_map<PlatformName, ProfilesFlagsOverride> OverrideLinkFlags;

std::unordered_map<PlatformName, ProfilesProcessPaths> OtherFilesToBeCompiled;
std::unordered_map<PlatformName, ProfilesProcessPaths> IncludePaths;

std::vector<DependencyInfo> Dependencies;
RUNCPP2_FIELD_BEGIN();

std::unordered_map<PlatformName, ProfilesDefines> Defines;
RUNCPP2_FIELD std::string Language;
RUNCPP2_FIELD bool PassScriptPath = false;
RUNCPP2_FIELD BuildType CurrentBuildType = BuildType::EXECUTABLE;
RUNCPP2_FIELD std::unordered_map< PlatformName,
std::vector<ProfileName>> RequiredProfiles;
RUNCPP2_FIELD std::unordered_map< PlatformName,
ProfilesFlagsOverride> OverrideCompileFlags;
RUNCPP2_FIELD std::unordered_map< PlatformName,
ProfilesFlagsOverride> OverrideLinkFlags;
RUNCPP2_FIELD std::unordered_map< PlatformName,
ProfilesProcessPaths> OtherFilesToBeCompiled;
RUNCPP2_FIELD std::unordered_map< PlatformName,
ProfilesProcessPaths> IncludePaths;
RUNCPP2_FIELD std::vector<DependencyInfo> Dependencies;
RUNCPP2_FIELD std::unordered_map<PlatformName, ProfilesDefines> Defines;
RUNCPP2_FIELD std::unordered_map<PlatformName, ProfilesCommands> Setup;
RUNCPP2_FIELD std::unordered_map<PlatformName, ProfilesCommands> PreBuild;
RUNCPP2_FIELD std::unordered_map<PlatformName, ProfilesCommands> PostBuild;
RUNCPP2_FIELD std::unordered_map<PlatformName, ProfilesCommands> Cleanup;

std::unordered_map<PlatformName, ProfilesCommands> Setup;
std::unordered_map<PlatformName, ProfilesCommands> PreBuild;
std::unordered_map<PlatformName, ProfilesCommands> PostBuild;
std::unordered_map<PlatformName, ProfilesCommands> Cleanup;
static constexpr int FieldsCount = RUNCPP2_FIELD_COUNT;

//Internal tracking
bool Populated = false;
Expand All @@ -54,6 +60,7 @@ namespace runcpp2

bool ParseYAML_Node(ryml::ConstNodeRef node);
std::string ToString(std::string indentation) const;
bool IsAllCompiledCacheInvalidated(const ScriptInfo& other) const;
bool Equals(const ScriptInfo& other) const;
};
}
Expand Down
1 change: 0 additions & 1 deletion Include/runcpp2/Data/StageInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ namespace runcpp2
std::string& inOutSubstitutedString) const;

bool ConstructCommand( const SubstitutionMap& substitutionMap,
const bool isExecutable,
const BuildType buildType,
std::string& outCommand) const;

Expand Down
20 changes: 20 additions & 0 deletions Include/runcpp2/MacroUtil.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "MacroPowerToys.h"

#if !defined(RUNCPP2_CURRENT_CLASS_NAME)
#error "RUNCPP2_CURRENT_CLASS_NAME needs to be defined"
#else
#if defined(RUNCPP2_FIELD_BEGIN)
#undef RUNCPP2_FIELD_BEGIN
#undef RUNCPP2_FIELD
#undef RUNCPP2_FIELD_END
#endif

#define RUNCPP2_FIELD_BEGIN() MPT_START_COUNTER_AND_INCREMENT( RUNCPP2_CURRENT_CLASS_NAME )

#define RUNCPP2_FIELD MPT_INCREMENT_COUNTER();

#define RUNCPP2_FIELD_COUNT MPT_GET_COUNT_AND_INCREMENT( RUNCPP2_CURRENT_CLASS_NAME ) - 1

#undef RUNCPP2_CURRENT_CLASS_NAME
#endif

3 changes: 2 additions & 1 deletion Include/runcpp2/PipelineSteps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace runcpp2
ParseAndValidateScriptInfo( const ghc::filesystem::path& absoluteScriptPath,
const ghc::filesystem::path& scriptDirectory,
const std::string& scriptName,
const bool buildExecutable,
Data::ScriptInfo& outScriptInfo);

PipelineResult HandleCleanup( const Data::ScriptInfo& scriptInfo,
Expand Down Expand Up @@ -67,7 +68,7 @@ namespace runcpp2
const ghc::filesystem::path& absoluteScriptPath,
const Data::ScriptInfo* lastScriptInfo,
const int maxThreads,
bool& outRecompileNeeded,
bool& outAllRecompileNeeded,
bool& outRelinkNeeded,
std::vector<std::string>& outChangedDependencies);

Expand Down
16 changes: 13 additions & 3 deletions Src/Tests/Data/BuildTypeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ int main(int argc, char** argv)
BuildTypeToString(BuildType::SHARED) == "Shared");
ssTEST_OUTPUT_ASSERT( "Objects string",
BuildTypeToString(BuildType::OBJECTS) == "Objects");
ssTEST_OUTPUT_ASSERT( "InternalExecutable string",
BuildTypeToString(BuildType::INTERNAL_EXECUTABLE_EXECUTABLE) ==
"InternalExecutable");
ssTEST_OUTPUT_ASSERT( "InternalExecutableShared string",
BuildTypeToString(BuildType::INTERNAL_EXECUTABLE_SHARED) ==
"InternalExecutableShared");
ssTEST_OUTPUT_ASSERT("COUNT string", BuildTypeToString(BuildType::COUNT) == "");

//Test StringToBuildType
Expand All @@ -33,7 +39,12 @@ int main(int argc, char** argv)
StringToBuildType("Shared") == BuildType::SHARED);
ssTEST_OUTPUT_ASSERT( "Objects from string",
StringToBuildType("Objects") == BuildType::OBJECTS);

ssTEST_OUTPUT_ASSERT( "InternalExecutable from string",
StringToBuildType("InternalExecutable") ==
BuildType::INTERNAL_EXECUTABLE_EXECUTABLE);
ssTEST_OUTPUT_ASSERT( "InternalExecutableShared from string",
StringToBuildType("InternalExecutableShared") ==
BuildType::INTERNAL_EXECUTABLE_SHARED);
//Test invalid strings
ssTEST_OUTPUT_ASSERT("Empty string", StringToBuildType("") == BuildType::COUNT);
ssTEST_OUTPUT_ASSERT("Invalid string", StringToBuildType("Invalid") == BuildType::COUNT);
Expand All @@ -42,7 +53,7 @@ int main(int argc, char** argv)

ssTEST("BuildType COUNT Should Match Number of Types")
{
ssTEST_OUTPUT_ASSERT("COUNT value", static_cast<int>(BuildType::COUNT) == 4);
ssTEST_OUTPUT_ASSERT("COUNT value", static_cast<int>(BuildType::COUNT), 6);
};

ssTEST("BuildType Should Generate Correct Output Paths")
Expand Down Expand Up @@ -72,7 +83,6 @@ int main(int argc, char** argv)
scriptName,
profile,
BuildType::STATIC,
false,
outTargets,
outIsRunnable);
);
Expand Down
Loading