99#include < string>
1010#include < vector>
1111
12+ #include < boost/algorithm/cxx11/none_of.hpp>
13+
1214#include " _default.hpp"
15+ #include " absl/strings/match.h"
1316#include " input_parser.hpp"
1417#include " logger.hpp"
1518
@@ -50,7 +53,7 @@ namespace {
5053 if (path.empty ()) {
5154 return " \"\" " ;
5255 }
53- if (path. find ( ' ' ) != std::string::npos ) {
56+ if (absl::StrContains (path, ' ' )) {
5457 return " \" " + path + " \" " ;
5558 }
5659 return path;
@@ -60,16 +63,16 @@ namespace {
6063 * @brief Compile generated IR to binary
6164 */
6265 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;
6669
67- if (!fs::exists (ll_file )) {
70+ if (!fs::exists (LL_FILE )) {
6871 LOG_ERROR (" IR code not found" );
6972 return false ;
7073 }
7174
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 );
7376
7477 LOG_INFO (" Optimizing code..." );
7578
@@ -80,12 +83,12 @@ namespace {
8083 return false ;
8184 }
8285
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 ) {
8487 LOG_ERROR (" Optimized IR code not created" );
8588 return false ;
8689 }
8790
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);
8992
9093 LOG_INFO (" Compiling optimized code..." );
9194
@@ -148,8 +151,7 @@ namespace {
148151 }
149152
150153 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); });
153155 }
154156} // namespace
155157
@@ -166,6 +168,7 @@ auto main(int argc, char** argv) -> int {
166168 // Register command line options
167169 parser.add_option ({" -v" , " --version" , " Get version" , false , " " });
168170 parser.add_option ({" -h" , " --help" , " Print this help message" , false , " " });
171+ parser.add_option ({" -c" , " --check-utils-available" , " Check required utils" , false , " " });
169172
170173 // Parse command line
171174 if (!parser.parse (argc, argv)) {
@@ -176,6 +179,16 @@ auto main(int argc, char** argv) -> int {
176179 return 1 ;
177180 }
178181
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+
179192 if (parser.has_option (" -v" )) {
180193 LOG_INFO (" Version: %s" , VERSION);
181194 return 0 ;
0 commit comments