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 @@ -144,7 +144,7 @@ add_library(runcpp2 STATIC
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/StringUtil.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/runcpp2.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/BuildsManager.cpp"

"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/PipelineSteps.cpp"
)

target_include_directories(runcpp2 PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")
Expand Down
7 changes: 4 additions & 3 deletions Include/runcpp2/BuildsManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ namespace runcpp2
#endif

private:
const ghc::filesystem::path ConfigDirectory;
ghc::filesystem::path ConfigDirectory;

std::unordered_map<std::string, std::string> Mappings;
std::unordered_map<std::string, std::string> ReverseMappings;


const ghc::filesystem::path BuildDirectory;
const ghc::filesystem::path MappingsFile;
ghc::filesystem::path BuildDirectory;
ghc::filesystem::path MappingsFile;
bool Initialized;

bool ParseMappings(const std::string& mappingsContent);
Expand All @@ -34,6 +34,7 @@ namespace runcpp2
public:
BuildsManager(const ghc::filesystem::path& configDirectory);
BuildsManager(const BuildsManager& other);
BuildsManager& operator=(const BuildsManager& other);
~BuildsManager();

bool Initialize();
Expand Down
28 changes: 28 additions & 0 deletions Include/runcpp2/Data/CmdOptions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef RUNCPP2_DATA_CMD_OPTIONS_HPP
#define RUNCPP2_DATA_CMD_OPTIONS_HPP

namespace runcpp2
{
enum class CmdOptions
{
NONE,
RESET_CACHE,
RESET_USER_CONFIG,
EXECUTABLE,
HELP,
RESET_DEPENDENCIES,
LOCAL,
SHOW_USER_CONFIG,
SCRIPT_TEMPLATE,
WATCH,
BUILD,
VERSION,
LOG_LEVEL,
CONFIG_FILE,
CLEANUP,
BUILD_SOURCE_ONLY,
COUNT
};
}

#endif
25 changes: 25 additions & 0 deletions Include/runcpp2/Data/PipelineResult.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef RUNCPP2_PIPELINE_RESULT_HPP
#define RUNCPP2_PIPELINE_RESULT_HPP

namespace runcpp2
{
enum class PipelineResult
{
UNEXPECTED_FAILURE,
SUCCESS,
EMPTY_PROFILES,
INVALID_SCRIPT_PATH,
INVALID_CONFIG_PATH,
INVALID_BUILD_DIR,
INVALID_SCRIPT_INFO,
NO_AVAILABLE_PROFILE,
DEPENDENCIES_FAILED,
COMPILE_LINK_FAILED,
INVALID_PROFILE,
RUN_SCRIPT_FAILED,
INVALID_OPTION,
COUNT
};
}

#endif
111 changes: 111 additions & 0 deletions Include/runcpp2/PipelineSteps.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#ifndef RUNCPP2_PIPELINE_STEPS_HPP
#define RUNCPP2_PIPELINE_STEPS_HPP

#include "runcpp2/Data/Profile.hpp"
#include "runcpp2/Data/PipelineResult.hpp"
#include "runcpp2/Data/ProfilesCommands.hpp"
#include "runcpp2/Data/ScriptInfo.hpp"
#include "runcpp2/Data/CmdOptions.hpp"

#include "runcpp2/BuildsManager.hpp"

#include "ghc/filesystem.hpp"

#include <string>
#include <vector>

namespace runcpp2
{
bool CopyFiles( const ghc::filesystem::path& destDir,
const std::vector<std::string>& filePaths,
std::vector<std::string>& outCopiedPaths);

PipelineResult RunProfileCommands( const Data::ProfilesCommands* commands,
const Data::Profile& profile,
const std::string& workingDir,
const std::string& commandType);

PipelineResult ValidateInputs( const std::string& scriptPath,
const std::vector<Data::Profile>& profiles,
ghc::filesystem::path& outAbsoluteScriptPath,
ghc::filesystem::path& outScriptDirectory,
std::string& outScriptName);

PipelineResult
ParseAndValidateScriptInfo( const ghc::filesystem::path& absoluteScriptPath,
const ghc::filesystem::path& scriptDirectory,
const std::string& scriptName,
const Data::ScriptInfo* lastScriptInfo,
Data::ScriptInfo& outScriptInfo);

PipelineResult HandleCleanup( const Data::ScriptInfo& scriptInfo,
const Data::Profile& profile,
const ghc::filesystem::path& scriptDirectory,
const ghc::filesystem::path& buildDir,
const ghc::filesystem::path& absoluteScriptPath,
BuildsManager& buildsManager);

PipelineResult
InitializeBuildDirectory( const ghc::filesystem::path& configDir,
const ghc::filesystem::path& absoluteScriptPath,
bool useLocalBuildDir,
BuildsManager& outBuildsManager,
ghc::filesystem::path& outBuildDir);

PipelineResult CheckScriptInfoChanges( const ghc::filesystem::path& buildDir,
const Data::ScriptInfo& scriptInfo,
const Data::Profile& profile,
const ghc::filesystem::path& scriptDirectory,
const Data::ScriptInfo* lastScriptInfo,
bool& outRecompileNeeded,
bool& outRelinkNeeded,
std::vector<std::string>& outChangedDependencies);

PipelineResult
ProcessDependencies(Data::ScriptInfo& scriptInfo,
const Data::Profile& profile,
const ghc::filesystem::path& absoluteScriptPath,
const ghc::filesystem::path& buildDir,
const std::unordered_map<CmdOptions, std::string>& currentOptions,
const std::vector<std::string>& changedDependencies,
std::vector<Data::DependencyInfo*>& outAvailableDependencies,
std::vector<std::string>& outGatheredBinariesPaths);

void SeparateDependencyFiles( const Data::FilesTypesInfo& filesTypes,
const std::vector<std::string>& gatheredBinariesPaths,
std::vector<std::string>& outLinkFilesPaths,
std::vector<std::string>& outFilesToCopyPaths);

PipelineResult HandlePreBuild( const Data::ScriptInfo& scriptInfo,
const Data::Profile& profile,
const ghc::filesystem::path& buildDir);

PipelineResult HandlePostBuild( const Data::ScriptInfo& scriptInfo,
const Data::Profile& profile,
const ghc::filesystem::path& buildDir);

PipelineResult
RunCompiledOutput( const ghc::filesystem::path& target,
const ghc::filesystem::path& absoluteScriptPath,
const Data::ScriptInfo& scriptInfo,
const std::vector<std::string>& runArgs,
const std::unordered_map<CmdOptions, std::string>& currentOptions,
int& returnStatus);

PipelineResult
HandleBuildOutput( const ghc::filesystem::path& target,
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,
ghc::filesystem::path& outTarget);
}


#endif
41 changes: 4 additions & 37 deletions Include/runcpp2/runcpp2.hpp
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
#ifndef RUNCPP2_RUNCPP2_HPP
#define RUNCPP2_RUNCPP2_HPP

#include "runcpp2/Data/CmdOptions.hpp"
#include "runcpp2/Data/Profile.hpp"
#include "runcpp2/Data/ScriptInfo.hpp"
#include "runcpp2/Data/PipelineResult.hpp"

#include <string>
#include <vector>

namespace runcpp2
{
enum class CmdOptions
{
NONE,
RESET_CACHE,
RESET_USER_CONFIG,
EXECUTABLE,
HELP,
RESET_DEPENDENCIES,
LOCAL,
SHOW_USER_CONFIG,
SCRIPT_TEMPLATE,
WATCH,
BUILD,
VERSION,
LOG_LEVEL,
CONFIG_FILE,
CLEANUP,
COUNT
};

enum class PipelineResult
{
UNEXPECTED_FAILURE,
SUCCESS,
EMPTY_PROFILES,
INVALID_SCRIPT_PATH,
INVALID_CONFIG_PATH,
INVALID_BUILD_DIR,
INVALID_SCRIPT_INFO,
NO_AVAILABLE_PROFILE,
DEPENDENCIES_FAILED,
COMPILE_LINK_FAILED,
INVALID_PROFILE,
RUN_SCRIPT_FAILED,
COUNT
};

struct OptionInfo
{
CmdOptions Option;
Expand All @@ -69,6 +34,8 @@ namespace runcpp2
Data::ScriptInfo& outScriptInfo,
const std::string& buildOutputDir,
int& returnStatus);

std::string PipelineResultToString(PipelineResult result);
}

#endif
15 changes: 15 additions & 0 deletions Src/runcpp2/BuildsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ namespace runcpp2
MappingsFile(BuildDirectory / "Mappings.csv"),
Initialized(false)
{}

BuildsManager::BuildsManager(const BuildsManager& other)
{
*this = other;
}

BuildsManager& BuildsManager::operator=(const BuildsManager& other)
{
ConfigDirectory = other.ConfigDirectory;
Mappings = other.Mappings;
BuildDirectory = other.BuildDirectory;
MappingsFile = other.MappingsFile;
Initialized = other.Initialized;
return *this;
}

BuildsManager::~BuildsManager()
{}
Expand Down
Loading