From 59f6c7c0d2f343f5f12cd2f03b2d9ab217e79e8c Mon Sep 17 00:00:00 2001 From: Anders Wallin Date: Tue, 13 Oct 2020 08:15:27 +0200 Subject: [PATCH 1/5] Add option to set arguments to CC analyze Signed-off-by: Anders Wallin --- README.md | 6 +++++- classes/codechecker.bbclass | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8073866..0d74905 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ To enable the layer within a single recipe, do add inherit codechecker CODECHECKER_ENABLED = "1" - ### In conf/local.conf +### In conf/local.conf INHERIT += "codechecker" CODECHECKER_ENABLED = "1" @@ -34,6 +34,10 @@ To upload the results to the CodeScanner webserver (e.g. docker container) add: Note: The URL of the product to store the results for, in the format of 'http[s]://]host:port/Endpoint'. (default: localhost:8001/Default) +To add arguments to the CodeChecker analyze command (see CodeChecker man), e.g.: + + CODECHECKER_ANALYZE_ARGS = "-e sensitive" + Note: this was tested against the docker container docker pull codechecker/codechecker-web:6.13.0 diff --git a/classes/codechecker.bbclass b/classes/codechecker.bbclass index e093d04..644628b 100644 --- a/classes/codechecker.bbclass +++ b/classes/codechecker.bbclass @@ -53,7 +53,7 @@ if test x"${CODECHECKER_ENABLED}" = x"1"; then export CC_LOGGER_FILE="${DEPLOY_DIR}/CodeChecker/${PN}/codechecker-log.json" export CC_ANALYSE_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/results/" if test -f ${CC_LOGGER_FILE} ; then - CodeChecker analyze ${PARALLEL_MAKE} -o ${CC_ANALYSE_OUT} --report-hash context-free-v2 ${CC_LOGGER_FILE} + CodeChecker analyze ${PARALLEL_MAKE} ${CODECHECKER_ANALYZE_ARGS} -o ${CC_ANALYSE_OUT} --report-hash context-free-v2 ${CC_LOGGER_FILE} fi fi } From 7f48bca5dfb3f7763aa8aebf57f5e32407dd588b Mon Sep 17 00:00:00 2001 From: Anders Wallin Date: Fri, 5 Mar 2021 10:05:30 +0100 Subject: [PATCH 2/5] updated to 6.15.1 and gatesgarth - Updated README.md - update to codechecker 6.15.1 and api 6.39 - split codecheckerreport task into cc_parse and cc_store - added codechecker DISTRO_FEATURE support and saving reports with timestamp - moved simple-helloworld to recipes-examples - added documentation.conf - remove nativesdk support - added support for gatesgarth Signed-off-by: Anders Wallin --- README.md | 24 +-- classes/codechecker.bbclass | 173 +++++++++--------- conf/documentation.conf | 11 ++ conf/layer.conf | 4 +- .../codechecker/codechecker_git.bb | 10 +- ...0001-Use-python3-for-setuptool-calls.patch | 91 --------- .../files/simple-hello-world.c | 0 .../simple-helloworld}/simple-helloworld.bb | 12 +- .../simple-helloworld.bbappend | 1 + .../python3-codechecker-api-native_6.32.0.bb | 16 -- .../python3-codechecker-api-native_6.39.0.bb | 9 + ...n3-codechecker-api-shared-native_6.32.0.bb | 16 -- ...n3-codechecker-api-shared-native_6.39.0.bb | 9 + .../python3-thrift-native_0.13.0.bb | 2 +- 14 files changed, 139 insertions(+), 239 deletions(-) create mode 100644 conf/documentation.conf delete mode 100644 recipes-devtools/codechecker/files/0001-Use-python3-for-setuptool-calls.patch rename {recipes-devtools/codechecker => recipes-examples/simple-helloworld}/files/simple-hello-world.c (100%) rename {recipes-devtools/codechecker => recipes-examples/simple-helloworld}/simple-helloworld.bb (65%) create mode 100644 recipes-examples/simple-helloworld/simple-helloworld.bbappend delete mode 100644 recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.32.0.bb create mode 100644 recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.39.0.bb delete mode 100644 recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.32.0.bb create mode 100644 recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.39.0.bb diff --git a/README.md b/README.md index 0d74905..ee87ef5 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,32 @@ # meta-codechecker -A Layer to support CodeChecker as a frontent to clang static analysis - +A Layer to support CodeChecker as a frontend to clang static analysis ## usage This layer exposes a bbclass and the recipes needed to support inclusion of the tooling. Note that meta-clang is a requirement. -### In a recipe enable: +### enable codechecker feature: + + In e.g. conf/local.conf + DISTRO_FEATURES_append += " codechecker" -To enable the layer within a single recipe, do add +To enable the layer within a single recipe, add to the bitbake recipe inherit codechecker - CODECHECKER_ENABLED = "1" - -### In conf/local.conf + +### globally enable codechecker for all packages + + In e.g. conf/local.conf INHERIT += "codechecker" - CODECHECKER_ENABLED = "1" -### options: +### options To generate a static HTML site as report do add: + In e.g. conf/local.conf CODECHECKER_REPORT_HTML = "1" To upload the results to the CodeScanner webserver (e.g. docker container) add: @@ -38,9 +41,6 @@ To add arguments to the CodeChecker analyze command (see CodeChecker man), e.g.: CODECHECKER_ANALYZE_ARGS = "-e sensitive" -Note: this was tested against the docker container - docker pull codechecker/codechecker-web:6.13.0 - ### output location The output will be in: diff --git a/classes/codechecker.bbclass b/classes/codechecker.bbclass index 644628b..539fc67 100644 --- a/classes/codechecker.bbclass +++ b/classes/codechecker.bbclass @@ -1,109 +1,112 @@ inherit python3-dir -python () { - if d.getVar("CODECHECKER_ENABLED") == "1": - if not bb.data.inherits_class('nativesdk', d) \ - and not bb.data.inherits_class('native', d) \ - and not bb.data.inherits_class('cross', d) \ - and not bb.data.inherits_class('crosssdk', d) \ - and not bb.data.inherits_class('allarch', d): - d.prependVarFlag("do_compile", 'prefuncs', "do_csprecompile ") - d.appendVarFlag("do_compile", 'postfuncs', " do_cspostcompile") - d.appendVarFlag("do_compile", "postfuncs", " do_codecheckeranalyse") - d.appendVarFlag("do_compile", "postfuncs", " do_codecheckerreport") - d.appendVarFlag("do_compile", 'depends', ' codechecker-native:do_populate_sysroot python3-six-native:do_populate_sysroot python3-thrift-native:do_populate_sysroot python3-codechecker-api-native:do_populate_sysroot python3-codechecker-api-shared-native:do_populate_sysroot clang-native:do_populate_sysroot python3-native:do_populate_sysroot python3-psutil-native:do_populate_sysroot python3-portalocker-native:do_populate_sysroot python3-pyyaml-native:do_populate_sysroot') -} - -SAVEDENV = "" -#_environ = dict(os.environ) # or os.environ.copy() -# os.environ.update(_environ) +CODECHECKER_ENABLED ?= "${@bb.utils.contains('DISTRO_FEATURES', 'codechecker', '1', '0', d)}" +CODECHECKER_ENABLED_class-native = "" +CODECHECKER_ENABLED_class-nativesdk = "" +CODECHECKER_ENABLED_class-cross-canadian = "" +CODECHECKER_REPORT_HTML ?= "1" python do_csprecompile () { - SAVEDENV = os.environ.copy() os.environ["LD_PRELOAD"] = "" + d.getVar('RECIPE_SYSROOT_NATIVE') + "/usr/local/CodeChecker/ld_logger/lib/x86_64/ldlogger.so" os.environ["CC_LOGGER_GCC_LIKE"] = "gcc:g++:clang:clang++:cc:c++:ccache" os.environ["CC_LOGGER_FILE"] = "" + d.getVar("DEPLOY_DIR") + "/CodeChecker/" + d.getVar("PN") + "/codechecker-log.json" - #os.environ["PARALLEL_MAKE"] = "" + d.getVar("PARALLEL_MAKE") os.makedirs("" + d.getVar("DEPLOY_DIR") + "/CodeChecker/" + d.getVar("PN") , exist_ok=True) - #bb.warn(str(os.environ["LD_PRELOAD"])) } python do_cspostcompile () { if d.getVar("CODECHECKER_ENABLED") == "1": os.environ["LD_PRELOAD"] = "" - # or restore saved env - # optimization: remove empty files } - ############################################### -do_codecheckeranalyse() { - -if test x"${CODECHECKER_ENABLED}" = x"1"; then - # optimization - skip empty - # - # need to teach proper PATHs for this run - export PYTHON="${STAGING_BINDIR_NATIVE}/python3-native/python3" - export PYTHONNOUSERSITE="1" - export PYTHONPATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/python${PYTHON_BASEVERSION}/site-packages/" - export PATH="${RECIPE_SYSROOT_NATIVE}/usr/bin:${RECIPE_SYSROOT_NATIVE}/usr/bin/python3-native/:${RECIPE_SYSROOT_NATIVE}/usr/local/CodeChecker/bin:$PATH" - - # expose Variable for CodeChecker - export CC_LOGGER_FILE="${DEPLOY_DIR}/CodeChecker/${PN}/codechecker-log.json" - export CC_ANALYSE_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/results/" - if test -f ${CC_LOGGER_FILE} ; then - CodeChecker analyze ${PARALLEL_MAKE} ${CODECHECKER_ANALYZE_ARGS} -o ${CC_ANALYSE_OUT} --report-hash context-free-v2 ${CC_LOGGER_FILE} +do_codechecker_analyse() { + if test x"${CODECHECKER_ENABLED}" = x"1"; then + # need to teach proper PATHs for this run + export PYTHON="${STAGING_BINDIR_NATIVE}/python3-native/python3" + export PYTHONNOUSERSITE="1" + export PYTHONPATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/python${PYTHON_BASEVERSION}/site-packages/" + export PATH="${RECIPE_SYSROOT_NATIVE}/usr/bin:${RECIPE_SYSROOT_NATIVE}/usr/bin/python3-native/:${RECIPE_SYSROOT_NATIVE}/usr/local/CodeChecker/bin:$PATH" + # expose Variable for CodeChecker + TS=$(date +%4Y%2m%2d%2H%2M%2S) + export CC_LOGGER_FILE="${DEPLOY_DIR}/CodeChecker/${PN}/codechecker-log.json" + export CC_ANALYSE_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/${TS}/results/" + if test -f ${CC_LOGGER_FILE} ; then + CodeChecker analyze ${PARALLEL_MAKE} ${CODECHECKER_ANALYZE_ARGS} -o ${CC_ANALYSE_OUT} --report-hash context-free-v2 ${CC_LOGGER_FILE} || status=$? + if [ ${status} -eq 0 ]; then + bbnote "CodeChecker analyze ok" + else + bbwarn "CodeChecker analyze issues found" + fi + ln -sfn ${DEPLOY_DIR}/CodeChecker/${PN}/${TS} ${DEPLOY_DIR}/CodeChecker/${PN}/latest + cp ${CC_LOGGER_FILE} ${DEPLOY_DIR}/CodeChecker/${PN}/${TS}/ + fi fi -fi } - -addtask codecheckeranalyse - -do_codecheckerreport() { - -if test x"${CODECHECKER_ENABLED}" = x"1"; then - - # optimization - skip empty - - # need to teach proper PATHs for this run - export PYTHON="${STAGING_BINDIR_NATIVE}/python3-native/python3" - export PYTHONNOUSERSITE="1" - export PYTHONPATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/python${PYTHON_BASEVERSION}/site-packages/" - export PATH="${RECIPE_SYSROOT_NATIVE}/usr/bin:${RECIPE_SYSROOT_NATIVE}/usr/bin/python3-native/:${RECIPE_SYSROOT_NATIVE}/usr/local/CodeChecker/bin:$PATH" - - # expose variables for CodeChecker - export CC_LOGGER_FILE="${DEPLOY_DIR}/CodeChecker/${PN}/codechecker-log.json" - export CC_ANALYSE_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/results/" - export CC_REPORT_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/report-html/" - - if test -d ${CC_ANALYSE_OUT} ; then - if test x"${CODECHECKER_REPORT_HTML}" = x"1"; then - mkdir -p ${CC_REPORT_OUT} - #usage: CodeChecker parse [-h] [-t {plist}] [-e {html,json,codeclimate}] - # [-o OUTPUT_PATH] [--suppress SUPPRESS] - # [--export-source-suppress] [--print-steps] - # [-i SKIPFILE] - # [--trim-path-prefix [TRIM_PATH_PREFIX [TRIM_PATH_PREFIX ...]]] - # [--review-status [REVIEW_STATUS [REVIEW_STATUS ...]]] - # [--verbose {info,debug,debug_analyzer}] - # file/folder [file/folder ...] - CodeChecker parse -e html --trim-path-prefix=${S} ${CC_ANALYSE_OUT} -o ${CC_REPORT_OUT} - fi - if test x"${CODECHECKER_REPORT_STORE}" = x"1"; then - if test ! x"${CODECHECKER_REPORT_HOST}" = x""; then - #usage: CodeChecker store [-h] [-t {plist}] [-n NAME] [--tag TAG] - # [--description DESCRIPTION] - # [--trim-path-prefix [TRIM_PATH_PREFIX [TRIM_PATH_PREFIX ...]]] - # [--config CONFIG_FILE] [-f] [--url PRODUCT_URL] - # [--verbose {info,debug,debug_analyzer}] - # [file/folder [file/folder ...]] - # Todo: credentials - CodeChecker store -n ${PF} --trim-path-prefix=${S} --url ${CODECHECKER_REPORT_HOST} ${CC_ANALYSE_OUT} +addtask codechecker_analyse + +do_codechecker_parse() { + if test x"${CODECHECKER_ENABLED}" = x"1"; then + # need to teach proper PATHs for this run + export PYTHON="${STAGING_BINDIR_NATIVE}/python3-native/python3" + export PYTHONNOUSERSITE="1" + export PYTHONPATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/python${PYTHON_BASEVERSION}/site-packages/" + export PATH="${RECIPE_SYSROOT_NATIVE}/usr/bin:${RECIPE_SYSROOT_NATIVE}/usr/bin/python3-native/:${RECIPE_SYSROOT_NATIVE}/usr/local/CodeChecker/bin:$PATH" + + # expose variables for CodeChecker + export CC_ANALYSE_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/latest/results/" + export CC_REPORT_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/latest/report-html/" + + if test -d ${CC_ANALYSE_OUT}/ ; then + if test x"${CODECHECKER_REPORT_HTML}" = x"1"; then + mkdir -p ${CC_REPORT_OUT} + CodeChecker parse -e html --trim-path-prefix=${S} ${CC_ANALYSE_OUT} -o ${CC_REPORT_OUT} + ln -sfn ${CC_REPORT_OUT} ${DEPLOY_DIR}/CodeChecker/${PN}/report-html + fi + fi + fi +} +addtask codechecker_parse + +do_codechecker_store() { + if test x"${CODECHECKER_ENABLED}" = x"1"; then + # need to teach proper PATHs for this run + export PYTHON="${STAGING_BINDIR_NATIVE}/python3-native/python3" + export PYTHONNOUSERSITE="1" + export PYTHONPATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/python${PYTHON_BASEVERSION}/site-packages/" + export PATH="${RECIPE_SYSROOT_NATIVE}/usr/bin:${RECIPE_SYSROOT_NATIVE}/usr/bin/python3-native/:${RECIPE_SYSROOT_NATIVE}/usr/local/CodeChecker/bin:$PATH" + + # expose variables for CodeChecker + export CC_ANALYSE_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/latest/results/" + export CC_REPORT_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/latest/report-html/" + + if test -d ${CC_ANALYSE_OUT}/ ; then + if test x"${CODECHECKER_REPORT_STORE}" = x"1"; then + if test ! x"${CODECHECKER_REPORT_HOST}" = x""; then + CodeChecker store -n ${PF} --trim-path-prefix=${S} --url ${CODECHECKER_REPORT_HOST} ${CC_ANALYSE_OUT} || status=$? + if ${status}; then + bbdebug 1 "CodeChecker store ok" + else + bbwarn "CodeChecker store failed" + fi + fi fi fi fi -fi } +addtask codechecker_store -addtask codecheckerreport \ No newline at end of file +python () { + if d.getVar("CODECHECKER_ENABLED") == "1": + if not bb.data.inherits_class('nativesdk', d) \ + and not bb.data.inherits_class('native', d) \ + and not bb.data.inherits_class('cross', d) \ + and not bb.data.inherits_class('crosssdk', d) \ + and not bb.data.inherits_class('allarch', d): + d.prependVarFlag("do_compile", "prefuncs", "do_csprecompile ") + d.appendVarFlag("do_compile", "postfuncs", " do_cspostcompile") + d.appendVarFlag("do_compile", "postfuncs", " do_codechecker_analyse") + d.appendVarFlag("do_compile", "postfuncs", " do_codechecker_parse") + d.appendVarFlag("do_compile", "postfuncs", " do_codechecker_store") + d.appendVarFlag("do_compile", "depends", " codechecker-native:do_populate_sysroot python3-six-native:do_populate_sysroot python3-thrift-native:do_populate_sysroot python3-codechecker-api-native:do_populate_sysroot python3-codechecker-api-shared-native:do_populate_sysroot clang-native:do_populate_sysroot python3-native:do_populate_sysroot python3-psutil-native:do_populate_sysroot python3-portalocker-native:do_populate_sysroot python3-pyyaml-native:do_populate_sysroot") +} diff --git a/conf/documentation.conf b/conf/documentation.conf new file mode 100644 index 0000000..8e0793e --- /dev/null +++ b/conf/documentation.conf @@ -0,0 +1,11 @@ +# DESCRIPTIONS FOR TASKS # +do_codechecker_analyse[doc] = "Execute the supported code analyzers for the files recorded in a JSON Compilation Database" +do_codechecker_parse[doc] = "Print analysis summary and results in a human-readable format." +do_codechecker_store[doc] = "Save analysis results to a database." + +# DESCRIPTIONS FOR VARIABLES # +CODECHECKER_ENABLED[doc] = "Enable Codechecker." +CODECHECKER_ANALYZE_ARGS[doc] = "CodeChecker analyze arguments." +CODECHECKER_REPORT_HTML[doc] = "Print analysis summary and results in a human-readable format." +CODECHECKER_REPORT_STORE[doc] = "Save analysis results to a database." +CODECHECKER_REPORT_HOST[doc] = "URL to CodeChecker server." diff --git a/conf/layer.conf b/conf/layer.conf index 4ae3237..57dd213 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -9,5 +9,7 @@ BBFILE_COLLECTIONS += "codechecker" BBFILE_PATTERN_codechecker = "^${LAYERDIR}/" BBFILE_PRIORITY_codechecker = "70" -LAYERSERIES_COMPAT_codechecker = "dunfell" +LAYERSERIES_COMPAT_codechecker = "dunfell gatesgarth" LAYERDEPENDS_codechecker = "core clang-layer meta-python" + +include documentation.conf diff --git a/recipes-devtools/codechecker/codechecker_git.bb b/recipes-devtools/codechecker/codechecker_git.bb index 38ee927..ccd19bc 100644 --- a/recipes-devtools/codechecker/codechecker_git.bb +++ b/recipes-devtools/codechecker/codechecker_git.bb @@ -5,12 +5,11 @@ LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=2e982d844baa4df1c80de75470e0c5cb" DEPENDS = "doxygen-native curl-native git-native nodejs-native python3-native" -SRC_URI = " git://github.com/Ericsson/codechecker.git;protocol=https \ - file://0001-Use-python3-for-setuptool-calls.patch " +SRC_URI = "git://github.com/Ericsson/CodeChecker.git;branch=release-v6.15.1" #SRCREV = "${AUTOREV}" -# last 6.32 api -SRCREV = "f5defa9cb06c8ffdd68160bafa0d130c4b0f3951" +#6.15.1 +SRCREV = "692e51ba4be08e97c4b07cc344edca082dc50f63" S = "${WORKDIR}/git" @@ -37,6 +36,5 @@ SYSROOT_DIRS += " ${exec_prefix}/local" SYSROOT_DIRS_NATIVE += " ${exec_prefix}/local" RDEPENDS_${PN}_class-native += "clang-native python3-native" -RDEPENDS_${PN}_class-nativesdk += "nativesdk-clang nativesdk-python3" -BBCLASSEXTEND += "native nativesdk" +BBCLASSEXTEND += "native" diff --git a/recipes-devtools/codechecker/files/0001-Use-python3-for-setuptool-calls.patch b/recipes-devtools/codechecker/files/0001-Use-python3-for-setuptool-calls.patch deleted file mode 100644 index 448fa23..0000000 --- a/recipes-devtools/codechecker/files/0001-Use-python3-for-setuptool-calls.patch +++ /dev/null @@ -1,91 +0,0 @@ -From ecb5b2b07236761115b85db2729d3d2db2961219 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= -Date: Mon, 13 Jul 2020 17:33:59 +0000 -Subject: [PATCH] Use python3 for setuptool calls -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Signed-off-by: Jan-Simon Möller ---- - .../tools/merge_clang_extdef_mappings/Makefile | 14 +++++++------- - analyzer/tools/statistics_collector/Makefile | 14 +++++++------- - 2 files changed, 14 insertions(+), 14 deletions(-) - -diff --git a/analyzer/tools/merge_clang_extdef_mappings/Makefile b/analyzer/tools/merge_clang_extdef_mappings/Makefile -index b6633c2a..76e3c7d7 100644 ---- a/analyzer/tools/merge_clang_extdef_mappings/Makefile -+++ b/analyzer/tools/merge_clang_extdef_mappings/Makefile -@@ -37,25 +37,25 @@ include tests/Makefile - - package: - # Install package in 'development mode'. -- python setup.py develop -+ python3 setup.py develop - - build: -- python setup.py build --build-purelib $(MERGE_CLANG_EXTDEF_MAPS_DIR) -+ python3 setup.py build --build-purelib $(MERGE_CLANG_EXTDEF_MAPS_DIR) - - dist: - # Create a source distribution. -- python setup.py sdist -+ python3 setup.py sdist - - upload_test: dist - # Upload package to the TestPyPI repository. -- $(eval PKG_NAME := $(shell python setup.py --name)) -- $(eval PKG_VERSION := $(shell python setup.py --version)) -+ $(eval PKG_NAME := $(shell python3 setup.py --name)) -+ $(eval PKG_VERSION := $(shell python3 setup.py --version)) - twine upload -r testpypi dist/$(PKG_NAME)-$(PKG_VERSION).tar.gz - - upload: dist - # Upload package to the PyPI repository. -- $(eval PKG_NAME := $(shell python setup.py --name)) -- $(eval PKG_VERSION := $(shell python setup.py --version)) -+ $(eval PKG_NAME := $(shell python3 setup.py --name)) -+ $(eval PKG_VERSION := $(shell python3 setup.py --version)) - twine upload -r pypi dist/$(PKG_NAME)-$(PKG_VERSION).tar.gz - - clean: -diff --git a/analyzer/tools/statistics_collector/Makefile b/analyzer/tools/statistics_collector/Makefile -index fd697466..ebe2263e 100644 ---- a/analyzer/tools/statistics_collector/Makefile -+++ b/analyzer/tools/statistics_collector/Makefile -@@ -37,25 +37,25 @@ include tests/Makefile - - package: - # Install package in 'development mode'. -- python setup.py develop -+ python3 setup.py develop - - build: -- python setup.py build --build-purelib $(STATISTICS_COLLECTOR_DIR) -+ python3 setup.py build --build-purelib $(STATISTICS_COLLECTOR_DIR) - - dist: - # Create a source distribution. -- python setup.py sdist -+ python3 setup.py sdist - - upload_test: dist - # Upload package to the TestPyPI repository. -- $(eval PKG_NAME := $(shell python setup.py --name)) -- $(eval PKG_VERSION := $(shell python setup.py --version)) -+ $(eval PKG_NAME := $(shell python3 setup.py --name)) -+ $(eval PKG_VERSION := $(shell python3 setup.py --version)) - twine upload -r testpypi dist/$(PKG_NAME)-$(PKG_VERSION).tar.gz - - upload: dist - # Upload package to the PyPI repository. -- $(eval PKG_NAME := $(shell python setup.py --name)) -- $(eval PKG_VERSION := $(shell python setup.py --version)) -+ $(eval PKG_NAME := $(shell python3 setup.py --name)) -+ $(eval PKG_VERSION := $(shell python3 setup.py --version)) - twine upload -r pypi dist/$(PKG_NAME)-$(PKG_VERSION).tar.gz - - clean: --- -2.26.2 - diff --git a/recipes-devtools/codechecker/files/simple-hello-world.c b/recipes-examples/simple-helloworld/files/simple-hello-world.c similarity index 100% rename from recipes-devtools/codechecker/files/simple-hello-world.c rename to recipes-examples/simple-helloworld/files/simple-hello-world.c diff --git a/recipes-devtools/codechecker/simple-helloworld.bb b/recipes-examples/simple-helloworld/simple-helloworld.bb similarity index 65% rename from recipes-devtools/codechecker/simple-helloworld.bb rename to recipes-examples/simple-helloworld/simple-helloworld.bb index e0607e8..eccc82c 100644 --- a/recipes-devtools/codechecker/simple-helloworld.bb +++ b/recipes-examples/simple-helloworld/simple-helloworld.bb @@ -7,16 +7,6 @@ SRC_URI = "file://simple-hello-world.c;subdir=sources" S = "${WORKDIR}/sources" -DEPENDS += "codechecker-native" - -EXTRANATIVEPATH += "python3-native" - -inherit codechecker -CODECHECKER_ENABLED ?= "1" -CODECHECKER_REPORT_HTML ?= "1" -#CODECHECKER_REPORT_STORE ?= "1" -#CODECHECKER_REPORT_HOST ?= "http://localhost:8001/Default" - do_compile() { ${CC} -w simple-hello-world.c ${CFLAGS} ${LDFLAGS} -o simple-hello-world } @@ -24,4 +14,4 @@ do_compile() { do_install() { install -d ${D}${bindir} install -m 0755 simple-hello-world ${D}${bindir} -} \ No newline at end of file +} diff --git a/recipes-examples/simple-helloworld/simple-helloworld.bbappend b/recipes-examples/simple-helloworld/simple-helloworld.bbappend new file mode 100644 index 0000000..565cf8d --- /dev/null +++ b/recipes-examples/simple-helloworld/simple-helloworld.bbappend @@ -0,0 +1 @@ +inherit codechecker diff --git a/recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.32.0.bb b/recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.32.0.bb deleted file mode 100644 index 5396362..0000000 --- a/recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.32.0.bb +++ /dev/null @@ -1,16 +0,0 @@ -SUMMARY = "Recipie to embedded the Python PiP Package codechecker_api" -HOMEPAGE ="https://pypi.org/project/codechecker_api" -LICENSE = "Apache-2.0-with-LLVM-exception" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" - -inherit pypi setuptools3 native -PYPI_PACKAGE = "codechecker_api" - -# 6.31 -#SRC_URI[sha256sum] = "7805aa650fd36cfa5567575720e7057cdb4a19748f331b049a6cd8b7d337f36f" - -#6.33 -#SRC_URI[sha256sum] = "39cd6b01b47ed9a0b8690d149a0c6bba6b7350df36c9a55bc78ddf459686c851" - -#6.32 -SRC_URI[sha256sum] = "8d7f7cf5d6c5b971e424135cc2967bf3b5451befa5be84dca54487b0c27032af" diff --git a/recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.39.0.bb b/recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.39.0.bb new file mode 100644 index 0000000..d8c816c --- /dev/null +++ b/recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.39.0.bb @@ -0,0 +1,9 @@ +SUMMARY = "Recipe to embedded the Python PiP Package codechecker_api" +HOMEPAGE ="https://pypi.org/project/codechecker_api" +LICENSE = "Apache-2.0-with-LLVM-exception" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" + +inherit native pypi setuptools3 +PYPI_PACKAGE = "codechecker_api" + +SRC_URI[sha256sum] = "19ddeee1edc0863e50f8a812887c22bafcfafe7367b7981e04f1a6ed74a3c092" diff --git a/recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.32.0.bb b/recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.32.0.bb deleted file mode 100644 index f992e4b..0000000 --- a/recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.32.0.bb +++ /dev/null @@ -1,16 +0,0 @@ -SUMMARY = "Recipie to embedded the Python PiP Package codechecker_api_shared" -HOMEPAGE ="https://pypi.org/project/codechecker_api_shared" -LICENSE = "Apache-2.0-with-LLVM-exception" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" - -inherit pypi setuptools3 native -PYPI_PACKAGE = "codechecker_api_shared" - -#6.31 -#SRC_URI[sha256sum] = "364ad9ddcf90a8b93b9d8c304f5ff7de644c0e6835e3629701132621d698d3bf" - -# 6.33 -#SRC_URI[sha256sum] = "1d196b7e7088e7ca656cceced4dba8add97eb6cd1be8c7a8eb637441d4b6818c" - -# 6.32 -SRC_URI[sha256sum] = "51e526a155e9a6fa765dd5eb6683e0b77ac0ef4caf098be27633e63070995d01" diff --git a/recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.39.0.bb b/recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.39.0.bb new file mode 100644 index 0000000..e9bf94b --- /dev/null +++ b/recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.39.0.bb @@ -0,0 +1,9 @@ +SUMMARY = "Recipe to embedded the Python PiP Package codechecker_api_shared" +HOMEPAGE ="https://pypi.org/project/codechecker_api_shared" +LICENSE = "Apache-2.0-with-LLVM-exception" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" + +inherit native pypi setuptools3 +PYPI_PACKAGE = "codechecker_api_shared" + +SRC_URI[sha256sum] = "65bee7da8fbffba61174cc4ccef76babcc9e6585ebdd4866da4a13d85834de25" diff --git a/recipes-python/python3-thrift/python3-thrift-native_0.13.0.bb b/recipes-python/python3-thrift/python3-thrift-native_0.13.0.bb index 08dc8ff..fa9a71c 100644 --- a/recipes-python/python3-thrift/python3-thrift-native_0.13.0.bb +++ b/recipes-python/python3-thrift/python3-thrift-native_0.13.0.bb @@ -1,5 +1,5 @@ # existing upstream recipe does not have a native version -SUMMARY = "Recipie to embedded the Python PiP Package thrift" +SUMMARY = "Recipe to embedded the Python PiP Package thrift" HOMEPAGE ="https://pypi.org/project/thrift" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=2ba8bcf874551cc47b1c430e18ec4163" From 9c78b3ee33c244780a57e7fc5bc72da23a666324 Mon Sep 17 00:00:00 2001 From: Anders Wallin Date: Tue, 9 Mar 2021 15:21:37 +0100 Subject: [PATCH 3/5] restructured and added error handling Signed-off-by: Anders Wallin --- classes/codechecker.bbclass | 121 +++++++++++++++++------------------- conf/documentation.conf | 11 ++-- 2 files changed, 62 insertions(+), 70 deletions(-) diff --git a/classes/codechecker.bbclass b/classes/codechecker.bbclass index 539fc67..9505e88 100644 --- a/classes/codechecker.bbclass +++ b/classes/codechecker.bbclass @@ -4,97 +4,93 @@ CODECHECKER_ENABLED ?= "${@bb.utils.contains('DISTRO_FEATURES', 'codechecker', ' CODECHECKER_ENABLED_class-native = "" CODECHECKER_ENABLED_class-nativesdk = "" CODECHECKER_ENABLED_class-cross-canadian = "" + CODECHECKER_REPORT_HTML ?= "1" python do_csprecompile () { os.environ["LD_PRELOAD"] = "" + d.getVar('RECIPE_SYSROOT_NATIVE') + "/usr/local/CodeChecker/ld_logger/lib/x86_64/ldlogger.so" os.environ["CC_LOGGER_GCC_LIKE"] = "gcc:g++:clang:clang++:cc:c++:ccache" - os.environ["CC_LOGGER_FILE"] = "" + d.getVar("DEPLOY_DIR") + "/CodeChecker/" + d.getVar("PN") + "/codechecker-log.json" - os.makedirs("" + d.getVar("DEPLOY_DIR") + "/CodeChecker/" + d.getVar("PN") , exist_ok=True) + os.environ["CC_LOGGER_FILE"] = "" + d.getVar("B") + "/codechecker-log.json" + os.makedirs("" + d.getVar("DEPLOY_DIR") + "/codechecker/" + d.getVar("PN") , exist_ok=True) } python do_cspostcompile () { - if d.getVar("CODECHECKER_ENABLED") == "1": - os.environ["LD_PRELOAD"] = "" + os.environ["LD_PRELOAD"] = "" } ############################################### -do_codechecker_analyse() { - if test x"${CODECHECKER_ENABLED}" = x"1"; then - # need to teach proper PATHs for this run - export PYTHON="${STAGING_BINDIR_NATIVE}/python3-native/python3" - export PYTHONNOUSERSITE="1" - export PYTHONPATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/python${PYTHON_BASEVERSION}/site-packages/" - export PATH="${RECIPE_SYSROOT_NATIVE}/usr/bin:${RECIPE_SYSROOT_NATIVE}/usr/bin/python3-native/:${RECIPE_SYSROOT_NATIVE}/usr/local/CodeChecker/bin:$PATH" - # expose Variable for CodeChecker - TS=$(date +%4Y%2m%2d%2H%2M%2S) - export CC_LOGGER_FILE="${DEPLOY_DIR}/CodeChecker/${PN}/codechecker-log.json" - export CC_ANALYSE_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/${TS}/results/" - if test -f ${CC_LOGGER_FILE} ; then - CodeChecker analyze ${PARALLEL_MAKE} ${CODECHECKER_ANALYZE_ARGS} -o ${CC_ANALYSE_OUT} --report-hash context-free-v2 ${CC_LOGGER_FILE} || status=$? +do_codechecker_analyze() { + bbnote "codechecker_analyze" + if test -f ${CC_LOGGER_FILE} ; then + CodeChecker analyze ${PARALLEL_MAKE} ${CODECHECKER_ANALYZE_ARGS} -o ${CC_ANALYZE_OUT} --report-hash context-free-v2 ${CC_LOGGER_FILE} || status=$? + if [ ${status} -eq 0 ]; then + bbnote "codechecker analyze ok" + else + bbwarn "codechecker analyze issues found, status=${status}" + status=0 + fi + mkdir -p ${CC_DIR} + ln -sfn ${CC_DIR}/${TS} ${CC_DIR}/latest + cp ${CC_LOGGER_FILE} ${CC_DIR}/${TS}/ + fi +} + +do_codechecker_parse() { + bbnote "codechecker_parse" + if test x"${CODECHECKER_REPORT_HTML}" = x"1"; then + mkdir -p ${CC_REPORT_OUT} + CodeChecker parse ${CODECHECKER_PARSE_ARGS} -e html --trim-path-prefix=${S} ${CC_ANALYZE_OUT} -o ${CC_REPORT_OUT} || status=$? + if [ ${status} -eq 0 ]; then + bbdebug 1 "codechecker parse ok" + else + bbwarn "codechecker parse failed, status=${status}" + status=0 + fi + fi +} + +do_codechecker_store() { + bbnote "codechecker_store" + if test x"${CODECHECKER_REPORT_STORE}" = x"1"; then + if test ! x"${CODECHECKER_REPORT_HOST}" = x""; then + CodeChecker store ${CODECHECKER_STORE_ARGS} -n ${PF} --trim-path-prefix=${S} --url ${CODECHECKER_REPORT_HOST} ${CC_ANALYZE_OUT} || status=$? if [ ${status} -eq 0 ]; then - bbnote "CodeChecker analyze ok" + bbdebug 1 "codechecker store ok" else - bbwarn "CodeChecker analyze issues found" + bbwarn "codechecker store failed, status=${status}" + status=0 fi - ln -sfn ${DEPLOY_DIR}/CodeChecker/${PN}/${TS} ${DEPLOY_DIR}/CodeChecker/${PN}/latest - cp ${CC_LOGGER_FILE} ${DEPLOY_DIR}/CodeChecker/${PN}/${TS}/ fi fi } -addtask codechecker_analyse -do_codechecker_parse() { +do_codechecker() { if test x"${CODECHECKER_ENABLED}" = x"1"; then + bbnote "codechecker enabled" + # need to teach proper PATHs for this run export PYTHON="${STAGING_BINDIR_NATIVE}/python3-native/python3" export PYTHONNOUSERSITE="1" export PYTHONPATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/python${PYTHON_BASEVERSION}/site-packages/" export PATH="${RECIPE_SYSROOT_NATIVE}/usr/bin:${RECIPE_SYSROOT_NATIVE}/usr/bin/python3-native/:${RECIPE_SYSROOT_NATIVE}/usr/local/CodeChecker/bin:$PATH" - # expose variables for CodeChecker - export CC_ANALYSE_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/latest/results/" - export CC_REPORT_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/latest/report-html/" + # expose variable for codechecker + export TS=$(date +%4Y%2m%2d%2H%2M%2S) + export CC_DIR="${DEPLOY_DIR}/codechecker/${PN}" + export CC_ANALYZE_OUT="${CC_DIR}/${TS}/results/" + export CC_REPORT_OUT="${CC_DIR}/${TS}/report-html/" + export CC_LOGGER_FILE="${B}/codechecker-log.json" + export status=0 - if test -d ${CC_ANALYSE_OUT}/ ; then - if test x"${CODECHECKER_REPORT_HTML}" = x"1"; then - mkdir -p ${CC_REPORT_OUT} - CodeChecker parse -e html --trim-path-prefix=${S} ${CC_ANALYSE_OUT} -o ${CC_REPORT_OUT} - ln -sfn ${CC_REPORT_OUT} ${DEPLOY_DIR}/CodeChecker/${PN}/report-html - fi + do_codechecker_analyze + if test -d ${CC_ANALYZE_OUT} ; then + do_codechecker_parse + do_codechecker_store fi fi } -addtask codechecker_parse - -do_codechecker_store() { - if test x"${CODECHECKER_ENABLED}" = x"1"; then - # need to teach proper PATHs for this run - export PYTHON="${STAGING_BINDIR_NATIVE}/python3-native/python3" - export PYTHONNOUSERSITE="1" - export PYTHONPATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/python${PYTHON_BASEVERSION}/site-packages/" - export PATH="${RECIPE_SYSROOT_NATIVE}/usr/bin:${RECIPE_SYSROOT_NATIVE}/usr/bin/python3-native/:${RECIPE_SYSROOT_NATIVE}/usr/local/CodeChecker/bin:$PATH" - - # expose variables for CodeChecker - export CC_ANALYSE_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/latest/results/" - export CC_REPORT_OUT="${DEPLOY_DIR}/CodeChecker/${PN}/latest/report-html/" - - if test -d ${CC_ANALYSE_OUT}/ ; then - if test x"${CODECHECKER_REPORT_STORE}" = x"1"; then - if test ! x"${CODECHECKER_REPORT_HOST}" = x""; then - CodeChecker store -n ${PF} --trim-path-prefix=${S} --url ${CODECHECKER_REPORT_HOST} ${CC_ANALYSE_OUT} || status=$? - if ${status}; then - bbdebug 1 "CodeChecker store ok" - else - bbwarn "CodeChecker store failed" - fi - fi - fi - fi - fi -} -addtask codechecker_store +addtask codechecker after do_compile before do_install python () { if d.getVar("CODECHECKER_ENABLED") == "1": @@ -105,8 +101,5 @@ python () { and not bb.data.inherits_class('allarch', d): d.prependVarFlag("do_compile", "prefuncs", "do_csprecompile ") d.appendVarFlag("do_compile", "postfuncs", " do_cspostcompile") - d.appendVarFlag("do_compile", "postfuncs", " do_codechecker_analyse") - d.appendVarFlag("do_compile", "postfuncs", " do_codechecker_parse") - d.appendVarFlag("do_compile", "postfuncs", " do_codechecker_store") d.appendVarFlag("do_compile", "depends", " codechecker-native:do_populate_sysroot python3-six-native:do_populate_sysroot python3-thrift-native:do_populate_sysroot python3-codechecker-api-native:do_populate_sysroot python3-codechecker-api-shared-native:do_populate_sysroot clang-native:do_populate_sysroot python3-native:do_populate_sysroot python3-psutil-native:do_populate_sysroot python3-portalocker-native:do_populate_sysroot python3-pyyaml-native:do_populate_sysroot") } diff --git a/conf/documentation.conf b/conf/documentation.conf index 8e0793e..719f824 100644 --- a/conf/documentation.conf +++ b/conf/documentation.conf @@ -1,11 +1,10 @@ # DESCRIPTIONS FOR TASKS # -do_codechecker_analyse[doc] = "Execute the supported code analyzers for the files recorded in a JSON Compilation Database" -do_codechecker_parse[doc] = "Print analysis summary and results in a human-readable format." -do_codechecker_store[doc] = "Save analysis results to a database." +do_codechecker[doc] = "Run codechecker analyse, parse and store." # DESCRIPTIONS FOR VARIABLES # -CODECHECKER_ENABLED[doc] = "Enable Codechecker." -CODECHECKER_ANALYZE_ARGS[doc] = "CodeChecker analyze arguments." +CODECHECKER_ANALYZE_ARGS[doc] = "codechecker analyze arguments." +CODECHECKER_PARSE_ARGS[doc] = "codechecker parse arguments." +CODECHECKER_STORE_ARGS[doc] = "codechecker store arguments." CODECHECKER_REPORT_HTML[doc] = "Print analysis summary and results in a human-readable format." CODECHECKER_REPORT_STORE[doc] = "Save analysis results to a database." -CODECHECKER_REPORT_HOST[doc] = "URL to CodeChecker server." +CODECHECKER_REPORT_HOST[doc] = "URL to codechecker server." From f4206e6de63bbcde4a281a411ffde8420febf8af Mon Sep 17 00:00:00 2001 From: Anders Wallin Date: Fri, 9 Apr 2021 16:20:58 +0200 Subject: [PATCH 4/5] python3-codechecker-api: inheriting native last Signed-off-by: Anders Wallin --- .../python3-codechecker-api-native_6.39.0.bb | 2 +- .../python3-codechecker-api-shared-native_6.39.0.bb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.39.0.bb b/recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.39.0.bb index d8c816c..b631131 100644 --- a/recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.39.0.bb +++ b/recipes-python/python3-codechecker-api/python3-codechecker-api-native_6.39.0.bb @@ -3,7 +3,7 @@ HOMEPAGE ="https://pypi.org/project/codechecker_api" LICENSE = "Apache-2.0-with-LLVM-exception" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" -inherit native pypi setuptools3 +inherit pypi setuptools3 native PYPI_PACKAGE = "codechecker_api" SRC_URI[sha256sum] = "19ddeee1edc0863e50f8a812887c22bafcfafe7367b7981e04f1a6ed74a3c092" diff --git a/recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.39.0.bb b/recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.39.0.bb index e9bf94b..b3b42fa 100644 --- a/recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.39.0.bb +++ b/recipes-python/python3-codechecker-api/python3-codechecker-api-shared-native_6.39.0.bb @@ -3,7 +3,7 @@ HOMEPAGE ="https://pypi.org/project/codechecker_api_shared" LICENSE = "Apache-2.0-with-LLVM-exception" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" -inherit native pypi setuptools3 +inherit pypi setuptools3 native PYPI_PACKAGE = "codechecker_api_shared" SRC_URI[sha256sum] = "65bee7da8fbffba61174cc4ccef76babcc9e6585ebdd4866da4a13d85834de25" From 262869d3223a5e84b107fe4d3312cef18656e3b0 Mon Sep 17 00:00:00 2001 From: Anders Wallin Date: Fri, 16 Apr 2021 09:25:08 +0200 Subject: [PATCH 5/5] added layer compatibility for hardknott --- conf/layer.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/layer.conf b/conf/layer.conf index 57dd213..3a7fd81 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -9,7 +9,7 @@ BBFILE_COLLECTIONS += "codechecker" BBFILE_PATTERN_codechecker = "^${LAYERDIR}/" BBFILE_PRIORITY_codechecker = "70" -LAYERSERIES_COMPAT_codechecker = "dunfell gatesgarth" +LAYERSERIES_COMPAT_codechecker = "dunfell gatesgarth hardknott" LAYERDEPENDS_codechecker = "core clang-layer meta-python" include documentation.conf