@@ -232,7 +232,8 @@ def add_arguments_to_parser(parser):
232232 parser .add_argument ('--dump-compiler-info-file' ,
233233 dest = "dump_compiler_info_file" ,
234234 required = False ,
235- default = argparse .SUPPRESS ,
235+ action = 'store_true' ,
236+ default = False ,
236237 help = "Dump implicit gcc compiler info to a json file "
237238 "that can be used for fine-tuning analysis later."
238239 "These are information like the implicit include "
@@ -1264,7 +1265,8 @@ def main(args):
12641265
12651266 args .output_path = os .path .abspath (args .output_path )
12661267 if os .path .exists (args .output_path ) and \
1267- not os .path .isdir (args .output_path ):
1268+ not os .path .isdir (args .output_path ) and \
1269+ not args .dump_compiler_info_file :
12681270 LOG .error ("The given output path is not a directory: " +
12691271 args .output_path )
12701272 sys .exit (1 )
@@ -1352,20 +1354,15 @@ def main(args):
13521354 "overwriting with current result" , args .output_path )
13531355 shutil .rmtree (args .output_path )
13541356
1355- if not os .path .exists (args .output_path ):
1357+ if not os .path .exists (args .output_path ) and \
1358+ not args .dump_compiler_info_file :
13561359 os .makedirs (args .output_path )
13571360
1358- # TODO: I'm not sure that this directory should be created here.
1359- fixit_dir = os .path .join (args .output_path , 'fixit' )
1360- if not os .path .exists (fixit_dir ):
1361- os .makedirs (fixit_dir )
1362-
13631361 LOG .debug ("args: %s" , str (args ))
13641362 LOG .debug ("Output will be stored to: '%s'" , args .output_path )
13651363
13661364 actions , skipped_cmp_cmd_count = log_parser .parse_unique_log (
13671365 compile_commands ,
1368- args .output_path ,
13691366 args .compile_uniqueing ,
13701367 compiler_info_file ,
13711368 args .keep_gcc_include_fixed ,
@@ -1381,16 +1378,18 @@ def main(args):
13811378 "compilation database or all of them were skipped." )
13821379 sys .exit (0 )
13831380
1384- if 'dump_compiler_info_file' in args and args .dump_compiler_info_file :
1385- compiler_info = Path (args .output_path ) / 'compiler_info.json'
1386- try :
1387- os .rename (
1388- compiler_info ,
1389- compiler_info .with_name (args .dump_compiler_info_file ))
1390- except ValueError as err :
1391- LOG .error (err )
1392- LOG .error ("Provide a single filename." )
1381+ if args .dump_compiler_info_file :
1382+ log_parser .ImplicitCompilerInfo .dump_compiler_info (
1383+ args .output_path )
13931384 sys .exit (0 )
1385+ else :
1386+ log_parser .ImplicitCompilerInfo .dump_compiler_info (
1387+ Path (args .output_path ) / "compiler_info.json" )
1388+
1389+ # TODO: I'm not sure that this directory should be created here.
1390+ fixit_dir = os .path .join (args .output_path , 'fixit' )
1391+ if not os .path .exists (fixit_dir ):
1392+ os .makedirs (fixit_dir )
13941393
13951394 uniqued_compilation_db_file = os .path .join (
13961395 args .output_path , "unique_compile_commands.json" )
0 commit comments