Skip to content

Commit d9caed3

Browse files
Merge pull request #31 from Neko-Box-Coder/RefactorStartPipeline
Refactor StartPipeline
2 parents 9fcb053 + f6a9986 commit d9caed3

File tree

10 files changed

+1231
-870
lines changed

10 files changed

+1231
-870
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ add_library(runcpp2 STATIC
144144
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/StringUtil.cpp"
145145
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/runcpp2.cpp"
146146
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/BuildsManager.cpp"
147-
147+
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/PipelineSteps.cpp"
148148
)
149149

150150
target_include_directories(runcpp2 PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")

Include/runcpp2/BuildsManager.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ namespace runcpp2
1818
#endif
1919

2020
private:
21-
const ghc::filesystem::path ConfigDirectory;
21+
ghc::filesystem::path ConfigDirectory;
2222

2323
std::unordered_map<std::string, std::string> Mappings;
2424
std::unordered_map<std::string, std::string> ReverseMappings;
2525

2626

27-
const ghc::filesystem::path BuildDirectory;
28-
const ghc::filesystem::path MappingsFile;
27+
ghc::filesystem::path BuildDirectory;
28+
ghc::filesystem::path MappingsFile;
2929
bool Initialized;
3030

3131
bool ParseMappings(const std::string& mappingsContent);
@@ -34,6 +34,7 @@ namespace runcpp2
3434
public:
3535
BuildsManager(const ghc::filesystem::path& configDirectory);
3636
BuildsManager(const BuildsManager& other);
37+
BuildsManager& operator=(const BuildsManager& other);
3738
~BuildsManager();
3839

3940
bool Initialize();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef RUNCPP2_DATA_CMD_OPTIONS_HPP
2+
#define RUNCPP2_DATA_CMD_OPTIONS_HPP
3+
4+
namespace runcpp2
5+
{
6+
enum class CmdOptions
7+
{
8+
NONE,
9+
RESET_CACHE,
10+
RESET_USER_CONFIG,
11+
EXECUTABLE,
12+
HELP,
13+
RESET_DEPENDENCIES,
14+
LOCAL,
15+
SHOW_USER_CONFIG,
16+
SCRIPT_TEMPLATE,
17+
WATCH,
18+
BUILD,
19+
VERSION,
20+
LOG_LEVEL,
21+
CONFIG_FILE,
22+
CLEANUP,
23+
BUILD_SOURCE_ONLY,
24+
COUNT
25+
};
26+
}
27+
28+
#endif
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef RUNCPP2_PIPELINE_RESULT_HPP
2+
#define RUNCPP2_PIPELINE_RESULT_HPP
3+
4+
namespace runcpp2
5+
{
6+
enum class PipelineResult
7+
{
8+
UNEXPECTED_FAILURE,
9+
SUCCESS,
10+
EMPTY_PROFILES,
11+
INVALID_SCRIPT_PATH,
12+
INVALID_CONFIG_PATH,
13+
INVALID_BUILD_DIR,
14+
INVALID_SCRIPT_INFO,
15+
NO_AVAILABLE_PROFILE,
16+
DEPENDENCIES_FAILED,
17+
COMPILE_LINK_FAILED,
18+
INVALID_PROFILE,
19+
RUN_SCRIPT_FAILED,
20+
INVALID_OPTION,
21+
COUNT
22+
};
23+
}
24+
25+
#endif

Include/runcpp2/PipelineSteps.hpp

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#ifndef RUNCPP2_PIPELINE_STEPS_HPP
2+
#define RUNCPP2_PIPELINE_STEPS_HPP
3+
4+
#include "runcpp2/Data/Profile.hpp"
5+
#include "runcpp2/Data/PipelineResult.hpp"
6+
#include "runcpp2/Data/ProfilesCommands.hpp"
7+
#include "runcpp2/Data/ScriptInfo.hpp"
8+
#include "runcpp2/Data/CmdOptions.hpp"
9+
10+
#include "runcpp2/BuildsManager.hpp"
11+
12+
#include "ghc/filesystem.hpp"
13+
14+
#include <string>
15+
#include <vector>
16+
17+
namespace runcpp2
18+
{
19+
bool CopyFiles( const ghc::filesystem::path& destDir,
20+
const std::vector<std::string>& filePaths,
21+
std::vector<std::string>& outCopiedPaths);
22+
23+
PipelineResult RunProfileCommands( const Data::ProfilesCommands* commands,
24+
const Data::Profile& profile,
25+
const std::string& workingDir,
26+
const std::string& commandType);
27+
28+
PipelineResult ValidateInputs( const std::string& scriptPath,
29+
const std::vector<Data::Profile>& profiles,
30+
ghc::filesystem::path& outAbsoluteScriptPath,
31+
ghc::filesystem::path& outScriptDirectory,
32+
std::string& outScriptName);
33+
34+
PipelineResult
35+
ParseAndValidateScriptInfo( const ghc::filesystem::path& absoluteScriptPath,
36+
const ghc::filesystem::path& scriptDirectory,
37+
const std::string& scriptName,
38+
const Data::ScriptInfo* lastScriptInfo,
39+
Data::ScriptInfo& outScriptInfo);
40+
41+
PipelineResult HandleCleanup( const Data::ScriptInfo& scriptInfo,
42+
const Data::Profile& profile,
43+
const ghc::filesystem::path& scriptDirectory,
44+
const ghc::filesystem::path& buildDir,
45+
const ghc::filesystem::path& absoluteScriptPath,
46+
BuildsManager& buildsManager);
47+
48+
PipelineResult
49+
InitializeBuildDirectory( const ghc::filesystem::path& configDir,
50+
const ghc::filesystem::path& absoluteScriptPath,
51+
bool useLocalBuildDir,
52+
BuildsManager& outBuildsManager,
53+
ghc::filesystem::path& outBuildDir);
54+
55+
PipelineResult CheckScriptInfoChanges( const ghc::filesystem::path& buildDir,
56+
const Data::ScriptInfo& scriptInfo,
57+
const Data::Profile& profile,
58+
const ghc::filesystem::path& scriptDirectory,
59+
const Data::ScriptInfo* lastScriptInfo,
60+
bool& outRecompileNeeded,
61+
bool& outRelinkNeeded,
62+
std::vector<std::string>& outChangedDependencies);
63+
64+
PipelineResult
65+
ProcessDependencies(Data::ScriptInfo& scriptInfo,
66+
const Data::Profile& profile,
67+
const ghc::filesystem::path& absoluteScriptPath,
68+
const ghc::filesystem::path& buildDir,
69+
const std::unordered_map<CmdOptions, std::string>& currentOptions,
70+
const std::vector<std::string>& changedDependencies,
71+
std::vector<Data::DependencyInfo*>& outAvailableDependencies,
72+
std::vector<std::string>& outGatheredBinariesPaths);
73+
74+
void SeparateDependencyFiles( const Data::FilesTypesInfo& filesTypes,
75+
const std::vector<std::string>& gatheredBinariesPaths,
76+
std::vector<std::string>& outLinkFilesPaths,
77+
std::vector<std::string>& outFilesToCopyPaths);
78+
79+
PipelineResult HandlePreBuild( const Data::ScriptInfo& scriptInfo,
80+
const Data::Profile& profile,
81+
const ghc::filesystem::path& buildDir);
82+
83+
PipelineResult HandlePostBuild( const Data::ScriptInfo& scriptInfo,
84+
const Data::Profile& profile,
85+
const ghc::filesystem::path& buildDir);
86+
87+
PipelineResult
88+
RunCompiledOutput( const ghc::filesystem::path& target,
89+
const ghc::filesystem::path& absoluteScriptPath,
90+
const Data::ScriptInfo& scriptInfo,
91+
const std::vector<std::string>& runArgs,
92+
const std::unordered_map<CmdOptions, std::string>& currentOptions,
93+
int& returnStatus);
94+
95+
PipelineResult
96+
HandleBuildOutput( const ghc::filesystem::path& target,
97+
const std::vector<std::string>& filesToCopyPaths,
98+
const Data::ScriptInfo& scriptInfo,
99+
const Data::Profile& profile,
100+
const std::string& buildOutputDir,
101+
const std::unordered_map<CmdOptions, std::string>& currentOptions);
102+
103+
PipelineResult GetTargetPath( const ghc::filesystem::path& buildDir,
104+
const std::string& scriptName,
105+
const Data::Profile& profile,
106+
const std::unordered_map<CmdOptions, std::string>& currentOptions,
107+
ghc::filesystem::path& outTarget);
108+
}
109+
110+
111+
#endif

Include/runcpp2/runcpp2.hpp

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,16 @@
11
#ifndef RUNCPP2_RUNCPP2_HPP
22
#define RUNCPP2_RUNCPP2_HPP
33

4+
#include "runcpp2/Data/CmdOptions.hpp"
45
#include "runcpp2/Data/Profile.hpp"
56
#include "runcpp2/Data/ScriptInfo.hpp"
7+
#include "runcpp2/Data/PipelineResult.hpp"
68

79
#include <string>
810
#include <vector>
911

1012
namespace runcpp2
1113
{
12-
enum class CmdOptions
13-
{
14-
NONE,
15-
RESET_CACHE,
16-
RESET_USER_CONFIG,
17-
EXECUTABLE,
18-
HELP,
19-
RESET_DEPENDENCIES,
20-
LOCAL,
21-
SHOW_USER_CONFIG,
22-
SCRIPT_TEMPLATE,
23-
WATCH,
24-
BUILD,
25-
VERSION,
26-
LOG_LEVEL,
27-
CONFIG_FILE,
28-
CLEANUP,
29-
COUNT
30-
};
31-
32-
enum class PipelineResult
33-
{
34-
UNEXPECTED_FAILURE,
35-
SUCCESS,
36-
EMPTY_PROFILES,
37-
INVALID_SCRIPT_PATH,
38-
INVALID_CONFIG_PATH,
39-
INVALID_BUILD_DIR,
40-
INVALID_SCRIPT_INFO,
41-
NO_AVAILABLE_PROFILE,
42-
DEPENDENCIES_FAILED,
43-
COMPILE_LINK_FAILED,
44-
INVALID_PROFILE,
45-
RUN_SCRIPT_FAILED,
46-
COUNT
47-
};
48-
4914
struct OptionInfo
5015
{
5116
CmdOptions Option;
@@ -69,6 +34,8 @@ namespace runcpp2
6934
Data::ScriptInfo& outScriptInfo,
7035
const std::string& buildOutputDir,
7136
int& returnStatus);
37+
38+
std::string PipelineResultToString(PipelineResult result);
7239
}
7340

7441
#endif

Src/runcpp2/BuildsManager.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ namespace runcpp2
9393
MappingsFile(BuildDirectory / "Mappings.csv"),
9494
Initialized(false)
9595
{}
96+
97+
BuildsManager::BuildsManager(const BuildsManager& other)
98+
{
99+
*this = other;
100+
}
101+
102+
BuildsManager& BuildsManager::operator=(const BuildsManager& other)
103+
{
104+
ConfigDirectory = other.ConfigDirectory;
105+
Mappings = other.Mappings;
106+
BuildDirectory = other.BuildDirectory;
107+
MappingsFile = other.MappingsFile;
108+
Initialized = other.Initialized;
109+
return *this;
110+
}
96111

97112
BuildsManager::~BuildsManager()
98113
{}

0 commit comments

Comments
 (0)