Skip to content

Commit 5e30b61

Browse files
Adding option to watch script changes
1 parent ee13b49 commit 5e30b61

File tree

9 files changed

+352
-193
lines changed

9 files changed

+352
-193
lines changed

Include/runcpp2/CompilingLinking.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
namespace runcpp2
1212
{
13+
bool CompileScriptOnly( const ghc::filesystem::path& buildDir,
14+
const std::string& scriptPath,
15+
const Data::ScriptInfo& scriptInfo,
16+
const std::vector<Data::DependencyInfo*>& availableDependencies,
17+
const Data::Profile& profile,
18+
bool buildExecutable);
19+
1320
bool CompileAndLinkScript( const ghc::filesystem::path& buildDir,
1421
const std::string& scriptPath,
1522
const Data::ScriptInfo& scriptInfo,

Include/runcpp2/DependenciesHelper.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ namespace runcpp2
2323
const std::vector<Data::DependencyInfo*>& availableDependencies,
2424
const std::vector<std::string>& dependenciesLocalCopiesPaths);
2525

26-
bool SetupDependencies( const runcpp2::Data::Profile& profile,
27-
const ghc::filesystem::path& buildDir,
28-
const Data::ScriptInfo& scriptInfo,
29-
std::vector<Data::DependencyInfo*>& availableDependencies,
30-
const std::vector<std::string>& dependenciesLocalCopiesPaths,
31-
const std::vector<std::string>& dependenciesSourcePaths);
26+
bool SetupDependenciesIfNeeded( const runcpp2::Data::Profile& profile,
27+
const ghc::filesystem::path& buildDir,
28+
const Data::ScriptInfo& scriptInfo,
29+
std::vector<Data::DependencyInfo*>& availableDependencies,
30+
const std::vector<std::string>& dependenciesLocalCopiesPaths,
31+
const std::vector<std::string>& dependenciesSourcePaths);
3232

3333
bool BuildDependencies( const runcpp2::Data::Profile& profile,
3434
const Data::ScriptInfo& scriptInfo,

Include/runcpp2/runcpp2.hpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@ namespace runcpp2
2020
LOCAL,
2121
SHOW_USER_CONFIG,
2222
SCRIPT_TEMPLATE,
23+
WATCH,
24+
COUNT
25+
};
26+
27+
enum class PipelineResult
28+
{
29+
UNEXPECTED_FAILURE,
30+
SUCCESS,
31+
EMPTY_PROFILES,
32+
INVALID_SCRIPT_PATH,
33+
INVALID_CONFIG_PATH,
34+
INVALID_BUILD_DIR,
35+
INVALID_SCRIPT_INFO,
36+
NO_AVAILABLE_PROFILE,
37+
DEPENDENCIES_FAILED,
38+
COMPILE_LINK_FAILED,
39+
INVALID_PROFILE,
40+
RUN_SCRIPT_FAILED,
2341
COUNT
2442
};
2543

@@ -35,11 +53,12 @@ namespace runcpp2
3553

3654
void GetDefaultScriptInfo(std::string& scriptInfo);
3755

38-
int RunScript( const std::string& scriptPath,
39-
const std::vector<Data::Profile>& profiles,
40-
const std::string& configPreferredProfile,
41-
const std::unordered_map<CmdOptions, std::string> currentOptions,
42-
const std::vector<std::string>& runArgs);
56+
PipelineResult StartPipeline( const std::string& scriptPath,
57+
const std::vector<Data::Profile>& profiles,
58+
const std::string& configPreferredProfile,
59+
const std::unordered_map<CmdOptions, std::string> currentOptions,
60+
const std::vector<std::string>& runArgs,
61+
int& returnStatus);
4362
}
4463

4564
#endif

Src/runcpp2/CompilingLinking.cpp

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ namespace
183183
{
184184
ssLOG_ERROR("Setup command \"" << setupStep << "\" failed");
185185
ssLOG_ERROR("Failed with result " << setupResult);
186-
ssLOG_ERROR("Failed with output: " << setupOutput);
186+
ssLOG_ERROR("Failed with output: \n" << setupOutput);
187187
return false;
188188
}
189189
}
@@ -217,7 +217,7 @@ namespace
217217
resultCode != 0)
218218
{
219219
ssLOG_ERROR("Compile command failed with result " << resultCode);
220-
ssLOG_ERROR("Compile output: " << commandOutput);
220+
ssLOG_ERROR("Compile output: \n" << commandOutput);
221221
return false;
222222
}
223223
}
@@ -247,7 +247,7 @@ namespace
247247
{
248248
ssLOG_ERROR("Cleanup command \"" << cleanupStep << "\" failed");
249249
ssLOG_ERROR("Failed with result " << cleanupResult);
250-
ssLOG_ERROR("Failed with output: " << cleanupOutput);
250+
ssLOG_ERROR("Failed with output: \n" << cleanupOutput);
251251
return false;
252252
}
253253
}
@@ -517,7 +517,7 @@ namespace
517517
{
518518
ssLOG_ERROR("Setup command \"" << setupStep << "\" failed");
519519
ssLOG_ERROR("Failed with result " << setupResult);
520-
ssLOG_ERROR("Failed with output: " << setupOutput);
520+
ssLOG_ERROR("Failed with output: \n" << setupOutput);
521521
return false;
522522
}
523523
}
@@ -550,7 +550,7 @@ namespace
550550
resultCode != 0)
551551
{
552552
ssLOG_ERROR("Link command failed with result " << resultCode);
553-
ssLOG_ERROR("Link output: " << linkOutput);
553+
ssLOG_ERROR("Link output: \n" << linkOutput);
554554
return false;
555555
}
556556
}
@@ -580,7 +580,7 @@ namespace
580580
{
581581
ssLOG_ERROR("Cleanup command \"" << cleanupStep << "\" failed");
582582
ssLOG_ERROR("Failed with result " << cleanupResult);
583-
ssLOG_ERROR("Failed with output: " << cleanupOutput);
583+
ssLOG_ERROR("Failed with output: \n" << cleanupOutput);
584584
return false;
585585
}
586586
}
@@ -617,7 +617,7 @@ namespace
617617
{
618618
ssLOG_ERROR("Command \"" << steps.at(i) << "\" failed");
619619
ssLOG_ERROR("Failed with result " << commandResult);
620-
ssLOG_ERROR("Failed with output: " << commandOutput);
620+
ssLOG_ERROR("Failed with output: \n" << commandOutput);
621621
return false;
622622
}
623623
}
@@ -626,6 +626,36 @@ namespace
626626
}
627627
}
628628

629+
bool runcpp2::CompileScriptOnly(const ghc::filesystem::path& buildDir,
630+
const std::string& scriptPath,
631+
const Data::ScriptInfo& scriptInfo,
632+
const std::vector<Data::DependencyInfo*>& availableDependencies,
633+
const Data::Profile& profile,
634+
bool buildExecutable)
635+
{
636+
if(!RunGlobalSteps(buildDir, profile.Setup))
637+
{
638+
ssLOG_ERROR("Failed to run profile global setup steps");
639+
return false;
640+
}
641+
642+
std::string scriptObjectFilePath;
643+
644+
if(!CompileScript( buildDir,
645+
scriptPath,
646+
scriptInfo,
647+
availableDependencies,
648+
profile,
649+
buildExecutable,
650+
scriptObjectFilePath))
651+
{
652+
ssLOG_ERROR("CompileScript failed");
653+
return false;
654+
}
655+
656+
return true;
657+
}
658+
629659
bool runcpp2::CompileAndLinkScript( const ghc::filesystem::path& buildDir,
630660
const std::string& scriptPath,
631661
const Data::ScriptInfo& scriptInfo,

Src/runcpp2/DependenciesHelper.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ namespace
4646
buildDir.string()))
4747
{
4848
ssLOG_ERROR("Failed to run git clone with result: " << returnCode);
49-
ssLOG_ERROR("Output: " << output);
49+
ssLOG_ERROR("Output: \n" << output);
5050
return false;
5151
}
5252
else
53-
ssLOG_INFO("Output: " << output);
53+
ssLOG_INFO("Output: \n" << output);
5454

5555
break;
5656
}
@@ -170,11 +170,11 @@ namespace
170170
processedDependencyPath))
171171
{
172172
ssLOG_ERROR("Failed to run command with result: " << returnCode);
173-
ssLOG_ERROR("Output: " << output);
173+
ssLOG_ERROR("Output: \n" << output);
174174
return false;
175175
}
176176
else
177-
ssLOG_INFO("Output: " << output);
177+
ssLOG_INFO("Output: \n" << output);
178178
}
179179

180180
return true;
@@ -385,12 +385,12 @@ bool runcpp2::CleanupDependencies( const runcpp2::Data::Profile& profile,
385385
return true;
386386
}
387387

388-
bool runcpp2::SetupDependencies(const runcpp2::Data::Profile& profile,
389-
const ghc::filesystem::path& buildDir,
390-
const Data::ScriptInfo& scriptInfo,
391-
std::vector<Data::DependencyInfo*>& availableDependencies,
392-
const std::vector<std::string>& dependenciesLocalCopiesPaths,
393-
const std::vector<std::string>& dependenciesSourcePaths)
388+
bool runcpp2::SetupDependenciesIfNeeded(const runcpp2::Data::Profile& profile,
389+
const ghc::filesystem::path& buildDir,
390+
const Data::ScriptInfo& scriptInfo,
391+
std::vector<Data::DependencyInfo*>& availableDependencies,
392+
const std::vector<std::string>& dependenciesLocalCopiesPaths,
393+
const std::vector<std::string>& dependenciesSourcePaths)
394394
{
395395
ssLOG_FUNC_DEBUG();
396396

Src/runcpp2/PlatformUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ bool runcpp2::RunCommandAndGetOutput( const std::string& command,
122122
if(outReturnCode != 0)
123123
{
124124
ssLOG_DEBUG("Failed when running command");
125-
ssLOG_DEBUG("outOutput: " << outOutput.c_str());
125+
ssLOG_DEBUG("outOutput: \n" << outOutput.c_str());
126126
return false;
127127
}
128128

0 commit comments

Comments
 (0)