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
216 changes: 153 additions & 63 deletions DefaultYAMLs/DefaultUserConfig.yaml

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions Include/runcpp2/CompilingLinking.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ namespace runcpp2
const std::vector<Data::DependencyInfo*>& availableDependencies,
const Data::Profile& profile,
const std::vector<std::string>& compiledObjectsPaths,
bool buildExecutable,
const std::string exeExt);
bool buildExecutable);
}

#endif
17 changes: 7 additions & 10 deletions Include/runcpp2/Data/BuildTypeHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ namespace runcpp2
{
namespace BuildTypeHelper
{
const FileProperties* GetOutputFileProperties( const FilesTypesInfo& filesTypes,
BuildType buildType,
bool asExecutable);

bool NeedsLinking(BuildType buildType);

bool GetOutputPath( const ghc::filesystem::path& buildDir,
const std::string& scriptName,
const Profile& profile,
const BuildType buildType,
const bool asExecutable,
ghc::filesystem::path& outPath);
bool GetPossibleOutputPaths(const ghc::filesystem::path& buildDir,
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
2 changes: 2 additions & 0 deletions Include/runcpp2/Data/StageInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace runcpp2
std::vector<std::string> Setup;
std::vector<std::string> Cleanup;
std::vector<RunPart> RunParts;
std::vector<std::string> ExpectedOutputFiles;
};

struct
Expand All @@ -52,6 +53,7 @@ namespace runcpp2

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

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

Expand Down
16 changes: 9 additions & 7 deletions Include/runcpp2/PipelineSteps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,21 @@ namespace runcpp2
int& returnStatus);

PipelineResult
HandleBuildOutput( const ghc::filesystem::path& target,
HandleBuildOutput( const std::vector<ghc::filesystem::path>& targets,
const std::vector<std::string>& filesToCopyPaths,
const Data::ScriptInfo& scriptInfo,
const Data::Profile& profile,
const std::string& buildOutputDir,
const std::unordered_map<CmdOptions, std::string>& currentOptions);

PipelineResult GetTargetPath( const ghc::filesystem::path& buildDir,
const std::string& scriptName,
const Data::Profile& profile,
const std::unordered_map<CmdOptions, std::string>& currentOptions,
const Data::ScriptInfo& scriptInfo,
ghc::filesystem::path& outTarget);
PipelineResult GetBuiltTargetPaths( const ghc::filesystem::path& buildDir,
const std::string& scriptName,
const Data::Profile& profile,
const std::unordered_map< CmdOptions,
std::string>& currentOptions,
const Data::ScriptInfo& scriptInfo,
std::vector<ghc::filesystem::path>& outTargets,
ghc::filesystem::path* outRunnableTarget);

bool GatherSourceFiles( const ghc::filesystem::path& absoluteScriptPath,
const Data::ScriptInfo& scriptInfo,
Expand Down
22 changes: 16 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,21 @@ pipeline
bash "cd ./Build && ./runcpp2 -l " +
"-c ../DefaultYAMLs/DefaultUserConfig.yaml " +
"--log-level info ../Examples/test.cpp"
}
{
bash "cd ./Build && ./runcpp2 -l -b " +
"-c ../DefaultYAMLs/DefaultUserConfig.yaml " +
"--log-level info ../Examples/test.cpp"
bash "ls -lah ./Build"


cleanWs()
bash "ls -lah"
unstash 'linux_build'
bash "ls -lah"
bash "ls -lah ./Build/Src/Tests"
bash "cd ./Build && ./runcpp2 -l -b" +
bash "cd ./Build && ./runcpp2 -l -b " +
"-c ../DefaultYAMLs/DefaultUserConfig.yaml " +
"--log-level info ../Examples/test_static.cpp"
bash "ls -lah ./Build"
}
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
}
Expand Down Expand Up @@ -295,15 +300,20 @@ pipeline
bat "cd .\\Build\\Debug && .\\runcpp2.exe -l " +
"-c ..\\..\\DefaultYAMLs\\DefaultUserConfig.yaml " +
"--log-level info ..\\..\\Examples\\test.cpp"
}
{
bat "cd .\\Build\\Debug && .\\runcpp2.exe -l -b " +
"-c ..\\..\\DefaultYAMLs\\DefaultUserConfig.yaml " +
"--log-level info ..\\..\\Examples\\test.cpp"
bat "dir .\\Build\\Debug"


cleanWs()
bat 'dir'
unstash 'windows_build'
bat 'dir'
bat "cd .\\Build\\Debug && .\\runcpp2.exe -l -b" +
bat "cd .\\Build\\Debug && .\\runcpp2.exe -l -b " +
"-c ..\\..\\DefaultYAMLs\\DefaultUserConfig.yaml " +
"--log-level info ..\\..\\Examples\\test_static.cpp"
bat "dir .\\Build\\Debug"
}
post { failure { script { FAILED_STAGE = env.STAGE_NAME } } }
}
Expand Down
31 changes: 12 additions & 19 deletions Src/Tests/Data/BuildTypeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,26 @@ int main(int argc, char** argv)

ssTEST_OUTPUT_EXECUTION
(
ghc::filesystem::path outPath;
bool result = runcpp2::Data::BuildTypeHelper::GetOutputPath(
buildDir, scriptName, profile, runcpp2::Data::BuildType::STATIC, false, outPath);
std::vector<ghc::filesystem::path> outTargets;
std::vector<bool> outIsRunnable;
bool result = BuildTypeHelper::GetPossibleOutputPaths( buildDir,
scriptName,
profile,
BuildType::STATIC,
false,
outTargets,
outIsRunnable);
);

ssTEST_OUTPUT_ASSERT("GetOutputPath should succeed", result == true);
ssTEST_OUTPUT_ASSERT("GetOutputPath should return a single target", outTargets.size() == 1);
#ifdef _WIN32
ssTEST_OUTPUT_ASSERT("Static library path", outPath, "build/test.lib");
ssTEST_OUTPUT_ASSERT("Static library path", outTargets.at(0), "build/test.lib");
#else
ssTEST_OUTPUT_ASSERT("Static library path", outPath, "build/libtest.a");
ssTEST_OUTPUT_ASSERT("Static library path", outTargets.at(0), "build/libtest.a");
#endif
};

ssTEST("BuildType Should Map To Correct File Types")
{
ssTEST_OUTPUT_SETUP
(
runcpp2::Data::FilesTypesInfo filesTypes;
);

ssTEST_OUTPUT_ASSERT( "Static build type",
BuildTypeHelper::GetOutputFileProperties( filesTypes,
BuildType::STATIC,
false),
&filesTypes.StaticLinkFile);
};

ssTEST_END_TEST_GROUP();
return 0;
}
1 change: 1 addition & 0 deletions Src/Tests/Data/DependencyInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
Name: MyLibrary
Platforms:
Expand Down
1 change: 1 addition & 0 deletions Src/Tests/Data/DependencyLinkPropertyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
MSVC:
SearchLibraryNames: [mylib, mylib_static]
Expand Down
2 changes: 2 additions & 0 deletions Src/Tests/Data/DependencySourceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
Git:
URL: https://github.com/user/repo.git
Expand Down Expand Up @@ -57,6 +58,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
Local:
Path: ../external/mylib
Expand Down
1 change: 1 addition & 0 deletions Src/Tests/Data/FilePropertiesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
Prefix:
Windows: lib
Expand Down
1 change: 1 addition & 0 deletions Src/Tests/Data/FilesToCopyInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
MSVC:
- bin/Debug/mylib.dll
Expand Down
1 change: 1 addition & 0 deletions Src/Tests/Data/FilesTypesInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
ObjectLinkFile:
Prefix:
Expand Down
1 change: 1 addition & 0 deletions Src/Tests/Data/FlagsOverrideInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
Remove: -Wall
Append: -O3
Expand Down
31 changes: 28 additions & 3 deletions Src/Tests/Data/ProfileTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ int main(int argc, char** argv)

ssTEST("Profile Should Parse Valid YAML")
{
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
Name: "g++"
NameAliases: ["mingw"]
Expand Down Expand Up @@ -69,6 +70,7 @@ int main(int argc, char** argv)
CommandPart: " -I\"{IncludeDirectoryPath}\""
- Type: Once
CommandPart: " \"{InputFilePath}\" -o \"{OutputFilePath}\""
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
ExecutableShared:
DefaultPlatform:
Flags: "-std=c++17 -Wall -g -fpic"
Expand All @@ -80,20 +82,23 @@ int main(int argc, char** argv)
CommandPart: " -I\"{IncludeDirectoryPath}\""
- Type: Once
CommandPart: " \"{InputFilePath}\" -o \"{OutputFilePath}\""
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
Static:
DefaultPlatform:
Flags: "-std=c++17 -Wall -g"
Executable: "g++"
RunParts:
- Type: Once
CommandPart: "{Executable} -c {CompileFlags}"
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
Shared:
DefaultPlatform:
Flags: "-std=c++17 -Wall -g -fpic"
Executable: "g++"
RunParts:
- Type: Once
CommandPart: "{Executable} -c {CompileFlags}"
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
Linker:
PreRun:
DefaultPlatform: ""
Expand All @@ -107,33 +112,38 @@ int main(int argc, char** argv)
RunParts:
- Type: Once
CommandPart: "{Executable} {LinkFlags} -o \"{OutputFilePath}\""
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
Windows:
Flags: "-Wl,-rpath,\\$ORIGIN"
Executable: "g++"
RunParts:
- Type: Once
CommandPart: "{Executable} {LinkFlags} -o \"{OutputFilePath}\""
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
Static:
DefaultPlatform:
Flags: ""
Executable: "g++"
RunParts:
- Type: Once
CommandPart: "{Executable} {LinkFlags} -o \"{OutputFilePath}\""
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
Shared:
Unix:
Flags: "-shared -Wl,-rpath,\\$ORIGIN"
Executable: "g++"
RunParts:
- Type: Once
CommandPart: "{Executable} {LinkFlags} -o \"{OutputFilePath}\""
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
ExecutableShared:
Unix:
Flags: "-shared -Wl,-rpath,\\$ORIGIN"
Executable: "g++"
RunParts:
- Type: Once
CommandPart: "{Executable} {LinkFlags} -o \"{OutputFilePath}\""
ExpectedOutputFiles: ["TestOutputFile", "TestOutputFile2"]
)";

ssTEST_OUTPUT_SETUP
Expand Down Expand Up @@ -208,11 +218,17 @@ int main(int argc, char** argv)
const auto& executableCompile = profile.Compiler.OutputTypes.Executable.at("DefaultPlatform");
);
ssTEST_OUTPUT_ASSERT( "Compiler Executable flags",
executableCompile.Flags == "-std=c++17 -Wall -g");
executableCompile.Flags,
"-std=c++17 -Wall -g");
ssTEST_OUTPUT_ASSERT( "Compiler Executable executable",
executableCompile.Executable == "g++");
executableCompile.Executable,
"g++");
ssTEST_OUTPUT_ASSERT( "Compiler Executable RunParts size",
executableCompile.RunParts.size() == 3);
executableCompile.RunParts.size(),
3);
ssTEST_OUTPUT_ASSERT( "Compiler Executable ExpectedOutputFiles size",
executableCompile.ExpectedOutputFiles.size(),
2);

//Verify Compiler ExecutableShared
ssTEST_OUTPUT_SETUP
Expand All @@ -229,6 +245,9 @@ int main(int argc, char** argv)
ssTEST_OUTPUT_ASSERT( "Compiler ExecutableShared RunParts size",
executableSharedCompile.RunParts.size(),
3);
ssTEST_OUTPUT_ASSERT( "Compiler ExecutableShared ExpectedOutputFiles size",
executableSharedCompile.ExpectedOutputFiles.size(),
2);

//Verify Linker
ssTEST_OUTPUT_ASSERT( "Linker CheckExistence DefaultPlatform",
Expand All @@ -243,6 +262,9 @@ int main(int argc, char** argv)
executableLink.Executable == "g++");
ssTEST_OUTPUT_ASSERT( "Linker Executable RunParts size",
executableLink.RunParts.size() == 1);
ssTEST_OUTPUT_ASSERT( "Linker Executable ExpectedOutputFiles size",
executableLink.ExpectedOutputFiles.size(),
2);

//Verify Linker ExecutableShared
ssTEST_OUTPUT_SETUP
Expand All @@ -259,6 +281,9 @@ int main(int argc, char** argv)
ssTEST_OUTPUT_ASSERT( "Linker ExecutableShared RunParts size",
executableSharedLink.RunParts.size(),
1);
ssTEST_OUTPUT_ASSERT( "Linker ExecutableShared ExpectedOutputFiles size",
executableSharedLink.ExpectedOutputFiles.size(),
2);

//Test ToString() and Equals()
ssTEST_OUTPUT_EXECUTION
Expand Down
1 change: 1 addition & 0 deletions Src/Tests/Data/ProfilesCommandsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
MSVC:
- mkdir build
Expand Down
1 change: 1 addition & 0 deletions Src/Tests/Data/ProfilesDefinesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
MSVC:
- _WIN32
Expand Down
1 change: 1 addition & 0 deletions Src/Tests/Data/ProfilesFlagsOverrideTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(int argc, char** argv)
{
ssTEST_OUTPUT_SETUP
(
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
const char* yamlStr = R"(
MSVC:
Remove: /W4
Expand Down
Loading