Skip to content

Commit 8dd880d

Browse files
committed
CMD: guard skip_if_metrics with version check
1 parent 7c76ca9 commit 8dd880d

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

chb/app/CHVersion.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
chbversion: str = "0.3.0-20260122"
1+
chbversion: str = "0.3.0-20260125"
2+
3+
minimum_required_chb_version = "0.6.0_20260122"

chb/cmdline/commandutil.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262

6363
from chb.app.Callgraph import CallgraphNode
6464

65+
from chb.app.CHVersion import minimum_required_chb_version
66+
6567
from chb.arm.ARMAccess import ARMAccess
6668
from chb.arm.ARMAssembly import ARMAssembly
6769

@@ -458,9 +460,18 @@ def analyzecmd(args: argparse.Namespace) -> NoReturn:
458460
exit(0)
459461

460462
if skip_if_metrics and UF.has_analysis_results(path, xfile):
461-
# we have what we need
462-
print_status_update("Skip analysis of " + xname)
463-
exit(0)
463+
chbversion = UF.get_resultmetrics_chb_version(path, xfile)
464+
if chbversion >= minimum_required_chb_version:
465+
# we have what we need
466+
print_status_update("Skip analysis of " + xname + " (version: " + chbversion + ")")
467+
exit(0)
468+
else:
469+
print_status_update(
470+
"Analysis results found are out of date with current version. "
471+
+ "Minimum required version: "
472+
+ minimum_required_chb_version
473+
+ ". Version found: "
474+
+ chbversion)
464475

465476
try:
466477
userhints = prepare_executable(

chb/util/fileutil.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,14 @@ def get_resultmetrics_xheader(path: str, xfile: str) -> ET.Element:
843843
return get_chb_xheader(filename)
844844

845845

846+
def get_resultmetrics_chb_version(path: str, xfile: str) -> str:
847+
xheader = get_resultmetrics_xheader(path, xfile)
848+
xversion = xheader.get("chb-version")
849+
if xversion is None:
850+
raise CHBError("chb-version attribute missing from metrics header")
851+
return xversion
852+
853+
846854
def get_resultdata_filename(path: str, xfile: str) -> str:
847855
fdir = get_results_dir(path, xfile)
848856
return get_chb_filename(fdir, xfile, "data.xml")

0 commit comments

Comments
 (0)