|
4 | 4 | #include "ssLogger/ssLog.hpp" |
5 | 5 | #include "System2.h" |
6 | 6 |
|
7 | | -namespace |
| 7 | +namespace |
8 | 8 | { |
9 | | - |
10 | 9 | bool IsProfileAvailableOnSystem(const runcpp2::Data::Profile& profile) |
11 | 10 | { |
12 | 11 | //Check compiler |
13 | | - std::string command = profile.Compiler.Executable + " -v"; |
14 | | - |
15 | | - System2CommandInfo compilerCommandInfo = {}; |
16 | | - compilerCommandInfo.RedirectOutput = true; |
17 | | - SYSTEM2_RESULT sys2Result = System2Run(command.c_str(), &compilerCommandInfo); |
18 | | - |
19 | | - if(sys2Result != SYSTEM2_RESULT_SUCCESS) |
20 | 12 | { |
21 | | - ssLOG_ERROR("System2Run failed with result: " << sys2Result); |
22 | | - return false; |
23 | | - } |
24 | | - |
25 | | - int returnCode = 0; |
26 | | - sys2Result = System2GetCommandReturnValueSync(&compilerCommandInfo, &returnCode); |
27 | | - if(sys2Result != SYSTEM2_RESULT_SUCCESS) |
28 | | - { |
29 | | - ssLOG_ERROR("System2GetCommandReturnValueSync failed with result: " << sys2Result); |
30 | | - return false; |
| 13 | + //Getting EnvironmentSetup command |
| 14 | + std::string command; |
| 15 | + { |
| 16 | + command = runcpp2::HasValueFromPlatformMap(profile.Compiler.EnvironmentSetup) ? |
| 17 | + *runcpp2::GetValueFromPlatformMap(profile.Compiler.EnvironmentSetup) : ""; |
| 18 | + |
| 19 | + if(!command.empty()) |
| 20 | + command += " && "; |
| 21 | + } |
| 22 | + |
| 23 | + command += profile.Compiler.Executable + " -v"; |
| 24 | + System2CommandInfo compilerCommandInfo = {}; |
| 25 | + compilerCommandInfo.RedirectOutput = true; |
| 26 | + SYSTEM2_RESULT sys2Result = System2Run(command.c_str(), &compilerCommandInfo); |
| 27 | + |
| 28 | + if(sys2Result != SYSTEM2_RESULT_SUCCESS) |
| 29 | + { |
| 30 | + ssLOG_ERROR("System2Run failed with result: " << sys2Result); |
| 31 | + return false; |
| 32 | + } |
| 33 | + |
| 34 | + int returnCode = 0; |
| 35 | + sys2Result = System2GetCommandReturnValueSync(&compilerCommandInfo, &returnCode); |
| 36 | + if(sys2Result != SYSTEM2_RESULT_SUCCESS) |
| 37 | + { |
| 38 | + ssLOG_ERROR("System2GetCommandReturnValueSync failed with result: " << sys2Result); |
| 39 | + return false; |
| 40 | + } |
| 41 | + |
| 42 | + if(returnCode != 0) |
| 43 | + return false; |
31 | 44 | } |
32 | 45 |
|
33 | | - if(returnCode != 0) |
34 | | - return false; |
35 | | - |
36 | 46 | //Check linker |
37 | | - command = profile.Linker.Executable + " -v"; |
38 | | - |
39 | | - System2CommandInfo linkerCommandInfo = {}; |
40 | | - linkerCommandInfo.RedirectOutput = true; |
41 | | - sys2Result = System2Run(command.c_str(), &linkerCommandInfo); |
42 | | - |
43 | | - if(sys2Result != SYSTEM2_RESULT_SUCCESS) |
44 | | - { |
45 | | - ssLOG_ERROR("System2Run failed with result: " << sys2Result); |
46 | | - return false; |
47 | | - } |
48 | | - |
49 | | - returnCode = 0; |
50 | | - sys2Result = System2GetCommandReturnValueSync(&linkerCommandInfo, &returnCode); |
51 | | - if(sys2Result != SYSTEM2_RESULT_SUCCESS) |
52 | 47 | { |
53 | | - ssLOG_ERROR("System2GetCommandReturnValueSync failed with result: " << sys2Result); |
54 | | - return false; |
| 48 | + //Getting EnvironmentSetup command |
| 49 | + std::string command; |
| 50 | + { |
| 51 | + command = runcpp2::HasValueFromPlatformMap(profile.Compiler.EnvironmentSetup) ? |
| 52 | + *runcpp2::GetValueFromPlatformMap(profile.Compiler.EnvironmentSetup) : ""; |
| 53 | + |
| 54 | + if(!command.empty()) |
| 55 | + command += " && "; |
| 56 | + } |
| 57 | + |
| 58 | + command += profile.Linker.Executable + " -v"; |
| 59 | + System2CommandInfo linkerCommandInfo = {}; |
| 60 | + linkerCommandInfo.RedirectOutput = true; |
| 61 | + SYSTEM2_RESULT sys2Result = System2Run(command.c_str(), &linkerCommandInfo); |
| 62 | + |
| 63 | + if(sys2Result != SYSTEM2_RESULT_SUCCESS) |
| 64 | + { |
| 65 | + ssLOG_ERROR("System2Run failed with result: " << sys2Result); |
| 66 | + return false; |
| 67 | + } |
| 68 | + |
| 69 | + int returnCode = 0; |
| 70 | + sys2Result = System2GetCommandReturnValueSync(&linkerCommandInfo, &returnCode); |
| 71 | + if(sys2Result != SYSTEM2_RESULT_SUCCESS) |
| 72 | + { |
| 73 | + ssLOG_ERROR("System2GetCommandReturnValueSync failed with result: " << sys2Result); |
| 74 | + return false; |
| 75 | + } |
| 76 | + |
| 77 | + if(returnCode != 0) |
| 78 | + return false; |
55 | 79 | } |
56 | | - |
57 | | - if(returnCode != 0) |
58 | | - return false; |
59 | 80 |
|
60 | 81 | return true; |
61 | 82 | } |
|
0 commit comments