77#include  " tasks/ShellExecTask.h" 
88#include  " utils/CollectionUtils.h" 
99#include  " utils/StringUtils.h" 
10+ #include  " utils/path/FileSystemPath.h" 
1011
1112#include  " loguru.h" 
1213
1314#include  < algorithm> 
14- #include  " utils/path/FileSystemPath.h" 
1515#include  < iterator> 
1616#include  < set> 
1717#include  < utility> 
@@ -20,26 +20,36 @@ namespace utbot {
2020    BaseCommand::BaseCommand (std::list<std::string> commandLine, fs::path directory, bool  shouldChangeDirectory)
2121        : commandLine(std::move(commandLine)), directory(std::move(directory)), shouldChangeDirectory{shouldChangeDirectory} {
2222        initOptimizationLevel ();
23+         initCompiler ();
24+         initOutput ();
2325    }
2426    BaseCommand::BaseCommand (std::vector<std::string> commandLine, fs::path directory, bool  shouldChangeDirectory)
2527        : commandLine(commandLine.begin(), commandLine.end()), directory(std::move(directory)), shouldChangeDirectory{shouldChangeDirectory} {
2628        initOptimizationLevel ();
29+         initCompiler ();
30+         initOutput ();
2731    }
2832
2933    BaseCommand::BaseCommand (BaseCommand const  &other)
30-         : directory(other.directory), commandLine(other.commandLine),
31-           environmentVariables (other.environmentVariables), shouldChangeDirectory(other.shouldChangeDirectory) {
34+             : directory(other.directory), commandLine(other.commandLine),
35+               environmentVariables (other.environmentVariables), shouldChangeDirectory(other.shouldChangeDirectory),
36+               compiler(other.compiler),
37+               output(other.output) {
3238        if  (other.optimizationLevel .has_value ()) {
3339            optimizationLevel =
34-                 std::next (commandLine.begin (),
35-                           std::distance<const_iterator>(other.commandLine .begin (),
36-                                                         other.optimizationLevel .value ()));
40+                      std::next (commandLine.begin (),
41+                                std::distance<const_iterator>(other.commandLine .begin (),
42+                                                              other.optimizationLevel .value ()));
3743        }
3844    }
45+ 
3946    BaseCommand::BaseCommand (BaseCommand &&other) noexcept 
4047        : directory(std::move(other.directory)), commandLine(std::move(other.commandLine)),
4148          environmentVariables(std::move(other.environmentVariables)),
42-           optimizationLevel(other.optimizationLevel), shouldChangeDirectory(other.shouldChangeDirectory) {
49+           optimizationLevel(other.optimizationLevel),
50+           compiler(other.compiler),
51+           output(other.output),
52+           shouldChangeDirectory(other.shouldChangeDirectory) {
4353    }
4454
4555    void  BaseCommand::initOptimizationLevel () {
@@ -48,6 +58,19 @@ namespace utbot {
4858            optimizationLevel = it;
4959        }
5060    }
61+ 
62+     void  BaseCommand::initCompiler () {
63+         auto  it = commandLine.begin ();
64+         compiler = it;
65+     }
66+ 
67+     void  BaseCommand::initOutput () {
68+         auto  it = findOutput ();
69+         if  (it != commandLine.end ()) {
70+             output = it;
71+         }
72+     }
73+ 
5174    BaseCommand::iterator BaseCommand::findOutput () {
5275        auto  it = std::find (commandLine.begin (), commandLine.end (), " -o" 
5376        if  (it != commandLine.end ()) {
@@ -127,4 +150,20 @@ namespace utbot {
127150            optimizationLevel = addFlagToBegin (flag);
128151        }
129152    }
153+ 
154+     fs::path BaseCommand::getCompiler () const  {
155+         return  *compiler;
156+     }
157+ 
158+     void  BaseCommand::setCompiler (fs::path compiler) {
159+         *(this ->compiler ) = std::move (compiler);
160+     }
161+ 
162+     fs::path BaseCommand::getOutput () const  {
163+         return  *output;
164+     }
165+ 
166+     void  BaseCommand::setOutput (fs::path output) {
167+         *(this ->output ) = std::move (output);
168+     }
130169}
0 commit comments