Skip to content

Commit 5565f63

Browse files
waskyosipma
authored andcommitted
CMD: Allow excluding files from analysis
The functionality was already there in CApplication, this just exposes it as a command line parameter to chkc c-project analyze
1 parent 77f2a7b commit 5565f63

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

chc/app/CApplication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# Copyright (c) 2017-2020 Kestrel Technology LLC
88
# Copyright (c) 2020-2022 Henny B. Sipma
9-
# Copyright (c) 2023-2024 Aarno Labs LLC
9+
# Copyright (c) 2023-2025 Aarno Labs LLC
1010
#
1111
# Permission is hereby granted, free of charge, to any person obtaining a copy
1212
# of this software and associated documentation files (the "Software"), to deal

chc/cmdline/c_project/cprojectutil.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ------------------------------------------------------------------------------
55
# The MIT License (MIT)
66
#
7-
# Copyright (c) 2024 Aarno Labs, LLC
7+
# Copyright (c) 2024-2025 Aarno Labs, LLC
88
#
99
# Permission is hereby granted, free of charge, to any person obtaining a copy
1010
# of this software and associated documentation files (the "Software"), to deal
@@ -170,6 +170,7 @@ def cproject_analyze_project(args: argparse.Namespace) -> NoReturn:
170170
loglevel: str = args.loglevel
171171
logfilename: Optional[str] = args.logfilename
172172
logfilemode: str = args.logfilemode
173+
excludefiles: List[str] = args.exclude
173174

174175
if not os.path.isdir(tgtpath):
175176
print_error(f"Target directory {tgtpath} not found")
@@ -193,7 +194,7 @@ def cproject_analyze_project(args: argparse.Namespace) -> NoReturn:
193194
exit(1)
194195

195196
capp = CApplication(
196-
projectpath, projectname, targetpath, contractpath)
197+
projectpath, projectname, targetpath, contractpath, excludefiles=excludefiles)
197198

198199
def save_xrefs(f: "CFile") -> None:
199200
capp.indexmanager.save_xrefs(
@@ -206,7 +207,7 @@ def save_xrefs(f: "CFile") -> None:
206207
linker.save_global_compinfos()
207208

208209
capp = CApplication(
209-
projectpath, projectname, targetpath, contractpath)
210+
projectpath, projectname, targetpath, contractpath, excludefiles=excludefiles)
210211

211212
am = AnalysisManager(capp, verbose=True)
212213

chc/cmdline/chkc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# ------------------------------------------------------------------------------
66
# The MIT License (MIT)
77
#
8-
# Copyright (c) 2023-2024 Aarno Labs, LLC
8+
# Copyright (c) 2023-2025 Aarno Labs, LLC
99
#
1010
# Permission is hereby granted, free of charge, to any person obtaining a copy
1111
# of this software and associated documentation files (the "Software"), to deal
@@ -1350,6 +1350,9 @@ def parse() -> argparse.Namespace:
13501350
choices=["a", "w"],
13511351
default="a",
13521352
help="file mode for log file: append (a, default), or write (w)")
1353+
cprojectanalyze.add_argument("-x", "--exclude", action='append',
1354+
help="Exclude file from analysis. To exclude multiple files, use "
1355+
"this option for each file, e.g. -x dir1/f1.c, -x dir2/f2.c")
13531356
cprojectanalyze.set_defaults(func=P.cproject_analyze_project)
13541357

13551358
# --- report

0 commit comments

Comments
 (0)