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
44 changes: 29 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ project(runcpp2)
set(CMAKE_CXX_STANDARD 11)

option(RUNCPP2_UPDATE_DEFAULT_YAMLS "Update default yaml files" OFF)
option(RUNCPP2_BUILD_TESTS "Build runcpp2 tests" OFF)

if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
option(RUNCPP2_WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
option(RUNCPP2_BUILD_TESTS "Build runcpp2 tests" ON)
else()
option(RUNCPP2_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
option(RUNCPP2_BUILD_TESTS "Build runcpp2 tests" OFF)
endif()

# =========================================================================
# Retrieving Version String
Expand Down Expand Up @@ -158,28 +165,35 @@ target_link_libraries(runcpp2 PUBLIC ghc_filesystem ryml::ryml mpark_variant)

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# TODO: Try to change to /Wall
set(STANDARD_COMPILE_FLAGS "/utf-8;/W1;/DGHC_WIN_DISABLE_WSTRING_STORAGE_TYPE=1")
set(RUNCPP2_STANDARD_COMPILE_FLAGS "/utf-8;/W1;/DGHC_WIN_DISABLE_WSTRING_STORAGE_TYPE=1")
if (RUNCPP2_WARNINGS_AS_ERRORS)
list(APPEND RUNCPP2_STANDARD_COMPILE_FLAGS "/WX")
endif()

message("RUNCPP2_STANDARD_COMPILE_FLAGS: ${RUNCPP2_STANDARD_COMPILE_FLAGS}")
else()
set(STANDARD_COMPILE_FLAGS "-Wall"
"-Wno-return-local-addr"
"-Wno-sign-compare"
#"-Wno-unused-variable"
#"-Wno-unused-but-set-variable"
"-Wno-unused-parameter"
"-Wno-switch"
"-Wno-gnu-zero-variadic-macro-arguments"
"-Wextra"
"-pedantic"
"-Werror")
set(RUNCPP2_STANDARD_COMPILE_FLAGS "-Wall"
"-Wno-return-local-addr"
"-Wno-sign-compare"
#"-Wno-unused-variable"
#"-Wno-unused-but-set-variable"
"-Wno-unused-parameter"
"-Wno-switch"
"-Wno-gnu-zero-variadic-macro-arguments"
"-Wextra"
"-pedantic")
if (RUNCPP2_WARNINGS_AS_ERRORS)
list(APPEND RUNCPP2_STANDARD_COMPILE_FLAGS "-Werror")
endif()
endif()

target_compile_options(runcpp2 PRIVATE "${STANDARD_COMPILE_FLAGS}")
target_compile_options(runcpp2 PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")

# Define the version macro
target_compile_definitions(runcpp2 PUBLIC RUNCPP2_VERSION="${RUNCPP2_PROJECT_VERSION}")

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

Expand Down
2 changes: 1 addition & 1 deletion Include/runcpp2/Data/DependencyInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace runcpp2
std::unordered_map<PlatformName, ProfilesCommands> Build;
std::unordered_map<PlatformName, FilesToCopyInfo> FilesToCopy;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
std::string ToString(std::string indentation) const;
bool Equals(const DependencyInfo& other) const;
};
Expand Down
4 changes: 3 additions & 1 deletion Include/runcpp2/Data/DependencyLinkProperty.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ namespace runcpp2
public:
std::unordered_map<ProfileName, ProfileLinkProperty> ProfileProperties;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
std::string ToString(std::string indentation) const;
bool Equals(const DependencyLinkProperty& other) const;
};
Expand Down
2 changes: 1 addition & 1 deletion Include/runcpp2/Data/DependencySource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace runcpp2
ghc::filesystem::path ImportPath;
std::vector<std::shared_ptr<DependencySource>> ImportedSources;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
std::string ToString(std::string indentation) const;
bool Equals(const DependencySource& other) const;
};
Expand Down
2 changes: 1 addition & 1 deletion Include/runcpp2/Data/FileProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace runcpp2
std::unordered_map<PlatformName, std::string> Prefix;
std::unordered_map<PlatformName, std::string> Extension;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
std::string ToString(std::string indentation) const;
bool Equals(const FileProperties& other) const;
};
Expand Down
4 changes: 3 additions & 1 deletion Include/runcpp2/Data/FilesToCopyInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace runcpp2
{
std::unordered_map<ProfileName, std::vector<std::string>> ProfileFiles;

bool ParseYAML_Node(const ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
std::string ToString(std::string indentation) const;
bool Equals(const FilesToCopyInfo& other) const;
};
Expand Down
2 changes: 1 addition & 1 deletion Include/runcpp2/Data/FilesTypesInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace runcpp2
FileProperties StaticLinkFile;
FileProperties DebugSymbolFile;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
std::string ToString(std::string indentation) const;
bool Equals(const FilesTypesInfo& other) const;
};
Expand Down
3 changes: 2 additions & 1 deletion Include/runcpp2/Data/FlagsOverrideInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace runcpp2
std::string Remove;
std::string Append;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
std::string ToString(std::string indentation) const;
bool Equals(const FlagsOverrideInfo& other) const;
};
Expand Down
2 changes: 1 addition & 1 deletion Include/runcpp2/Data/GitSource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace runcpp2
bool FullHistory = false;
SubmoduleInitType CurrentSubmoduleInitType = SubmoduleInitType::SHALLOW;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
std::string ToString(std::string indentation) const;
bool Equals(const GitSource& other) const;
};
Expand Down
4 changes: 2 additions & 2 deletions Include/runcpp2/Data/LocalSource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ namespace runcpp2
std::string Path;
LocalCopyMode CopyMode = LocalCopyMode::Auto;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
std::string ToString(std::string indentation) const;
bool Equals(const LocalSource& other) const;
};
}
}

#endif
#endif
2 changes: 1 addition & 1 deletion Include/runcpp2/Data/Profile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace runcpp2
StageInfo Linker;

void GetNames(std::vector<std::string>& outNames) const;
bool ParseYAML_Node(ryml::ConstNodeRef& profileNode);
bool ParseYAML_Node(ryml::ConstNodeRef profileNode);
std::string ToString(std::string indentation) const;
bool Equals(const Profile& other) const;
};
Expand Down
4 changes: 3 additions & 1 deletion Include/runcpp2/Data/ProfilesCommands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ namespace runcpp2
//TODO: Allow specifying command can fail
std::unordered_map<ProfileName, std::vector<std::string>> CommandSteps;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
std::string ToString(std::string indentation) const;
bool Equals(const ProfilesCommands& other) const;
};
Expand Down
4 changes: 3 additions & 1 deletion Include/runcpp2/Data/ProfilesDefines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ namespace runcpp2
public:
std::unordered_map<ProfileName, std::vector<Define>> Defines;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
std::string ToString(std::string indentation) const;
bool Equals(const ProfilesDefines& other) const;
};
Expand Down
5 changes: 4 additions & 1 deletion Include/runcpp2/Data/ProfilesFlagsOverride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "FlagsOverrideInfo.hpp"
#include "runcpp2/Data/ParseCommon.hpp"

#include <unordered_map>

namespace runcpp2
Expand All @@ -14,7 +15,9 @@ namespace runcpp2
public:
std::unordered_map<ProfileName, FlagsOverrideInfo> FlagsOverrides;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
std::string ToString(std::string indentation) const;
bool Equals(const ProfilesFlagsOverride& other) const;
};
Expand Down
4 changes: 3 additions & 1 deletion Include/runcpp2/Data/ProfilesProcessPaths.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ namespace runcpp2
public:
std::unordered_map<ProfileName, std::vector<ghc::filesystem::path>> Paths;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
std::string ToString(std::string indentation) const;
bool Equals(const ProfilesProcessPaths& other) const;
};
Expand Down
2 changes: 1 addition & 1 deletion Include/runcpp2/Data/ScriptInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace runcpp2
ghc::filesystem::file_time_type LastWriteTime =
ghc::filesystem::file_time_type::min();

bool ParseYAML_Node(ryml::ConstNodeRef& node);
bool ParseYAML_Node(ryml::ConstNodeRef node);
std::string ToString(std::string indentation) const;
bool Equals(const ScriptInfo& other) const;
};
Expand Down
2 changes: 1 addition & 1 deletion Include/runcpp2/Data/StageInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace runcpp2
const BuildType buildType,
std::string& outCommand) const;

bool ParseYAML_Node(ryml::ConstNodeRef& node, std::string outputTypeKeyName);
bool ParseYAML_Node(ryml::ConstNodeRef node, std::string outputTypeKeyName);
std::string ToString( std::string indentation,
std::string outputTypeKeyName) const;
bool Equals(const StageInfo& other) const;
Expand Down
55 changes: 53 additions & 2 deletions Include/runcpp2/ParseUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
#define RUNCPP2_PARSE_UTIL_HPP

#include "runcpp2/YamlLib.hpp"
#include "runcpp2/Data/ParseCommon.hpp"
#include "ssLogger/ssLog.hpp"

#include <vector>
#include <unordered_map>

namespace runcpp2
{
Expand All @@ -21,15 +24,21 @@ namespace runcpp2
bool nullable);
};

bool CheckNodeRequirements( ryml::ConstNodeRef& node,
bool CheckNodeRequirement( ryml::ConstNodeRef node,
const std::string name,
ryml::NodeType nodeType,
bool required,
bool nullable);

bool CheckNodeRequirements( ryml::ConstNodeRef node,
const std::vector<NodeRequirement>& requirements);

bool GetParsableInfo(const std::string& contentToParse, std::string& outParsableInfo);

bool ResolveYAML_Stream(ryml::Tree& rootTree,
ryml::ConstNodeRef& outRootNode);

bool ExistAndHasChild( const ryml::ConstNodeRef& node,
bool ExistAndHasChild( ryml::ConstNodeRef node,
const std::string& childName,
bool nullable = false);

Expand All @@ -38,6 +47,48 @@ namespace runcpp2
std::string GetEscapedYAMLString(const std::string& input);

bool ParseIncludes(const std::string& line, std::string& outIncludePath);

template<typename T>
bool ParsePlatformProfileMap( ryml::ConstNodeRef node,
const std::string& key,
std::unordered_map<PlatformName, T>& result,
const std::string& errorMessage)
{
if(ExistAndHasChild(node, key))
{
ryml::ConstNodeRef mapNode = node[key.c_str()];

//If we skip platform profile
T defaultValue;
if(defaultValue.IsYAML_NodeParsableAsDefault(mapNode))
{
if(defaultValue.ParseYAML_NodeWithProfile(mapNode, "DefaultProfile"))
result["DefaultPlatform"] = defaultValue;
else
return false;
}
else
{
if(!CheckNodeRequirement(mapNode, key, ryml::NodeType_e::MAP, false, true))
return false;

for(int i = 0; i < mapNode.num_children(); ++i)
{
PlatformName platform = GetKey(mapNode[i]);
T value;
ryml::ConstNodeRef currentNode = mapNode[i];

if(!value.ParseYAML_Node(currentNode))
{
ssLOG_ERROR("ScriptInfo: Failed to parse " << errorMessage);
return false;
}
result[platform] = value;
}
}
}
return true;
}
}

#endif
6 changes: 3 additions & 3 deletions Src/Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ add_executable(BuildsManagerTest "${CMAKE_CURRENT_LIST_DIR}/../runcpp2/BuildsMan
# "${CMAKE_CURRENT_LIST_DIR}/../Tests/BuildsManager/MockComponents.cpp")

target_include_directories(BuildsManagerTest PRIVATE "${CMAKE_CURRENT_LIST_DIR}/../../Include")
target_compile_options(BuildsManagerTest PRIVATE "${STANDARD_COMPILE_FLAGS}")
target_compile_options(BuildsManagerTest PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
target_link_libraries(BuildsManagerTest PRIVATE ghc_filesystem CppOverride ssTest ssLogger)
target_compile_definitions(BuildsManagerTest PRIVATE INTERNAL_RUNCPP2_UNIT_TESTS=1)

add_executable(IncludeManagerTest "${CMAKE_CURRENT_LIST_DIR}/../runcpp2/IncludeManager.cpp"
"${CMAKE_CURRENT_LIST_DIR}/IncludeManagerTest.cpp")

target_include_directories(IncludeManagerTest PRIVATE "${CMAKE_CURRENT_LIST_DIR}/../../Include")
target_compile_options(IncludeManagerTest PRIVATE "${STANDARD_COMPILE_FLAGS}")
target_compile_options(IncludeManagerTest PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
target_link_libraries(IncludeManagerTest PRIVATE ghc_filesystem CppOverride ssTest ssLogger)
target_compile_definitions(IncludeManagerTest PRIVATE INTERNAL_RUNCPP2_UNIT_TESTS=1)

function(create_data_test TEST_NAME)
add_executable("${TEST_NAME}" "${CMAKE_CURRENT_LIST_DIR}/Data/${TEST_NAME}.cpp")
target_compile_options("${TEST_NAME}" PRIVATE "${STANDARD_COMPILE_FLAGS}")
target_compile_options("${TEST_NAME}" PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
target_compile_definitions("${TEST_NAME}" PRIVATE INTERNAL_RUNCPP2_UNIT_TESTS=1 TERMCOLOR_USE_ANSI_ESCAPE_SEQUENCES=1)
target_link_libraries("${TEST_NAME}" PUBLIC runcpp2 ssTest)

Expand Down
Loading