Skip to content

Commit cd0ab97

Browse files
Improving user config & build process to be more flexible
1 parent cd69ea2 commit cd0ab97

File tree

14 files changed

+560
-350
lines changed

14 files changed

+560
-350
lines changed

DefaultYAMLs/DefaultUserConfig.yaml

Lines changed: 151 additions & 77 deletions
Large diffs are not rendered by default.

Include/runcpp2/CompilingLinking.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ namespace runcpp2
3535
const std::vector<Data::DependencyInfo*>& availableDependencies,
3636
const Data::Profile& profile,
3737
const std::vector<std::string>& compiledObjectsPaths,
38-
bool buildExecutable,
39-
const std::string exeExt);
38+
bool buildExecutable);
4039
}
4140

4241
#endif

Include/runcpp2/Data/BuildTypeHelper.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ namespace runcpp2
1212
{
1313
namespace BuildTypeHelper
1414
{
15-
const FileProperties* GetOutputFileProperties( const FilesTypesInfo& filesTypes,
16-
BuildType buildType,
17-
bool asExecutable);
18-
1915
bool NeedsLinking(BuildType buildType);
2016

21-
bool GetOutputPath( const ghc::filesystem::path& buildDir,
22-
const std::string& scriptName,
23-
const Profile& profile,
24-
const BuildType buildType,
25-
const bool asExecutable,
26-
ghc::filesystem::path& outPath);
17+
bool GetPossibleOutputPaths(const ghc::filesystem::path& buildDir,
18+
const std::string& scriptName,
19+
const Profile& profile,
20+
const BuildType buildType,
21+
const bool asExecutable,
22+
std::vector<ghc::filesystem::path>& outPaths,
23+
std::vector<bool>& outIsRunnable);
2724
}
2825
}
2926
}

Include/runcpp2/Data/StageInfo.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace runcpp2
4040
std::vector<std::string> Setup;
4141
std::vector<std::string> Cleanup;
4242
std::vector<RunPart> RunParts;
43+
std::vector<std::string> ExpectedOutputFiles;
4344
};
4445

4546
struct
@@ -52,6 +53,7 @@ namespace runcpp2
5253

5354
using SubstitutionMap = std::unordered_map<std::string, std::vector<std::string>>;
5455

56+
//TODO: Make this static function?
5557
bool PerformSubstituions( const SubstitutionMap& substitutionMap,
5658
std::string& inOutSubstitutedString) const;
5759

Include/runcpp2/PipelineSteps.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,21 @@ namespace runcpp2
102102
int& returnStatus);
103103

104104
PipelineResult
105-
HandleBuildOutput( const ghc::filesystem::path& target,
105+
HandleBuildOutput( const std::vector<ghc::filesystem::path>& targets,
106106
const std::vector<std::string>& filesToCopyPaths,
107107
const Data::ScriptInfo& scriptInfo,
108108
const Data::Profile& profile,
109109
const std::string& buildOutputDir,
110110
const std::unordered_map<CmdOptions, std::string>& currentOptions);
111111

112-
PipelineResult GetTargetPath( const ghc::filesystem::path& buildDir,
113-
const std::string& scriptName,
114-
const Data::Profile& profile,
115-
const std::unordered_map<CmdOptions, std::string>& currentOptions,
116-
const Data::ScriptInfo& scriptInfo,
117-
ghc::filesystem::path& outTarget);
112+
PipelineResult GetBuiltTargetPaths( const ghc::filesystem::path& buildDir,
113+
const std::string& scriptName,
114+
const Data::Profile& profile,
115+
const std::unordered_map< CmdOptions,
116+
std::string>& currentOptions,
117+
const Data::ScriptInfo& scriptInfo,
118+
std::vector<ghc::filesystem::path>& outTargets,
119+
ghc::filesystem::path* outRunnableTarget);
118120

119121
bool GatherSourceFiles( const ghc::filesystem::path& absoluteScriptPath,
120122
const Data::ScriptInfo& scriptInfo,

Jenkinsfile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,21 @@ pipeline
254254
bash "cd ./Build && ./runcpp2 -l " +
255255
"-c ../DefaultYAMLs/DefaultUserConfig.yaml " +
256256
"--log-level info ../Examples/test.cpp"
257-
}
258-
{
257+
bash "cd ./Build && ./runcpp2 -l -b " +
258+
"-c ../DefaultYAMLs/DefaultUserConfig.yaml " +
259+
"--log-level info ../Examples/test.cpp"
260+
bash "ls -lah ./Build"
261+
262+
259263
cleanWs()
260264
bash "ls -lah"
261265
unstash 'linux_build'
262266
bash "ls -lah"
263267
bash "ls -lah ./Build/Src/Tests"
264-
bash "cd ./Build && ./runcpp2 -l -b" +
268+
bash "cd ./Build && ./runcpp2 -l -b " +
265269
"-c ../DefaultYAMLs/DefaultUserConfig.yaml " +
266270
"--log-level info ../Examples/test_static.cpp"
271+
bash "ls -lah ./Build"
267272
}
268273
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
269274
}
@@ -295,15 +300,20 @@ pipeline
295300
bat "cd .\\Build\\Debug && .\\runcpp2.exe -l " +
296301
"-c ..\\..\\DefaultYAMLs\\DefaultUserConfig.yaml " +
297302
"--log-level info ..\\..\\Examples\\test.cpp"
298-
}
299-
{
303+
bat "cd .\\Build\\Debug && .\\runcpp2.exe -l -b " +
304+
"-c ..\\..\\DefaultYAMLs\\DefaultUserConfig.yaml " +
305+
"--log-level info ..\\..\\Examples\\test.cpp"
306+
bat "dir .\\Build\\Debug"
307+
308+
300309
cleanWs()
301310
bat 'dir'
302311
unstash 'windows_build'
303312
bat 'dir'
304-
bat "cd .\\Build\\Debug && .\\runcpp2.exe -l -b" +
313+
bat "cd .\\Build\\Debug && .\\runcpp2.exe -l -b " +
305314
"-c ..\\..\\DefaultYAMLs\\DefaultUserConfig.yaml " +
306315
"--log-level info ..\\..\\Examples\\test_static.cpp"
316+
bat "dir .\\Build\\Debug"
307317
}
308318
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
309319
}

Src/Tests/Data/BuildTypeTest.cpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,33 +66,26 @@ int main(int argc, char** argv)
6666

6767
ssTEST_OUTPUT_EXECUTION
6868
(
69-
ghc::filesystem::path outPath;
70-
bool result = runcpp2::Data::BuildTypeHelper::GetOutputPath(
71-
buildDir, scriptName, profile, runcpp2::Data::BuildType::STATIC, false, outPath);
69+
std::vector<ghc::filesystem::path> outTargets;
70+
std::vector<bool> outIsRunnable;
71+
bool result = BuildTypeHelper::GetPossibleOutputPaths( buildDir,
72+
scriptName,
73+
profile,
74+
BuildType::STATIC,
75+
false,
76+
outTargets,
77+
outIsRunnable);
7278
);
7379

7480
ssTEST_OUTPUT_ASSERT("GetOutputPath should succeed", result == true);
81+
ssTEST_OUTPUT_ASSERT("GetOutputPath should return a single target", outTargets.size() == 1);
7582
#ifdef _WIN32
76-
ssTEST_OUTPUT_ASSERT("Static library path", outPath, "build/test.lib");
83+
ssTEST_OUTPUT_ASSERT("Static library path", outTargets.at(0), "build/test.lib");
7784
#else
78-
ssTEST_OUTPUT_ASSERT("Static library path", outPath, "build/libtest.a");
85+
ssTEST_OUTPUT_ASSERT("Static library path", outTargets.at(0), "build/libtest.a");
7986
#endif
8087
};
8188

82-
ssTEST("BuildType Should Map To Correct File Types")
83-
{
84-
ssTEST_OUTPUT_SETUP
85-
(
86-
runcpp2::Data::FilesTypesInfo filesTypes;
87-
);
88-
89-
ssTEST_OUTPUT_ASSERT( "Static build type",
90-
BuildTypeHelper::GetOutputFileProperties( filesTypes,
91-
BuildType::STATIC,
92-
false),
93-
&filesTypes.StaticLinkFile);
94-
};
95-
9689
ssTEST_END_TEST_GROUP();
9790
return 0;
9891
}

Src/Tests/Data/ProfileTest.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ int main(int argc, char** argv)
99

1010
ssTEST_INIT_TEST_GROUP();
1111

12+
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
1213
ssTEST("Profile Should Parse Valid YAML")
1314
{
1415
const char* yamlStr = R"(
@@ -69,6 +70,7 @@ int main(int argc, char** argv)
6970
CommandPart: " -I\"{IncludeDirectoryPath}\""
7071
- Type: Once
7172
CommandPart: " \"{InputFilePath}\" -o \"{OutputFilePath}\""
73+
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
7274
ExecutableShared:
7375
DefaultPlatform:
7476
Flags: "-std=c++17 -Wall -g -fpic"
@@ -80,20 +82,23 @@ int main(int argc, char** argv)
8082
CommandPart: " -I\"{IncludeDirectoryPath}\""
8183
- Type: Once
8284
CommandPart: " \"{InputFilePath}\" -o \"{OutputFilePath}\""
85+
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
8386
Static:
8487
DefaultPlatform:
8588
Flags: "-std=c++17 -Wall -g"
8689
Executable: "g++"
8790
RunParts:
8891
- Type: Once
8992
CommandPart: "{Executable} -c {CompileFlags}"
93+
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
9094
Shared:
9195
DefaultPlatform:
9296
Flags: "-std=c++17 -Wall -g -fpic"
9397
Executable: "g++"
9498
RunParts:
9599
- Type: Once
96100
CommandPart: "{Executable} -c {CompileFlags}"
101+
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
97102
Linker:
98103
PreRun:
99104
DefaultPlatform: ""
@@ -107,33 +112,38 @@ int main(int argc, char** argv)
107112
RunParts:
108113
- Type: Once
109114
CommandPart: "{Executable} {LinkFlags} -o \"{OutputFilePath}\""
115+
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
110116
Windows:
111117
Flags: "-Wl,-rpath,\\$ORIGIN"
112118
Executable: "g++"
113119
RunParts:
114120
- Type: Once
115121
CommandPart: "{Executable} {LinkFlags} -o \"{OutputFilePath}\""
122+
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
116123
Static:
117124
DefaultPlatform:
118125
Flags: ""
119126
Executable: "g++"
120127
RunParts:
121128
- Type: Once
122129
CommandPart: "{Executable} {LinkFlags} -o \"{OutputFilePath}\""
130+
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
123131
Shared:
124132
Unix:
125133
Flags: "-shared -Wl,-rpath,\\$ORIGIN"
126134
Executable: "g++"
127135
RunParts:
128136
- Type: Once
129137
CommandPart: "{Executable} {LinkFlags} -o \"{OutputFilePath}\""
138+
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
130139
ExecutableShared:
131140
Unix:
132141
Flags: "-shared -Wl,-rpath,\\$ORIGIN"
133142
Executable: "g++"
134143
RunParts:
135144
- Type: Once
136145
CommandPart: "{Executable} {LinkFlags} -o \"{OutputFilePath}\""
146+
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
137147
)";
138148

139149
ssTEST_OUTPUT_SETUP
@@ -208,11 +218,17 @@ int main(int argc, char** argv)
208218
const auto& executableCompile = profile.Compiler.OutputTypes.Executable.at("DefaultPlatform");
209219
);
210220
ssTEST_OUTPUT_ASSERT( "Compiler Executable flags",
211-
executableCompile.Flags == "-std=c++17 -Wall -g");
221+
executableCompile.Flags,
222+
"-std=c++17 -Wall -g");
212223
ssTEST_OUTPUT_ASSERT( "Compiler Executable executable",
213-
executableCompile.Executable == "g++");
224+
executableCompile.Executable,
225+
"g++");
214226
ssTEST_OUTPUT_ASSERT( "Compiler Executable RunParts size",
215-
executableCompile.RunParts.size() == 3);
227+
executableCompile.RunParts.size(),
228+
3);
229+
ssTEST_OUTPUT_ASSERT( "Compiler Executable ExpectedOutputFiles size",
230+
executableCompile.ExpectedOutputFiles.size(),
231+
2);
216232

217233
//Verify Compiler ExecutableShared
218234
ssTEST_OUTPUT_SETUP
@@ -229,6 +245,9 @@ int main(int argc, char** argv)
229245
ssTEST_OUTPUT_ASSERT( "Compiler ExecutableShared RunParts size",
230246
executableSharedCompile.RunParts.size(),
231247
3);
248+
ssTEST_OUTPUT_ASSERT( "Compiler ExecutableShared ExpectedOutputFiles size",
249+
executableSharedCompile.ExpectedOutputFiles.size(),
250+
2);
232251

233252
//Verify Linker
234253
ssTEST_OUTPUT_ASSERT( "Linker CheckExistence DefaultPlatform",
@@ -243,6 +262,9 @@ int main(int argc, char** argv)
243262
executableLink.Executable == "g++");
244263
ssTEST_OUTPUT_ASSERT( "Linker Executable RunParts size",
245264
executableLink.RunParts.size() == 1);
265+
ssTEST_OUTPUT_ASSERT( "Linker Executable ExpectedOutputFiles size",
266+
executableLink.ExpectedOutputFiles.size(),
267+
2);
246268

247269
//Verify Linker ExecutableShared
248270
ssTEST_OUTPUT_SETUP
@@ -259,6 +281,9 @@ int main(int argc, char** argv)
259281
ssTEST_OUTPUT_ASSERT( "Linker ExecutableShared RunParts size",
260282
executableSharedLink.RunParts.size(),
261283
1);
284+
ssTEST_OUTPUT_ASSERT( "Linker ExecutableShared ExpectedOutputFiles size",
285+
executableSharedLink.ExpectedOutputFiles.size(),
286+
2);
262287

263288
//Test ToString() and Equals()
264289
ssTEST_OUTPUT_EXECUTION

0 commit comments

Comments
 (0)