Skip to content

Commit b138ed3

Browse files
committed
look up Python interpreter in checkCWEEntries make target
1 parent 5924808 commit b138ed3

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,17 @@ validateXML: createXMLExamples
385385
xmllint --noout --relaxng cppcheck-errors.rng /tmp/example.xml
386386

387387
checkCWEEntries: /tmp/errorlist.xml
388-
./tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml
388+
# Find available Python interpreter
389+
ifndef PYTHON_INTERPRETER
390+
PYTHON_INTERPRETER := $(shell which python3)
391+
endif
392+
ifndef PYTHON_INTERPRETER
393+
PYTHON_INTERPRETER := $(shell which python)
394+
endif
395+
ifndef PYTHON_INTERPRETER
396+
$(error Did not find a Python interpreter)
397+
endif
398+
$(PYTHON_INTERPRETER) tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml
389399
.PHONY: validateRules
390400
validateRules:
391401
xmllint --noout rules/*.xml

tools/dmake.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,17 @@ int main(int argc, char **argv)
496496
fout << "\txmllint --noout --relaxng cppcheck-errors.rng /tmp/errorlist.xml\n";
497497
fout << "\txmllint --noout --relaxng cppcheck-errors.rng /tmp/example.xml\n";
498498
fout << "\ncheckCWEEntries: /tmp/errorlist.xml\n";
499-
fout << "\t./tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml\n";
499+
fout << "\t# Find available Python interpreter\n";
500+
fout << "\tifndef PYTHON_INTERPRETER\n";
501+
fout << "\t\tPYTHON_INTERPRETER := $(shell which python3)\n";
502+
fout << "\tendif\n";
503+
fout << "\tifndef PYTHON_INTERPRETER\n";
504+
fout << "\t\tPYTHON_INTERPRETER := $(shell which python)\n";
505+
fout << "\tendif\n";
506+
fout << "\tifndef PYTHON_INTERPRETER\n";
507+
fout << "\t\t$(error Did not find a Python interpreter)\n";
508+
fout << "\tendif\n";
509+
fout << "\t$(PYTHON_INTERPRETER) tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml\n";
500510
fout << ".PHONY: validateRules\n";
501511
fout << "validateRules:\n";
502512
fout << "\txmllint --noout rules/*.xml\n";

0 commit comments

Comments
 (0)