Skip to content

Commit 7d5b578

Browse files
Output dependencies clone progress
1 parent 90c23c0 commit 7d5b578

File tree

6 files changed

+90
-79
lines changed

6 files changed

+90
-79
lines changed

Include/runcpp2/PlatformUtil.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ namespace runcpp2
2929

3030
std::vector<std::string> GetPlatformNames();
3131

32-
bool RunCommandAndGetOutput(const std::string& command,
33-
std::string& outOutput,
34-
std::string runDirectory = "");
35-
36-
bool RunCommandAndGetOutput(const std::string& command,
37-
std::string& outOutput,
38-
int& outReturnCode,
39-
std::string runDirectory = "");
32+
bool RunCommand(const std::string& command,
33+
const bool& captureOutput,
34+
const std::string& runDirectory,
35+
std::string& outOutput,
36+
int& outReturnCode);
4037

4138
#if defined(_WIN32)
4239
std::string GetWindowsError();

Src/runcpp2/CompilingLinking.cpp

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,11 @@ namespace
337337

338338
std::string setupOutput;
339339
int setupResult;
340-
341-
if( !runcpp2::RunCommandAndGetOutput( setupStep,
342-
setupOutput,
343-
setupResult,
344-
buildDir.string()) ||
340+
if( !runcpp2::RunCommand( setupStep,
341+
true,
342+
buildDir.string(),
343+
setupOutput,
344+
setupResult) ||
345345
setupResult != 0)
346346
{
347347
ssLOG_ERROR("Setup command \"" << setupStep << "\" failed");
@@ -375,10 +375,12 @@ namespace
375375

376376
std::string commandOutput;
377377
int resultCode = 0;
378-
if( !runcpp2::RunCommandAndGetOutput( compileCommand,
379-
commandOutput,
380-
resultCode,
381-
buildDir.string()) ||
378+
379+
if( !runcpp2::RunCommand( compileCommand,
380+
true,
381+
buildDir.string(),
382+
commandOutput,
383+
resultCode) ||
382384
resultCode != 0)
383385
{
384386
ssLOG_ERROR("Compile command failed with result " << resultCode);
@@ -413,10 +415,11 @@ namespace
413415
std::string cleanupOutput;
414416
int cleanupResult;
415417

416-
if( !runcpp2::RunCommandAndGetOutput( cleanupStep,
417-
cleanupOutput,
418-
cleanupResult,
419-
buildDir.string()) ||
418+
if( !runcpp2::RunCommand( cleanupStep,
419+
true,
420+
buildDir.string(),
421+
cleanupOutput,
422+
cleanupResult) ||
420423
cleanupResult != 0)
421424
{
422425
ssLOG_ERROR("Cleanup command \"" << cleanupStep << "\" failed");
@@ -708,10 +711,11 @@ namespace
708711
std::string setupOutput;
709712
int setupResult;
710713

711-
if( !runcpp2::RunCommandAndGetOutput( setupStep,
712-
setupOutput,
713-
setupResult,
714-
buildDir.string()) ||
714+
if( !runcpp2::RunCommand( setupStep,
715+
true,
716+
buildDir.string(),
717+
setupOutput,
718+
setupResult) ||
715719
setupResult != 0)
716720
{
717721
ssLOG_ERROR("Setup command \"" << setupStep << "\" failed");
@@ -744,10 +748,12 @@ namespace
744748
ssLOG_INFO("running link command: " << linkCommand << " in " << buildDir.string());
745749
std::string linkOutput;
746750
int resultCode = 0;
747-
if( !runcpp2::RunCommandAndGetOutput( linkCommand,
748-
linkOutput,
749-
resultCode,
750-
buildDir.string()) ||
751+
752+
if( !runcpp2::RunCommand( linkCommand,
753+
true,
754+
buildDir.string(),
755+
linkOutput,
756+
resultCode) ||
751757
resultCode != 0)
752758
{
753759
ssLOG_ERROR("Link command failed with result " << resultCode);
@@ -775,10 +781,11 @@ namespace
775781
std::string cleanupOutput;
776782
int cleanupResult;
777783

778-
if( !runcpp2::RunCommandAndGetOutput( cleanupStep,
779-
cleanupOutput,
780-
cleanupResult,
781-
buildDir.string()) ||
784+
if( !runcpp2::RunCommand( cleanupStep,
785+
true,
786+
buildDir.string(),
787+
cleanupOutput,
788+
cleanupResult) ||
782789
cleanupResult != 0)
783790
{
784791
ssLOG_ERROR("Cleanup command \"" << cleanupStep << "\" failed");
@@ -812,10 +819,11 @@ namespace
812819
std::string commandOutput;
813820
int commandResult = 0;
814821

815-
if( !runcpp2::RunCommandAndGetOutput( steps.at(i),
816-
commandOutput,
817-
commandResult,
818-
buildDir.string()) ||
822+
if( !runcpp2::RunCommand( steps.at(i),
823+
true,
824+
buildDir.string(),
825+
commandOutput,
826+
commandResult) ||
819827
commandResult != 0)
820828
{
821829
ssLOG_ERROR("Command \"" << steps.at(i) << "\" failed");

Src/runcpp2/DependenciesHelper.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,18 @@ namespace
122122

123123
int returnCode = 0;
124124
std::string output;
125-
if(!runcpp2::RunCommandAndGetOutput(gitCloneCommand,
126-
output,
127-
returnCode,
128-
buildDir.string()))
125+
if(!runcpp2::RunCommand(gitCloneCommand,
126+
false,
127+
buildDir.string(),
128+
output,
129+
returnCode))
129130
{
130131
ssLOG_ERROR("Failed to run git clone with result: " << returnCode);
131-
ssLOG_ERROR("Output: \n" << output);
132+
//ssLOG_ERROR("Output: \n" << output);
132133
return false;
133134
}
134-
else
135-
ssLOG_INFO("Output: \n" << output);
135+
//else
136+
// ssLOG_INFO("Output: \n" << output);
136137
}
137138
else if(mpark::get_if<runcpp2::Data::LocalSource>(&(dependency.Source.Source)))
138139
{
@@ -257,10 +258,12 @@ namespace
257258

258259
int returnCode = 0;
259260
std::string output;
260-
if(!runcpp2::RunCommandAndGetOutput(commands->at(k),
261-
output,
262-
returnCode,
263-
processedDependencyPath))
261+
262+
if(!runcpp2::RunCommand(commands->at(k),
263+
true,
264+
processedDependencyPath,
265+
output,
266+
returnCode))
264267
{
265268
ssLOG_ERROR("Failed to run command with result: " << returnCode);
266269
ssLOG_ERROR("Output: \n" << output);

Src/runcpp2/PipelineSteps.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ runcpp2::RunProfileCommands(const Data::ProfilesCommands* commands,
240240
{
241241
std::string output;
242242
int returnCode = 0;
243-
if(!runcpp2::RunCommandAndGetOutput(cmd, output, returnCode, workingDir))
243+
244+
if(!runcpp2::RunCommand(cmd, true, workingDir, output, returnCode))
244245
{
245246
ssLOG_ERROR(commandType << " command failed: " << cmd <<
246247
" with return code " << returnCode);
@@ -404,7 +405,8 @@ runcpp2::PipelineResult runcpp2::HandleCleanup( const Data::ScriptInfo& scriptIn
404405
{
405406
std::string output;
406407
int returnCode = 0;
407-
if(!runcpp2::RunCommandAndGetOutput(cmd, output, returnCode, scriptDirectory))
408+
409+
if(!runcpp2::RunCommand(cmd, true, scriptDirectory, output, returnCode))
408410
{
409411
ssLOG_ERROR("Cleanup command failed: " << cmd <<
410412
" with return code " << returnCode);

Src/runcpp2/PlatformUtil.cpp

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,19 @@ std::vector<std::string> runcpp2::GetPlatformNames()
6969
#endif
7070
}
7171

72-
bool runcpp2::RunCommandAndGetOutput( const std::string& command,
73-
std::string& outOutput,
74-
std::string runDirectory)
75-
{
76-
int returnCode;
77-
return RunCommandAndGetOutput(command, outOutput, returnCode, runDirectory);
78-
}
79-
80-
bool runcpp2::RunCommandAndGetOutput( const std::string& command,
81-
std::string& outOutput,
82-
int& outReturnCode,
83-
std::string runDirectory)
72+
bool runcpp2::RunCommand( const std::string& command,
73+
const bool& captureOutput,
74+
const std::string& runDirectory,
75+
std::string& outOutput,
76+
int& outReturnCode)
8477
{
8578
ssLOG_FUNC_DEBUG();
8679
ssLOG_DEBUG("Running: " << command);
8780
System2CommandInfo commandInfo = {};
8881
if(!runDirectory.empty())
8982
commandInfo.RunDirectory = runDirectory.c_str();
9083

91-
commandInfo.RedirectOutput = true;
84+
commandInfo.RedirectOutput = captureOutput;
9285
SYSTEM2_RESULT sys2Result = System2Run(command.c_str(), &commandInfo);
9386

9487
if(sys2Result != SYSTEM2_RESULT_SUCCESS)
@@ -98,20 +91,23 @@ bool runcpp2::RunCommandAndGetOutput( const std::string& command,
9891
}
9992
outOutput.clear();
10093

101-
do
94+
if(captureOutput)
10295
{
103-
uint32_t byteRead = 0;
104-
outOutput.resize(outOutput.size() + 4096);
105-
106-
sys2Result =
107-
System2ReadFromOutput( &commandInfo,
108-
const_cast<char*>(outOutput.data()) + outOutput.size() - 4096,
109-
4096,
110-
&byteRead);
96+
do
97+
{
98+
uint32_t byteRead = 0;
99+
outOutput.resize(outOutput.size() + 4096);
100+
101+
sys2Result =
102+
System2ReadFromOutput( &commandInfo,
103+
const_cast<char*>(outOutput.data()) + outOutput.size() - 4096,
104+
4096,
105+
&byteRead);
111106

112-
outOutput.resize(outOutput.size() + byteRead);
107+
outOutput.resize(outOutput.size() + byteRead);
108+
}
109+
while(sys2Result == SYSTEM2_RESULT_READ_NOT_FINISHED);
113110
}
114-
while(sys2Result == SYSTEM2_RESULT_READ_NOT_FINISHED);
115111

116112
sys2Result = System2GetCommandReturnValueSync(&commandInfo, &outReturnCode, false);
117113
if(sys2Result != SYSTEM2_RESULT_SUCCESS)
@@ -120,7 +116,8 @@ bool runcpp2::RunCommandAndGetOutput( const std::string& command,
120116
return false;
121117
}
122118

123-
ssLOG_DEBUG("outOutput: \n" << outOutput.c_str());
119+
if(captureOutput)
120+
ssLOG_DEBUG("outOutput: \n" << outOutput.c_str());
124121

125122
if(outReturnCode != 0)
126123
{

Src/runcpp2/ProfileHelper.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ namespace
3333
for(int i = 0; i < cleanupSteps.size(); ++i)
3434
{
3535
std::string output;
36-
if(!runcpp2::RunCommandAndGetOutput(cleanupSteps.at(i), output))
36+
int resultCode;
37+
if(!runcpp2::RunCommand(cleanupSteps.at(i), true, "", output, resultCode))
3738
{
3839
ssLOG_INFO("Failed to run cleanup for " << profile.Name);
3940
return false;
@@ -53,7 +54,8 @@ namespace
5354
for(int i = 0; i < setupSteps.size(); ++i)
5455
{
5556
std::string output;
56-
if(!runcpp2::RunCommandAndGetOutput(setupSteps.at(i), output))
57+
int resultCode;
58+
if(!runcpp2::RunCommand(setupSteps.at(i), true, "", output, resultCode))
5759
{
5860
ssLOG_INFO("Failed to run setup for " << profile.Name);
5961
runCleanup();
@@ -77,7 +79,8 @@ namespace
7779
command += *runcpp2::GetValueFromPlatformMap(profile.Compiler.CheckExistence);
7880

7981
std::string output;
80-
if(!runcpp2::RunCommandAndGetOutput(command, output))
82+
int returnCode;
83+
if(!runcpp2::RunCommand(command, true, "", output, returnCode))
8184
{
8285
ssLOG_INFO("Failed to find compiler for profile " << profile.Name);
8386
runCleanup();
@@ -100,7 +103,8 @@ namespace
100103
command += *runcpp2::GetValueFromPlatformMap(profile.Linker.CheckExistence);
101104

102105
std::string output;
103-
if(!runcpp2::RunCommandAndGetOutput(command, output))
106+
int returnCode;
107+
if(!runcpp2::RunCommand(command, true, "", output, returnCode))
104108
{
105109
ssLOG_INFO("Failed to find linker for profile " << profile.Name);
106110
runCleanup();

0 commit comments

Comments
 (0)