7
7
#include " tasks/ShellExecTask.h"
8
8
#include " utils/CollectionUtils.h"
9
9
#include " utils/StringUtils.h"
10
+ #include " utils/path/FileSystemPath.h"
10
11
11
12
#include " loguru.h"
12
13
13
14
#include < algorithm>
14
- #include " utils/path/FileSystemPath.h"
15
15
#include < iterator>
16
16
#include < set>
17
17
#include < utility>
@@ -20,26 +20,36 @@ namespace utbot {
20
20
BaseCommand::BaseCommand (std::list<std::string> commandLine, fs::path directory, bool shouldChangeDirectory)
21
21
: commandLine(std::move(commandLine)), directory(std::move(directory)), shouldChangeDirectory{shouldChangeDirectory} {
22
22
initOptimizationLevel ();
23
+ initCompiler ();
24
+ initOutput ();
23
25
}
24
26
BaseCommand::BaseCommand (std::vector<std::string> commandLine, fs::path directory, bool shouldChangeDirectory)
25
27
: commandLine(commandLine.begin(), commandLine.end()), directory(std::move(directory)), shouldChangeDirectory{shouldChangeDirectory} {
26
28
initOptimizationLevel ();
29
+ initCompiler ();
30
+ initOutput ();
27
31
}
28
32
29
33
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) {
32
38
if (other.optimizationLevel .has_value ()) {
33
39
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 ()));
37
43
}
38
44
}
45
+
39
46
BaseCommand::BaseCommand (BaseCommand &&other) noexcept
40
47
: directory(std::move(other.directory)), commandLine(std::move(other.commandLine)),
41
48
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) {
43
53
}
44
54
45
55
void BaseCommand::initOptimizationLevel () {
@@ -48,6 +58,19 @@ namespace utbot {
48
58
optimizationLevel = it;
49
59
}
50
60
}
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
+
51
74
BaseCommand::iterator BaseCommand::findOutput () {
52
75
auto it = std::find (commandLine.begin (), commandLine.end (), " -o" );
53
76
if (it != commandLine.end ()) {
@@ -127,4 +150,20 @@ namespace utbot {
127
150
optimizationLevel = addFlagToBegin (flag);
128
151
}
129
152
}
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
+ }
130
169
}
0 commit comments