18
18
#include < util/file_util.h>
19
19
#include < util/irep_ids.h>
20
20
#include < util/parse_options.h>
21
+ #include < util/string_join.h>
21
22
#include < util/ui_message.h>
22
23
#include < utility>
23
24
#include < utils.h>
@@ -304,30 +305,37 @@ int cmdline_optionst::doit()
304
305
}
305
306
if (!cmdline.isset (" configuration-path" ))
306
307
{
307
- msg.error () << " Please set --configuration-path to a valid configuration "
308
- " file."
308
+ msg.error () << " --configuration-path wasn't provided. "
309
+ " Use it to provide a valid configuration file."
309
310
<< messaget::eom;
310
311
return -1 ;
311
312
}
312
313
313
- boost::filesystem::path config_path = cmdline.get_value (" configuration-path" );
314
+ std::string config_path = cmdline.get_value (" configuration-path" );
315
+ if (config_path.empty ())
316
+ {
317
+ msg.error () << " --configuration-path was empty. "
318
+ " Use it to provide a valid configuration file."
319
+ << messaget::eom;
320
+ return -1 ;
321
+ }
314
322
jsont config_json;
315
- if (parse_json (config_path. string () , ui_message_handler, config_json))
323
+ if (parse_json (config_path, ui_message_handler, config_json))
316
324
{
317
325
msg.error () << " ERROR: The input file '" << config_path
318
326
<< " ' is not a valid JSON file." << messaget::eom;
319
327
return -3 ;
320
328
}
321
329
322
330
generation_configurationt config = generation_configurationt (config_json);
323
- const std::string in_json_pathname = config.collected_classes_path ;
324
- if (! boost::filesystem::is_regular_file (in_json_pathname) )
331
+ optionalt< std::vector<std:: string>> parse_errors = config.get_parse_errors () ;
332
+ if (parse_errors )
325
333
{
326
- msg.error ()
327
- << " ERROR: The input file '" << in_json_pathname
328
- << " ' does not exist." << messaget::eom;
334
+ msg.error () << " ERROR: " << join (*parse_errors, " \n " ) << messaget::eom;
329
335
return -2 ;
330
336
}
337
+
338
+ const std::string &in_json_pathname = config.collected_classes_path ;
331
339
jsont cfg;
332
340
if (parse_json (in_json_pathname, ui_message_handler, cfg))
333
341
{
@@ -345,21 +353,9 @@ int cmdline_optionst::doit()
345
353
<< " class files)." << messaget::eom;
346
354
return -4 ;
347
355
}
348
- if (config.collected_classes_info_path .empty ())
349
- {
350
- msg.status () << " ERROR: collected_classes_info_path is empty." ;
351
- return -5 ;
352
- }
353
- const std::string out_json_pathname = config.collected_classes_info_path ;
354
- if (boost::filesystem::is_directory (out_json_pathname))
355
- {
356
- msg.error ()
357
- << " ERROR: The output path '" << out_json_pathname
358
- << " ' references an existing directory." << messaget::eom;
359
- return -6 ;
360
- }
356
+ const std::string &out_json_pathname = config.collected_classes_info_path ;
361
357
362
- const std::string di_out_path = config.di_configuration_path ;
358
+ const std::string & di_out_path = config.di_configuration_path ;
363
359
bool enable_di_scan = !di_out_path.empty ();
364
360
json_objectt results;
365
361
json_arrayt errors;
@@ -605,21 +601,7 @@ int cmdline_optionst::doit()
605
601
606
602
if (ep_generator.enabled ())
607
603
{
608
- const std::string detected_ep_path = config.detected_entry_points_path ;
609
-
610
- if (detected_ep_path.empty ())
611
- {
612
- msg.status () << " ERROR: collected_classes_info_path is empty." ;
613
- return -9 ;
614
- }
615
- if (boost::filesystem::is_directory (detected_ep_path))
616
- {
617
- msg.error ()
618
- << " ERROR: The output path '" << detected_ep_path
619
- << " ' references an existing directory." << messaget::eom;
620
- return -10 ;
621
- }
622
-
604
+ const std::string &detected_ep_path = config.detected_entry_points_path ;
623
605
std::ofstream epp_file (detected_ep_path);
624
606
if (!epp_file)
625
607
{
0 commit comments