Skip to content

Commit 219fa3b

Browse files
committed
Change "CodeChecker analyze --dump-compiler-info-file" format
1 parent 09cf96b commit 219fa3b

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

analyzer/codechecker_analyzer/buildlog/log_parser.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,6 @@ def _process_entry_worker(args):
12241224

12251225

12261226
def parse_unique_log(compilation_database,
1227-
report_dir,
12281227
compile_uniqueing="none",
12291228
compiler_info_file=None,
12301229
keep_gcc_include_fixed=False,
@@ -1252,8 +1251,6 @@ def parse_unique_log(compilation_database,
12521251
by "arguments" which is a split command. Older
12531252
versions of intercept-build provide the build
12541253
command this way.
1255-
report_dir -- The output report directory. The compiler infos
1256-
will be written to <report_dir>/compiler.info.json.
12571254
compile_uniqueing -- Compilation database uniqueing mode.
12581255
If there are more than one compile commands for a
12591256
target file, only a single one is kept.
@@ -1398,9 +1395,6 @@ def parse_unique_log(compilation_database,
13981395
compile_uniqueing)
13991396
sys.exit(1)
14001397

1401-
ImplicitCompilerInfo.dump_compiler_info(
1402-
os.path.join(report_dir, "compiler_info.json"))
1403-
14041398
LOG.debug('Parsing log file done.')
14051399
return list(uniqued_build_actions.values()), skipped_cmp_cmd_count
14061400

analyzer/codechecker_analyzer/cli/analyze.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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")

analyzer/codechecker_analyzer/cli/check.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ def add_arguments_to_parser(parser):
140140
parser.add_argument('--dump-compiler-info-file',
141141
dest="dump_compiler_info_file",
142142
required=False,
143+
action='store_true',
144+
default=False,
143145
help="Dump implicit gcc compiler info to a json file "
144146
"that can be used for fine-tuning analysis later."
145147
"These are information like the implicit include "

0 commit comments

Comments
 (0)