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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ add_library(runcpp2 STATIC
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesCommands.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesFlagsOverride.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ScriptInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesCompilesFiles.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesProcessPaths.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FilesTypesInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/StageInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesDefines.cpp"
Expand Down
11 changes: 10 additions & 1 deletion DefaultYAMLs/DefaultScriptInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,22 @@ OtherFilesToBeCompiled:
DefaultProfile:
- "./AnotherSourceFile.cpp"

# (Optional) Include paths (relative to script file path) for each platform and profile
IncludePaths:
# Target Platform (DefaultPlatform, Windows, Linux, MacOS, or Unix)
DefaultPlatform:
# Target Profile (e.g., "g++", "clang++", "msvc", or "DefaultProfile" for any profile)
DefaultProfile:
- "./include"
- "./src/include"

# (Optional) Define cross-compiler defines for each platform and profile.
# Defines can be specified as just a name or as a name-value pair.
Defines:
# Target Platform (DefaultPlatform, Windows, Linux, MacOS, or Unix)
DefaultPlatform:
# Profile name (e.g., "g++", "clang++", "msvc", or "DefaultProfile" for any profile)
"DefaultProfile":
DefaultProfile:
- "EXAMPLE_DEFINE" # Define without a value
- "VERSION_MAJOR=1" # Define with a value

Expand Down
9 changes: 7 additions & 2 deletions Examples/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ PassScriptPath: true
"msvc":
- "./OtherSources/AnotherSourceFileMSVC.cpp"

IncludePaths:
DefaultPlatform:
DefaultProfile:
- "./OtherSources"

Defines:
DefaultPlatform:
# Turns into `TEST_DEF=\"Test Define Working\"` in shell
Expand Down Expand Up @@ -104,11 +109,11 @@ PassScriptPath: true
#include "System2.hpp"

#if defined(__GNUC__)
#include "./OtherSources/AnotherSourceFileGcc.hpp"
#include "AnotherSourceFileGcc.hpp"
#endif

#if defined(_MSC_VER)
#include "./OtherSources/AnotherSourceFileMSVC.hpp"
#include "AnotherSourceFileMSVC.hpp"
#endif

#include <iostream>
Expand Down
2 changes: 2 additions & 0 deletions Include/runcpp2/CompilingLinking.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace runcpp2
const ghc::filesystem::path& scriptPath,
const std::vector<ghc::filesystem::path>& sourceFiles,
const std::vector<bool>& sourceHasCache,
const std::vector<ghc::filesystem::path>& includePaths,
const Data::ScriptInfo& scriptInfo,
const std::vector<Data::DependencyInfo*>& availableDependencies,
const Data::Profile& profile,
Expand All @@ -25,6 +26,7 @@ namespace runcpp2
const std::string& outputName,
const std::vector<ghc::filesystem::path>& sourceFiles,
const std::vector<bool>& sourceHasCache,
const std::vector<ghc::filesystem::path>& includePaths,
const Data::ScriptInfo& scriptInfo,
const std::vector<Data::DependencyInfo*>& availableDependencies,
const Data::Profile& profile,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RUNCPP2_DATA_PROFILES_COMPILES_FILES_HPP
#define RUNCPP2_DATA_PROFILES_COMPILES_FILES_HPP
#ifndef RUNCPP2_DATA_PROFILES_PROCESS_PATHS_HPP
#define RUNCPP2_DATA_PROFILES_PROCESS_PATHS_HPP

#include "runcpp2/Data/ParseCommon.hpp"

Expand All @@ -14,14 +14,14 @@ namespace runcpp2
{
namespace Data
{
class ProfilesCompilesFiles
class ProfilesProcessPaths
{
public:
std::unordered_map<ProfileName, std::vector<ghc::filesystem::path>> CompilesFiles;
std::unordered_map<ProfileName, std::vector<ghc::filesystem::path>> Paths;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
std::string ToString(std::string indentation) const;
bool Equals(const ProfilesCompilesFiles& other) const;
bool Equals(const ProfilesProcessPaths& other) const;
};
}
}
Expand Down
5 changes: 3 additions & 2 deletions Include/runcpp2/Data/ScriptInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "runcpp2/Data/DependencyInfo.hpp"
#include "runcpp2/Data/ProfilesFlagsOverride.hpp"
#include "runcpp2/Data/ParseCommon.hpp"
#include "runcpp2/Data/ProfilesCompilesFiles.hpp"
#include "runcpp2/Data/ProfilesProcessPaths.hpp"
#include "runcpp2/Data/ProfilesDefines.hpp"
#include "runcpp2/Data/ProfilesCommands.hpp"

Expand All @@ -26,7 +26,8 @@ namespace runcpp2
std::unordered_map<PlatformName, ProfilesFlagsOverride> OverrideCompileFlags;
std::unordered_map<PlatformName, ProfilesFlagsOverride> OverrideLinkFlags;

std::unordered_map<PlatformName, ProfilesCompilesFiles> OtherFilesToBeCompiled;
std::unordered_map<PlatformName, ProfilesProcessPaths> OtherFilesToBeCompiled;
std::unordered_map<PlatformName, ProfilesProcessPaths> IncludePaths;

std::vector<DependencyInfo> Dependencies;

Expand Down
11 changes: 11 additions & 0 deletions Include/runcpp2/PipelineSteps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ namespace runcpp2
const Data::Profile& profile,
const std::unordered_map<CmdOptions, std::string>& currentOptions,
ghc::filesystem::path& outTarget);

bool GatherSourceFiles( const ghc::filesystem::path& absoluteScriptPath,
const Data::ScriptInfo& scriptInfo,
const Data::Profile& currentProfile,
std::vector<ghc::filesystem::path>& outSourcePaths);

bool GatherIncludePaths(const ghc::filesystem::path& scriptDirectory,
const Data::ScriptInfo& scriptInfo,
const Data::Profile& currentProfile,
const std::vector<Data::DependencyInfo*>& dependencies,
std::vector<ghc::filesystem::path>& outIncludePaths);
}


Expand Down
2 changes: 1 addition & 1 deletion Src/Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ create_data_test(FlagsOverrideInfoTest)
create_data_test(DependencySourceTest)
create_data_test(FilesToCopyInfoTest)
create_data_test(ProfilesCommandsTest)
create_data_test(ProfilesCompilesFilesTest)
create_data_test(ProfilesProcessPathsTest)
create_data_test(ProfilesDefinesTest)
create_data_test(DependencyLinkPropertyTest)
create_data_test(FilesTypesInfoTest)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "runcpp2/Data/ProfilesCompilesFiles.hpp"
#include "runcpp2/Data/ProfilesProcessPaths.hpp"
#include "ssTest.hpp"
#include "runcpp2/YamlLib.hpp"
#include "runcpp2/runcpp2.hpp"
Expand All @@ -9,7 +9,7 @@ int main(int argc, char** argv)

ssTEST_INIT_TEST_GROUP();

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

runcpp2::Data::ProfilesCompilesFiles profilesCompilesFiles;
runcpp2::Data::ProfilesProcessPaths profilesProcessPaths;
);

ssTEST_OUTPUT_EXECUTION
(
ryml::ConstNodeRef nodeRef = root;
bool parseResult = profilesCompilesFiles.ParseYAML_Node(nodeRef);
bool parseResult = profilesProcessPaths.ParseYAML_Node(nodeRef);
);

ssTEST_OUTPUT_ASSERT("ParseYAML_Node should succeed", parseResult);

//Verify parsed values
ssTEST_OUTPUT_ASSERT( "MSVC files count",
profilesCompilesFiles.CompilesFiles.at("MSVC").size() == 2);
profilesProcessPaths.Paths.at("MSVC").size() == 2);
ssTEST_OUTPUT_ASSERT( "GCC files count",
profilesCompilesFiles.CompilesFiles.at("GCC").size() == 2);
profilesProcessPaths.Paths.at("GCC").size() == 2);
ssTEST_OUTPUT_ASSERT( "MSVC first file",
profilesCompilesFiles.CompilesFiles.at("MSVC").at(0) ==
profilesProcessPaths.Paths.at("MSVC").at(0) ==
"src/main.cpp");
ssTEST_OUTPUT_ASSERT( "GCC last file",
profilesCompilesFiles.CompilesFiles.at("GCC").at(1) ==
profilesProcessPaths.Paths.at("GCC").at(1) ==
"src/optimized.cpp");

//Test ToString() and Equals()
ssTEST_OUTPUT_EXECUTION
(
std::string yamlOutput = profilesCompilesFiles.ToString("");
std::string yamlOutput = profilesProcessPaths.ToString("");
ryml::Tree outputTree = ryml::parse_in_arena(ryml::to_csubstr(yamlOutput));

runcpp2::Data::ProfilesCompilesFiles parsedOutput;
runcpp2::Data::ProfilesProcessPaths parsedOutput;
nodeRef = outputTree.rootref();
parsedOutput.ParseYAML_Node(nodeRef);
);

ssTEST_OUTPUT_ASSERT( "Parsed output should equal original",
profilesCompilesFiles.Equals(parsedOutput));
profilesProcessPaths.Equals(parsedOutput));
};

ssTEST_END_TEST_GROUP();
Expand Down
21 changes: 17 additions & 4 deletions Src/Tests/Data/ScriptInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ int main(int argc, char** argv)
MSVC:
- src/extra.cpp
- src/debug.cpp
IncludePaths:
Windows:
MSVC:
- include
Defines:
Windows:
MSVC:
Expand Down Expand Up @@ -152,12 +156,21 @@ int main(int argc, char** argv)
//Verify OtherFilesToBeCompiled
ssTEST_OUTPUT_SETUP
(
const std::vector<ghc::filesystem::path>& msvcFiles =
scriptInfo.OtherFilesToBeCompiled.at("Windows").CompilesFiles.at("MSVC");
const std::vector<ghc::filesystem::path>& msvcCompileFiles =
scriptInfo.OtherFilesToBeCompiled.at("Windows").Paths.at("MSVC");
);
ssTEST_OUTPUT_ASSERT("MSVC files count", msvcFiles.size() == 2);
ssTEST_OUTPUT_ASSERT("MSVC first file", msvcFiles.at(0) == "src/extra.cpp");
ssTEST_OUTPUT_ASSERT("MSVC files count", msvcCompileFiles.size() == 2);
ssTEST_OUTPUT_ASSERT("MSVC first file", msvcCompileFiles.at(0) == "src/extra.cpp");

//Verify IncludePaths
ssTEST_OUTPUT_SETUP
(
const std::vector<ghc::filesystem::path>& msvcIncludeFiles =
scriptInfo.IncludePaths.at("Windows").Paths.at("MSVC");
);
ssTEST_OUTPUT_ASSERT("IncludePaths count", msvcIncludeFiles.size() == 1);
ssTEST_OUTPUT_ASSERT("IncludePaths first path", msvcIncludeFiles.at(0) == "include");

//Verify Defines
ssTEST_OUTPUT_SETUP
(
Expand Down
2 changes: 1 addition & 1 deletion Src/Tests/RunAllTests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CALL :RUN_TEST "%~dp0\%MODE%FlagsOverrideInfoTest.exe"
CALL :RUN_TEST "%~dp0\%MODE%DependencySourceTest.exe"
CALL :RUN_TEST "%~dp0\%MODE%ProfilesCommandsTest.exe"
CALL :RUN_TEST "%~dp0\%MODE%FilesToCopyInfoTest.exe"
CALL :RUN_TEST "%~dp0\%MODE%ProfilesCompilesFilesTest.exe"
CALL :RUN_TEST "%~dp0\%MODE%ProfilesProcessPathsTest.exe"
CALL :RUN_TEST "%~dp0\%MODE%ProfilesDefinesTest.exe"
CALL :RUN_TEST "%~dp0\%MODE%DependencyLinkPropertyTest.exe"
CALL :RUN_TEST "%~dp0\%MODE%FilesTypesInfoTest.exe"
Expand Down
2 changes: 1 addition & 1 deletion Src/Tests/RunAllTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ runTest ./FlagsOverrideInfoTest
runTest ./DependencySourceTest
runTest ./ProfilesCommandsTest
runTest ./FilesToCopyInfoTest
runTest ./ProfilesCompilesFilesTest
runTest ./ProfilesProcessPathsTest
runTest ./ProfilesDefinesTest
runTest ./DependencyLinkPropertyTest
runTest ./FilesTypesInfoTest
Expand Down
20 changes: 9 additions & 11 deletions Src/runcpp2/CompilingLinking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ namespace
bool CompileScript( const ghc::filesystem::path& buildDir,
const ghc::filesystem::path& scriptPath,
const std::vector<ghc::filesystem::path>& sourceFiles,
const std::vector<ghc::filesystem::path>& includePaths,
const runcpp2::Data::ScriptInfo& scriptInfo,
const std::vector<runcpp2::Data::DependencyInfo*>& availableDependencies,
const runcpp2::Data::Profile& profile,
Expand Down Expand Up @@ -100,18 +101,11 @@ namespace
substitutionMapTemplate["{CompileFlags}"] = {compileFlags};
}

//Include Directories
//Add script and dependency include paths
for(const ghc::filesystem::path& includePath : includePaths)
{
for(int i = 0; i < availableDependencies.size(); ++i)
{
for(int j = 0; j < availableDependencies.at(i)->AbsoluteIncludePaths.size(); ++j)
{
const std::string& currentIncludePath =
availableDependencies.at(i)->AbsoluteIncludePaths.at(j);

substitutionMapTemplate["{IncludeDirectoryPath}"].push_back(currentIncludePath);
}
}
std::string processedInclude = runcpp2::ProcessPath(includePath.string());
substitutionMapTemplate["{IncludeDirectoryPath}"].push_back(processedInclude);
}

// Add defines
Expand Down Expand Up @@ -643,6 +637,7 @@ bool runcpp2::CompileScriptOnly(const ghc::filesystem::path& buildDir,
const ghc::filesystem::path& scriptPath,
const std::vector<ghc::filesystem::path>& sourceFiles,
const std::vector<bool>& sourceHasCache,
const std::vector<ghc::filesystem::path>& includePaths,
const Data::ScriptInfo& scriptInfo,
const std::vector<Data::DependencyInfo*>& availableDependencies,
const Data::Profile& profile,
Expand All @@ -667,6 +662,7 @@ bool runcpp2::CompileScriptOnly(const ghc::filesystem::path& buildDir,
if(!CompileScript( buildDir,
scriptPath,
sourceFilesNeededToCompile,
includePaths,
scriptInfo,
availableDependencies,
profile,
Expand All @@ -685,6 +681,7 @@ bool runcpp2::CompileAndLinkScript( const ghc::filesystem::path& buildDir,
const std::string& outputName,
const std::vector<ghc::filesystem::path>& sourceFiles,
const std::vector<bool>& sourceHasCache,
const std::vector<ghc::filesystem::path>& includePaths,
const Data::ScriptInfo& scriptInfo,
const std::vector<Data::DependencyInfo*>& availableDependencies,
const Data::Profile& profile,
Expand All @@ -711,6 +708,7 @@ bool runcpp2::CompileAndLinkScript( const ghc::filesystem::path& buildDir,
if(!CompileScript( buildDir,
scriptPath,
sourceFilesNeededToCompile,
includePaths,
scriptInfo,
availableDependencies,
profile,
Expand Down
Loading