Skip to content

Commit f25475e

Browse files
Merge pull request #32 from Neko-Box-Coder/IncludePaths
Include paths
2 parents d9caed3 + 4e09beb commit f25475e

17 files changed

+341
-143
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ add_library(runcpp2 STATIC
129129
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesCommands.cpp"
130130
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesFlagsOverride.cpp"
131131
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ScriptInfo.cpp"
132-
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesCompilesFiles.cpp"
132+
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesProcessPaths.cpp"
133133
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FilesTypesInfo.cpp"
134134
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/StageInfo.cpp"
135135
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesDefines.cpp"

DefaultYAMLs/DefaultScriptInfo.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,22 @@ OtherFilesToBeCompiled:
5757
DefaultProfile:
5858
- "./AnotherSourceFile.cpp"
5959

60+
# (Optional) Include paths (relative to script file path) for each platform and profile
61+
IncludePaths:
62+
# Target Platform (DefaultPlatform, Windows, Linux, MacOS, or Unix)
63+
DefaultPlatform:
64+
# Target Profile (e.g., "g++", "clang++", "msvc", or "DefaultProfile" for any profile)
65+
DefaultProfile:
66+
- "./include"
67+
- "./src/include"
68+
6069
# (Optional) Define cross-compiler defines for each platform and profile.
6170
# Defines can be specified as just a name or as a name-value pair.
6271
Defines:
6372
# Target Platform (DefaultPlatform, Windows, Linux, MacOS, or Unix)
6473
DefaultPlatform:
6574
# Profile name (e.g., "g++", "clang++", "msvc", or "DefaultProfile" for any profile)
66-
"DefaultProfile":
75+
DefaultProfile:
6776
- "EXAMPLE_DEFINE" # Define without a value
6877
- "VERSION_MAJOR=1" # Define with a value
6978

Examples/test.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ PassScriptPath: true
1717
"msvc":
1818
- "./OtherSources/AnotherSourceFileMSVC.cpp"
1919
20+
IncludePaths:
21+
DefaultPlatform:
22+
DefaultProfile:
23+
- "./OtherSources"
24+
2025
Defines:
2126
DefaultPlatform:
2227
# Turns into `TEST_DEF=\"Test Define Working\"` in shell
@@ -104,11 +109,11 @@ PassScriptPath: true
104109
#include "System2.hpp"
105110

106111
#if defined(__GNUC__)
107-
#include "./OtherSources/AnotherSourceFileGcc.hpp"
112+
#include "AnotherSourceFileGcc.hpp"
108113
#endif
109114

110115
#if defined(_MSC_VER)
111-
#include "./OtherSources/AnotherSourceFileMSVC.hpp"
116+
#include "AnotherSourceFileMSVC.hpp"
112117
#endif
113118

114119
#include <iostream>

Include/runcpp2/CompilingLinking.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace runcpp2
1414
const ghc::filesystem::path& scriptPath,
1515
const std::vector<ghc::filesystem::path>& sourceFiles,
1616
const std::vector<bool>& sourceHasCache,
17+
const std::vector<ghc::filesystem::path>& includePaths,
1718
const Data::ScriptInfo& scriptInfo,
1819
const std::vector<Data::DependencyInfo*>& availableDependencies,
1920
const Data::Profile& profile,
@@ -25,6 +26,7 @@ namespace runcpp2
2526
const std::string& outputName,
2627
const std::vector<ghc::filesystem::path>& sourceFiles,
2728
const std::vector<bool>& sourceHasCache,
29+
const std::vector<ghc::filesystem::path>& includePaths,
2830
const Data::ScriptInfo& scriptInfo,
2931
const std::vector<Data::DependencyInfo*>& availableDependencies,
3032
const Data::Profile& profile,

Include/runcpp2/Data/ProfilesCompilesFiles.hpp renamed to Include/runcpp2/Data/ProfilesProcessPaths.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef RUNCPP2_DATA_PROFILES_COMPILES_FILES_HPP
2-
#define RUNCPP2_DATA_PROFILES_COMPILES_FILES_HPP
1+
#ifndef RUNCPP2_DATA_PROFILES_PROCESS_PATHS_HPP
2+
#define RUNCPP2_DATA_PROFILES_PROCESS_PATHS_HPP
33

44
#include "runcpp2/Data/ParseCommon.hpp"
55

@@ -14,14 +14,14 @@ namespace runcpp2
1414
{
1515
namespace Data
1616
{
17-
class ProfilesCompilesFiles
17+
class ProfilesProcessPaths
1818
{
1919
public:
20-
std::unordered_map<ProfileName, std::vector<ghc::filesystem::path>> CompilesFiles;
20+
std::unordered_map<ProfileName, std::vector<ghc::filesystem::path>> Paths;
2121

2222
bool ParseYAML_Node(ryml::ConstNodeRef& node);
2323
std::string ToString(std::string indentation) const;
24-
bool Equals(const ProfilesCompilesFiles& other) const;
24+
bool Equals(const ProfilesProcessPaths& other) const;
2525
};
2626
}
2727
}

Include/runcpp2/Data/ScriptInfo.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "runcpp2/Data/DependencyInfo.hpp"
55
#include "runcpp2/Data/ProfilesFlagsOverride.hpp"
66
#include "runcpp2/Data/ParseCommon.hpp"
7-
#include "runcpp2/Data/ProfilesCompilesFiles.hpp"
7+
#include "runcpp2/Data/ProfilesProcessPaths.hpp"
88
#include "runcpp2/Data/ProfilesDefines.hpp"
99
#include "runcpp2/Data/ProfilesCommands.hpp"
1010

@@ -26,7 +26,8 @@ namespace runcpp2
2626
std::unordered_map<PlatformName, ProfilesFlagsOverride> OverrideCompileFlags;
2727
std::unordered_map<PlatformName, ProfilesFlagsOverride> OverrideLinkFlags;
2828

29-
std::unordered_map<PlatformName, ProfilesCompilesFiles> OtherFilesToBeCompiled;
29+
std::unordered_map<PlatformName, ProfilesProcessPaths> OtherFilesToBeCompiled;
30+
std::unordered_map<PlatformName, ProfilesProcessPaths> IncludePaths;
3031

3132
std::vector<DependencyInfo> Dependencies;
3233

Include/runcpp2/PipelineSteps.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ namespace runcpp2
105105
const Data::Profile& profile,
106106
const std::unordered_map<CmdOptions, std::string>& currentOptions,
107107
ghc::filesystem::path& outTarget);
108+
109+
bool GatherSourceFiles( const ghc::filesystem::path& absoluteScriptPath,
110+
const Data::ScriptInfo& scriptInfo,
111+
const Data::Profile& currentProfile,
112+
std::vector<ghc::filesystem::path>& outSourcePaths);
113+
114+
bool GatherIncludePaths(const ghc::filesystem::path& scriptDirectory,
115+
const Data::ScriptInfo& scriptInfo,
116+
const Data::Profile& currentProfile,
117+
const std::vector<Data::DependencyInfo*>& dependencies,
118+
std::vector<ghc::filesystem::path>& outIncludePaths);
108119
}
109120

110121

Src/Tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ create_data_test(FlagsOverrideInfoTest)
2323
create_data_test(DependencySourceTest)
2424
create_data_test(FilesToCopyInfoTest)
2525
create_data_test(ProfilesCommandsTest)
26-
create_data_test(ProfilesCompilesFilesTest)
26+
create_data_test(ProfilesProcessPathsTest)
2727
create_data_test(ProfilesDefinesTest)
2828
create_data_test(DependencyLinkPropertyTest)
2929
create_data_test(FilesTypesInfoTest)

Src/Tests/Data/ProfilesCompilesFilesTest.cpp renamed to Src/Tests/Data/ProfilesProcessPathsTest.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "runcpp2/Data/ProfilesCompilesFiles.hpp"
1+
#include "runcpp2/Data/ProfilesProcessPaths.hpp"
22
#include "ssTest.hpp"
33
#include "runcpp2/YamlLib.hpp"
44
#include "runcpp2/runcpp2.hpp"
@@ -9,7 +9,7 @@ int main(int argc, char** argv)
99

1010
ssTEST_INIT_TEST_GROUP();
1111

12-
ssTEST("ProfilesCompilesFiles Should Parse Valid YAML")
12+
ssTEST("ProfilesProcessPaths Should Parse Valid YAML")
1313
{
1414
ssTEST_OUTPUT_SETUP
1515
(
@@ -25,42 +25,42 @@ int main(int argc, char** argv)
2525
ryml::Tree tree = ryml::parse_in_arena(c4::to_csubstr(yamlStr));
2626
ryml::ConstNodeRef root = tree.rootref();
2727

28-
runcpp2::Data::ProfilesCompilesFiles profilesCompilesFiles;
28+
runcpp2::Data::ProfilesProcessPaths profilesProcessPaths;
2929
);
3030

3131
ssTEST_OUTPUT_EXECUTION
3232
(
3333
ryml::ConstNodeRef nodeRef = root;
34-
bool parseResult = profilesCompilesFiles.ParseYAML_Node(nodeRef);
34+
bool parseResult = profilesProcessPaths.ParseYAML_Node(nodeRef);
3535
);
3636

3737
ssTEST_OUTPUT_ASSERT("ParseYAML_Node should succeed", parseResult);
3838

3939
//Verify parsed values
4040
ssTEST_OUTPUT_ASSERT( "MSVC files count",
41-
profilesCompilesFiles.CompilesFiles.at("MSVC").size() == 2);
41+
profilesProcessPaths.Paths.at("MSVC").size() == 2);
4242
ssTEST_OUTPUT_ASSERT( "GCC files count",
43-
profilesCompilesFiles.CompilesFiles.at("GCC").size() == 2);
43+
profilesProcessPaths.Paths.at("GCC").size() == 2);
4444
ssTEST_OUTPUT_ASSERT( "MSVC first file",
45-
profilesCompilesFiles.CompilesFiles.at("MSVC").at(0) ==
45+
profilesProcessPaths.Paths.at("MSVC").at(0) ==
4646
"src/main.cpp");
4747
ssTEST_OUTPUT_ASSERT( "GCC last file",
48-
profilesCompilesFiles.CompilesFiles.at("GCC").at(1) ==
48+
profilesProcessPaths.Paths.at("GCC").at(1) ==
4949
"src/optimized.cpp");
5050

5151
//Test ToString() and Equals()
5252
ssTEST_OUTPUT_EXECUTION
5353
(
54-
std::string yamlOutput = profilesCompilesFiles.ToString("");
54+
std::string yamlOutput = profilesProcessPaths.ToString("");
5555
ryml::Tree outputTree = ryml::parse_in_arena(ryml::to_csubstr(yamlOutput));
5656

57-
runcpp2::Data::ProfilesCompilesFiles parsedOutput;
57+
runcpp2::Data::ProfilesProcessPaths parsedOutput;
5858
nodeRef = outputTree.rootref();
5959
parsedOutput.ParseYAML_Node(nodeRef);
6060
);
6161

6262
ssTEST_OUTPUT_ASSERT( "Parsed output should equal original",
63-
profilesCompilesFiles.Equals(parsedOutput));
63+
profilesProcessPaths.Equals(parsedOutput));
6464
};
6565

6666
ssTEST_END_TEST_GROUP();

Src/Tests/Data/ScriptInfoTest.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ int main(int argc, char** argv)
3737
MSVC:
3838
- src/extra.cpp
3939
- src/debug.cpp
40+
IncludePaths:
41+
Windows:
42+
MSVC:
43+
- include
4044
Defines:
4145
Windows:
4246
MSVC:
@@ -152,12 +156,21 @@ int main(int argc, char** argv)
152156
//Verify OtherFilesToBeCompiled
153157
ssTEST_OUTPUT_SETUP
154158
(
155-
const std::vector<ghc::filesystem::path>& msvcFiles =
156-
scriptInfo.OtherFilesToBeCompiled.at("Windows").CompilesFiles.at("MSVC");
159+
const std::vector<ghc::filesystem::path>& msvcCompileFiles =
160+
scriptInfo.OtherFilesToBeCompiled.at("Windows").Paths.at("MSVC");
157161
);
158-
ssTEST_OUTPUT_ASSERT("MSVC files count", msvcFiles.size() == 2);
159-
ssTEST_OUTPUT_ASSERT("MSVC first file", msvcFiles.at(0) == "src/extra.cpp");
162+
ssTEST_OUTPUT_ASSERT("MSVC files count", msvcCompileFiles.size() == 2);
163+
ssTEST_OUTPUT_ASSERT("MSVC first file", msvcCompileFiles.at(0) == "src/extra.cpp");
160164

165+
//Verify IncludePaths
166+
ssTEST_OUTPUT_SETUP
167+
(
168+
const std::vector<ghc::filesystem::path>& msvcIncludeFiles =
169+
scriptInfo.IncludePaths.at("Windows").Paths.at("MSVC");
170+
);
171+
ssTEST_OUTPUT_ASSERT("IncludePaths count", msvcIncludeFiles.size() == 1);
172+
ssTEST_OUTPUT_ASSERT("IncludePaths first path", msvcIncludeFiles.at(0) == "include");
173+
161174
//Verify Defines
162175
ssTEST_OUTPUT_SETUP
163176
(

0 commit comments

Comments
 (0)