Skip to content

Commit b6ed754

Browse files
Merge pull request #62 from Neko-Box-Coder/libyaml
Switching YAML parsing from RapidYaml to LibYaml, license update and minor refactoring
2 parents 8c2d3b6 + d3c124a commit b6ed754

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+4837
-268
lines changed

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@
3131
[submodule "MacroPowerToys"]
3232
path = External/MacroPowerToys
3333
url = https://github.com/Neko-Box-Coder/MacroPowerToys.git
34+
[submodule "libyaml"]
35+
path = External/libyaml
36+
url = https://github.com/Neko-Box-Coder/libyaml.git
37+
[submodule "string-view-lite"]
38+
path = External/string-view-lite
39+
url = https://github.com/martinmoene/string-view-lite.git
40+
[submodule "DSResult"]
41+
path = External/DSResult
42+
url = https://github.com/Neko-Box-Coder/DSResult.git

CMakeLists.txt

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
55

66
project(runcpp2)
77

8+
# if(TARGET runcpp2)
9+
# message("runcpp2 cmake target has been added before. Skipping cmake...")
10+
# return()
11+
# endif()
12+
813
set(CMAKE_CXX_STANDARD 11)
914

1015
option(RUNCPP2_UPDATE_DEFAULT_YAMLS "Update default yaml files" OFF)
@@ -78,6 +83,20 @@ message("RUNCPP2_PROJECT_VERSION: ${RUNCPP2_PROJECT_VERSION}")
7883
# =========================================================================
7984
# External Dependencies
8085
# =========================================================================
86+
87+
# runcpp2 doesn't rely on install at all. Disabling it.
88+
# if(NOT DEFINED RUNCPP2_DISABLE_INSTALLATION)
89+
# # This variable is responsible for installation disabling.
90+
# set(RUNCPP2_DISABLE_INSTALLATION ON)
91+
#
92+
# # Replace install() with conditional installation.
93+
# macro(install)
94+
# if(NOT RUNCPP2_DISABLE_INSTALLATION)
95+
# _install(${ARGN})
96+
# endif()
97+
# endmacro()
98+
# endif()
99+
81100
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/ssLogger")
82101

83102
set(RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS ON CACHE BOOL "" FORCE)
@@ -88,12 +107,24 @@ add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/System2")
88107
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/dylib")
89108
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/variant")
90109

110+
set(EXPECTED_BUILD_PACKAGE OFF)
111+
set(BUILD_TESTING OFF)
112+
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/DSResult")
113+
114+
set(BUILD_TESTING ON)
115+
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/libyaml")
116+
set(BUILD_TESTING OFF)
117+
118+
# NOTE: Just include the file. Can't add subdirectory since it install stuff
119+
# add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/string-view-lite")
120+
add_library(string-view-lite INTERFACE)
121+
target_include_directories( string-view-lite INTERFACE
122+
"${CMAKE_CURRENT_LIST_DIR}/External/string-view-lite/include")
123+
91124
# Copy cfgpath.h
92125
configure_file( "${CMAKE_CURRENT_LIST_DIR}/External/cfgpath/cfgpath.h"
93126
"${CMAKE_CURRENT_LIST_DIR}/Include/cfgpath.h" COPYONLY)
94127

95-
96-
97128
if(RUNCPP2_BUILD_TESTS)
98129
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/ssTest")
99130
endif()
@@ -177,16 +208,17 @@ set(RUNCPP2_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/Profile.
177208
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/runcpp2.cpp"
178209
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/BuildsManager.cpp"
179210
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/PipelineSteps.cpp"
180-
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/IncludeManager.cpp")
211+
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/IncludeManager.cpp"
212+
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/LibYAML_Wrapper.cpp")
181213

182-
add_library(runcpp2 STATIC ${RUNCPP2_SOURCE_FILES})
214+
add_library(runcpp2Lib STATIC ${RUNCPP2_SOURCE_FILES})
183215

184216
set(RUNCPP2_PRIVATE_LINK_LIBS ssLogger System2 CppOverride dylib)
185-
set(RUNCPP2_PUBLIC_LINK_LIBS ghc_filesystem ryml::ryml mpark_variant MacroPowerToys)
217+
set(RUNCPP2_PUBLIC_LINK_LIBS ghc_filesystem ryml::ryml mpark_variant MacroPowerToys string-view-lite yaml DSResult)
186218

187-
target_include_directories(runcpp2 PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")
188-
target_link_libraries(runcpp2 PRIVATE ${RUNCPP2_PRIVATE_LINK_LIBS})
189-
target_link_libraries(runcpp2 PUBLIC ${RUNCPP2_PUBLIC_LINK_LIBS})
219+
target_include_directories(runcpp2Lib PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")
220+
target_link_libraries(runcpp2Lib PRIVATE ${RUNCPP2_PRIVATE_LINK_LIBS})
221+
target_link_libraries(runcpp2Lib PUBLIC ${RUNCPP2_PUBLIC_LINK_LIBS})
190222

191223
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
192224
# TODO: Try to change to /Wall
@@ -212,35 +244,35 @@ else()
212244
endif()
213245
endif()
214246

215-
target_compile_options(runcpp2 PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
247+
target_compile_options(runcpp2Lib PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
216248

217249
# 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})
250+
target_compile_definitions(runcpp2Lib PUBLIC RUNCPP2_VERSION="${RUNCPP2_PROJECT_VERSION}"
251+
RUNCPP2_CONFIG_VERSION=${RUNCPP2_CONFIG_VERSION})
220252

221253
# =========================================================================
222254
# runcpp2 executable
223255
# =========================================================================
224256

225-
add_executable(runcpp2_main "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/main.cpp")
226-
target_compile_options(runcpp2_main PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
227-
target_link_libraries(runcpp2_main PRIVATE runcpp2 ssLogger)
228-
set_target_properties(runcpp2_main PROPERTIES OUTPUT_NAME "runcpp2")
257+
add_executable(runcpp2 "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/main.cpp")
258+
target_compile_options(runcpp2 PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
259+
target_link_libraries(runcpp2 PUBLIC runcpp2Lib ssLogger)
229260

230261
# =========================================================================
231262
# runcpp2 library override
232263
# =========================================================================
233264

234-
add_library(runcpp2_override STATIC ${RUNCPP2_SOURCE_FILES})
235-
target_include_directories(runcpp2_override PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")
236-
target_link_libraries(runcpp2_override PRIVATE ${RUNCPP2_PRIVATE_LINK_LIBS})
237-
target_link_libraries(runcpp2_override PUBLIC ${RUNCPP2_PUBLIC_LINK_LIBS})
238-
target_compile_options(runcpp2_override PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
239-
target_compile_definitions(runcpp2_override PUBLIC RUNCPP2_VERSION="${RUNCPP2_PROJECT_VERSION}"
240-
RUNCPP2_CONFIG_VERSION=${RUNCPP2_CONFIG_VERSION}
241-
INTERNAL_RUNCPP2_UNIT_TESTS=1)
242265
if(RUNCPP2_BUILD_TESTS)
266+
add_library(runcpp2Override STATIC ${RUNCPP2_SOURCE_FILES})
267+
target_include_directories(runcpp2Override PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")
268+
target_link_libraries(runcpp2Override PRIVATE ${RUNCPP2_PRIVATE_LINK_LIBS})
269+
target_link_libraries(runcpp2Override PUBLIC ${RUNCPP2_PUBLIC_LINK_LIBS})
270+
target_compile_options(runcpp2Override PRIVATE "${RUNCPP2_STANDARD_COMPILE_FLAGS}")
271+
target_compile_definitions( runcpp2Override PUBLIC
272+
RUNCPP2_VERSION="${RUNCPP2_PROJECT_VERSION}"
273+
RUNCPP2_CONFIG_VERSION=${RUNCPP2_CONFIG_VERSION}
274+
INTERNAL_RUNCPP2_UNIT_TESTS=1)
243275
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Src/Tests")
244276
endif()
245277

246-
278+
# set(RUNCPP2_DISABLE_INSTALLATION OFF)

DefaultYAMLs/Default/g++.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Templates:
1313
CommandPart: " -I\"{IncludeDirectoryPath}\""
1414
- Type: Once
1515
CommandPart: " \"{InputFilePath}\" -o \"{OutputFileDirectory}{/}{ObjectLinkFile.Prefix}{InputFileName}{ObjectLinkFile.Extension}\""
16-
1716
"g++_CompileExpectedOutputFiles": &g++_CompileExpectedOutputFiles
1817
- "{OutputFileDirectory}{/}{ObjectLinkFile.Prefix}{InputFileName}{ObjectLinkFile.Extension}"
1918

External/DSResult

Submodule DSResult added at caf5b62

External/libyaml

Submodule libyaml added at 453b582

External/string-view-lite

Submodule string-view-lite added at d46fe4d

Include/Tests/ConfigParsing/MockComponents.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <sstream>
1111
#include <type_traits>
1212
#include <vector>
13+
#include <utility>
1314

1415
extern CO_DECLARE_INSTANCE(OverrideInstance);
1516

@@ -81,6 +82,12 @@ namespace Mock_std
8182
{
8283
return std::stoi(str, pos, base);
8384
}
85+
86+
template<class T>
87+
typename std::remove_reference<T>::type&& move( T&& t ) noexcept
88+
{
89+
return std::move(t);
90+
}
8491
}
8592

8693

Include/runcpp2/ConfigParsing.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ namespace runcpp2
2222

2323
bool ParseScriptInfo( const std::string& scriptInfo,
2424
Data::ScriptInfo& outScriptInfo);
25+
26+
bool ParseScriptInfo_LibYaml( const std::string& scriptInfo,
27+
Data::ScriptInfo& outScriptInfo);
2528
}
2629

2730
#endif

Include/runcpp2/Data/DependencyInfo.hpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,25 @@ namespace runcpp2
1616
{
1717
namespace Data
1818
{
19-
class DependencyInfo
19+
struct DependencyInfo
2020
{
21-
public:
22-
std::string Name;
23-
std::unordered_set<PlatformName> Platforms;
24-
DependencySource Source;
25-
DependencyLibraryType LibraryType;
26-
std::vector<std::string> IncludePaths;
27-
std::vector<std::string> AbsoluteIncludePaths;
28-
std::unordered_map<PlatformName, DependencyLinkProperty> LinkProperties;
29-
std::unordered_map<PlatformName, ProfilesCommands> Setup;
30-
std::unordered_map<PlatformName, ProfilesCommands> Cleanup;
31-
std::unordered_map<PlatformName, ProfilesCommands> Build;
32-
std::unordered_map<PlatformName, FilesToCopyInfo> FilesToCopy;
33-
34-
bool ParseYAML_Node(ryml::ConstNodeRef node);
35-
std::string ToString(std::string indentation) const;
36-
bool Equals(const DependencyInfo& other) const;
21+
std::string Name;
22+
std::unordered_set<PlatformName> Platforms;
23+
DependencySource Source;
24+
DependencyLibraryType LibraryType;
25+
std::vector<std::string> IncludePaths;
26+
std::vector<std::string> AbsoluteIncludePaths;
27+
std::unordered_map<PlatformName, DependencyLinkProperty> LinkProperties;
28+
std::unordered_map<PlatformName, ProfilesCommands> Setup;
29+
std::unordered_map<PlatformName, ProfilesCommands> Cleanup;
30+
std::unordered_map<PlatformName, ProfilesCommands> Build;
31+
std::unordered_map<PlatformName, FilesToCopyInfo> FilesToCopy;
32+
33+
bool ParseYAML_Node(ryml::ConstNodeRef node);
34+
bool ParseYAML_Node(YAML::ConstNodePtr node);
35+
36+
std::string ToString(std::string indentation) const;
37+
bool Equals(const DependencyInfo& other) const;
3738
};
3839
}
3940
}

Include/runcpp2/Data/DependencyLinkProperty.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ namespace runcpp2
2626
std::unordered_map<ProfileName, ProfileLinkProperty> ProfileProperties;
2727

2828
bool ParseYAML_Node(ryml::ConstNodeRef node);
29+
bool ParseYAML_Node(YAML::ConstNodePtr node);
30+
2931
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
3032
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
33+
34+
bool ParseYAML_NodeWithProfile_LibYaml(YAML::ConstNodePtr node, ProfileName profile);
35+
bool IsYAML_NodeParsableAsDefault_LibYaml(YAML::ConstNodePtr node) const;
36+
3137
std::string ToString(std::string indentation) const;
3238
bool Equals(const DependencyLinkProperty& other) const;
3339
};

0 commit comments

Comments
 (0)