Skip to content

Commit f6a9986

Browse files
Extracting PipelineSteps
1 parent 46fec18 commit f6a9986

File tree

7 files changed

+1045
-993
lines changed

7 files changed

+1045
-993
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")
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: 2 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +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"
6-
#include "runcpp2/BuildsManager.hpp"
7+
#include "runcpp2/Data/PipelineResult.hpp"
78

89
#include <string>
910
#include <vector>
1011

1112
namespace runcpp2
1213
{
13-
enum class CmdOptions
14-
{
15-
NONE,
16-
RESET_CACHE,
17-
RESET_USER_CONFIG,
18-
EXECUTABLE,
19-
HELP,
20-
RESET_DEPENDENCIES,
21-
LOCAL,
22-
SHOW_USER_CONFIG,
23-
SCRIPT_TEMPLATE,
24-
WATCH,
25-
BUILD,
26-
VERSION,
27-
LOG_LEVEL,
28-
CONFIG_FILE,
29-
CLEANUP,
30-
BUILD_SOURCE_ONLY,
31-
COUNT
32-
};
33-
34-
enum class PipelineResult
35-
{
36-
UNEXPECTED_FAILURE,
37-
SUCCESS,
38-
EMPTY_PROFILES,
39-
INVALID_SCRIPT_PATH,
40-
INVALID_CONFIG_PATH,
41-
INVALID_BUILD_DIR,
42-
INVALID_SCRIPT_INFO,
43-
NO_AVAILABLE_PROFILE,
44-
DEPENDENCIES_FAILED,
45-
COMPILE_LINK_FAILED,
46-
INVALID_PROFILE,
47-
RUN_SCRIPT_FAILED,
48-
INVALID_OPTION,
49-
COUNT
50-
};
51-
5214
struct OptionInfo
5315
{
5416
CmdOptions Option;
@@ -63,92 +25,6 @@ namespace runcpp2
6325

6426
void SetLogLevel(const std::string& logLevel);
6527

66-
PipelineResult RunProfileCommands( const Data::ProfilesCommands* commands,
67-
const Data::Profile& profile,
68-
const std::string& workingDir,
69-
const std::string& commandType);
70-
71-
PipelineResult ValidateInputs( const std::string& scriptPath,
72-
const std::vector<Data::Profile>& profiles,
73-
ghc::filesystem::path& outAbsoluteScriptPath,
74-
ghc::filesystem::path& outScriptDirectory,
75-
std::string& outScriptName);
76-
77-
PipelineResult
78-
ParseAndValidateScriptInfo( const ghc::filesystem::path& absoluteScriptPath,
79-
const ghc::filesystem::path& scriptDirectory,
80-
const std::string& scriptName,
81-
const Data::ScriptInfo* lastScriptInfo,
82-
Data::ScriptInfo& outScriptInfo);
83-
84-
PipelineResult HandleCleanup( const Data::ScriptInfo& scriptInfo,
85-
const Data::Profile& profile,
86-
const ghc::filesystem::path& scriptDirectory,
87-
const ghc::filesystem::path& buildDir,
88-
const ghc::filesystem::path& absoluteScriptPath,
89-
BuildsManager& buildsManager);
90-
91-
PipelineResult
92-
InitializeBuildDirectory( const ghc::filesystem::path& configDir,
93-
const ghc::filesystem::path& absoluteScriptPath,
94-
bool useLocalBuildDir,
95-
BuildsManager& outBuildsManager,
96-
ghc::filesystem::path& outBuildDir);
97-
98-
PipelineResult CheckScriptInfoChanges( const ghc::filesystem::path& buildDir,
99-
const Data::ScriptInfo& scriptInfo,
100-
const Data::Profile& profile,
101-
const ghc::filesystem::path& scriptDirectory,
102-
const Data::ScriptInfo* lastScriptInfo,
103-
bool& outRecompileNeeded,
104-
bool& outRelinkNeeded,
105-
std::vector<std::string>& outChangedDependencies);
106-
107-
PipelineResult
108-
ProcessDependencies(Data::ScriptInfo& scriptInfo,
109-
const Data::Profile& profile,
110-
const ghc::filesystem::path& absoluteScriptPath,
111-
const ghc::filesystem::path& buildDir,
112-
const std::unordered_map<CmdOptions, std::string>& currentOptions,
113-
const std::vector<std::string>& changedDependencies,
114-
std::vector<Data::DependencyInfo*>& outAvailableDependencies,
115-
std::vector<std::string>& outGatheredBinariesPaths);
116-
117-
void SeparateDependencyFiles( const Data::FilesTypesInfo& filesTypes,
118-
const std::vector<std::string>& gatheredBinariesPaths,
119-
std::vector<std::string>& outLinkFilesPaths,
120-
std::vector<std::string>& outFilesToCopyPaths);
121-
122-
PipelineResult HandlePreBuild( const Data::ScriptInfo& scriptInfo,
123-
const Data::Profile& profile,
124-
const ghc::filesystem::path& buildDir);
125-
126-
PipelineResult HandlePostBuild( const Data::ScriptInfo& scriptInfo,
127-
const Data::Profile& profile,
128-
const ghc::filesystem::path& buildDir);
129-
130-
PipelineResult
131-
RunCompiledOutput( const ghc::filesystem::path& target,
132-
const ghc::filesystem::path& absoluteScriptPath,
133-
const Data::ScriptInfo& scriptInfo,
134-
const std::vector<std::string>& runArgs,
135-
const std::unordered_map<CmdOptions, std::string>& currentOptions,
136-
int& returnStatus);
137-
138-
PipelineResult
139-
HandleBuildOutput( const ghc::filesystem::path& target,
140-
const std::vector<std::string>& filesToCopyPaths,
141-
const Data::ScriptInfo& scriptInfo,
142-
const Data::Profile& profile,
143-
const std::string& buildOutputDir,
144-
const std::unordered_map<CmdOptions, std::string>& currentOptions);
145-
146-
PipelineResult GetTargetPath( const ghc::filesystem::path& buildDir,
147-
const std::string& scriptName,
148-
const Data::Profile& profile,
149-
const std::unordered_map<CmdOptions, std::string>& currentOptions,
150-
ghc::filesystem::path& outTarget);
151-
15228
PipelineResult StartPipeline( const std::string& scriptPath,
15329
const std::vector<Data::Profile>& profiles,
15430
const std::string& configPreferredProfile,

0 commit comments

Comments
 (0)