9
9
#include < string>
10
10
#include < vector>
11
11
12
+ #include < boost/algorithm/cxx11/none_of.hpp>
13
+
12
14
#include " _default.hpp"
15
+ #include " absl/strings/match.h"
13
16
#include " input_parser.hpp"
14
17
#include " logger.hpp"
15
18
@@ -50,7 +53,7 @@ namespace {
50
53
if (path.empty ()) {
51
54
return " \"\" " ;
52
55
}
53
- if (path. find ( ' ' ) != std::string::npos ) {
56
+ if (absl::StrContains (path, ' ' )) {
54
57
return " \" " + path + " \" " ;
55
58
}
56
59
return path;
@@ -60,16 +63,16 @@ namespace {
60
63
* @brief Compile generated IR to binary
61
64
*/
62
65
auto compile_ir (const std::string& output_base) -> bool {
63
- const std::string ll_file = output_base + " .ll" ;
64
- const std::string opt_ll_file = output_base + " -opt.ll" ;
65
- const std::string bin_file = output_base;
66
+ const std::string LL_FILE = output_base + " .ll" ;
67
+ const std::string OPT_LL_FILE = output_base + " -opt.ll" ;
68
+ const std::string& bin_file = output_base;
66
69
67
- if (!fs::exists (ll_file )) {
70
+ if (!fs::exists (LL_FILE )) {
68
71
LOG_ERROR (" IR code not found" );
69
72
return false ;
70
73
}
71
74
72
- std::string opt_cmd = " opt " + safe_path (ll_file ) + " -O3 -S -o " + safe_path (opt_ll_file );
75
+ std::string opt_cmd = " opt " + safe_path (LL_FILE ) + " -O3 -S -o " + safe_path (OPT_LL_FILE );
73
76
74
77
LOG_INFO (" Optimizing code..." );
75
78
@@ -80,12 +83,12 @@ namespace {
80
83
return false ;
81
84
}
82
85
83
- if (!fs::exists (opt_ll_file ) || fs::file_size (opt_ll_file ) == 0 ) {
86
+ if (!fs::exists (OPT_LL_FILE ) || fs::file_size (OPT_LL_FILE ) == 0 ) {
84
87
LOG_ERROR (" Optimized IR code not created" );
85
88
return false ;
86
89
}
87
90
88
- std::string clang_cmd = " clang++ -O3 " + safe_path (opt_ll_file ) + " -o " + safe_path (bin_file);
91
+ std::string clang_cmd = " clang++ -O3 " + safe_path (OPT_LL_FILE ) + " -o " + safe_path (bin_file);
89
92
90
93
LOG_INFO (" Compiling optimized code..." );
91
94
@@ -148,8 +151,7 @@ namespace {
148
151
}
149
152
150
153
const std::string FORBIDDEN_CHARS = " /\\ :*?\" <>|" ;
151
- return std::none_of (
152
- name.begin (), name.end (), [&](char c) { return FORBIDDEN_CHARS.find (c) != std::string::npos; });
154
+ return boost::algorithm::none_of (name, [&](char c) { return absl::StrContains (FORBIDDEN_CHARS, c); });
153
155
}
154
156
} // namespace
155
157
@@ -166,6 +168,7 @@ auto main(int argc, char** argv) -> int {
166
168
// Register command line options
167
169
parser.add_option ({" -v" , " --version" , " Get version" , false , " " });
168
170
parser.add_option ({" -h" , " --help" , " Print this help message" , false , " " });
171
+ parser.add_option ({" -c" , " --check-utils-available" , " Check required utils" , false , " " });
169
172
170
173
// Parse command line
171
174
if (!parser.parse (argc, argv)) {
@@ -176,6 +179,16 @@ auto main(int argc, char** argv) -> int {
176
179
return 1 ;
177
180
}
178
181
182
+ if (parser.has_option (" -c" )) {
183
+ if (!check_utils_available ()) {
184
+ LOG_ERROR (" Utils not available. You installed clang++ and opt?" );
185
+ return 1 ;
186
+ }
187
+
188
+ LOG_INFO (" All utils available!" );
189
+ return 0 ;
190
+ }
191
+
179
192
if (parser.has_option (" -v" )) {
180
193
LOG_INFO (" Version: %s" , VERSION);
181
194
return 0 ;
0 commit comments