Skip to content

Commit

Permalink
cppcheck: deprecated user rules support
Browse files Browse the repository at this point in the history
as this feature is considered deprecated by upstream

Closes #3749

Signed-off-by: Konrad Weihmann <[email protected]>
  • Loading branch information
priv-kweihmann committed Aug 30, 2022
1 parent f049fa6 commit 49d07f3
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 107 deletions.
3 changes: 0 additions & 3 deletions classes/sca-cppcheck.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ python do_sca_cppcheck() {
import os
import subprocess

_user_rules = os.path.join(d.getVar("STAGING_DATADIR_NATIVE"), "cppcheck-user-rules.xml")
_add_include = d.getVar("SCA_CPPCHECK_ADD_INCLUDES").split(" ")

# Copy configurations into special dir
Expand All @@ -120,8 +119,6 @@ python do_sca_cppcheck() {
subprocess.check_call(["ln", "-sf", d.expand("${STAGING_DATADIR_NATIVE}/platform"), d.expand("${T}/platform")])

_args = ["cppcheck"]
if os.path.exists(_user_rules):
_args += ["--rule-file={}".format(_user_rules)]

if d.getVar("SCA_CPPCHECK_RUNMODE") == "complete":
_args += ["--enable=all"]
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,17 @@ DEFAULT_PREFERENCE = "${SCA_DEFAULT_PREFERENCE}"
LICENSE = "BSD-2-Clause"
LIC_FILES_CHKSUM = "file://${SCA_LAYERDIR}/LICENSE;md5=a4a2bbea1db029f21b3a328c7a059172"

SRC_URI = "file://suppress \
file://fatal \
file://empty-catch-block.rule \
file://strlen-empty-str.rule"
SRC_URI = "\
file://suppress \
file://fatal \
"

inherit nativesdk

do_configure () {
rules="${@" ".join(find_cfgs(d))}"
rulefile="${WORKDIR}/user-rules.xml"
echo "<?xml version=\"1.0\"?>" > "${rulefile}"
if [ ! -z "${rules}" ]; then
for r in ${@" ".join(find_cfgs(d))}; do
cat ${r} >> "${rulefile}"
done
fi
}
def find_cfgs(d):
sources=src_patches(d, True)
## Find all files in files-dir with ends on ".rule"
return sorted([x for x in sources if x.endswith('.rule')])

do_install() {
install -d "${D}${datadir}"
install "${WORKDIR}/suppress" "${D}${datadir}/cppcheck-recipe-suppress"
install "${WORKDIR}/fatal" "${D}${datadir}/cppcheck-recipe-fatal"
install "${WORKDIR}/user-rules.xml" "${D}${datadir}/cppcheck-user-rules.xml"
}

FILES:${PN} = "${datadir}"
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,17 @@ DEFAULT_PREFERENCE = "${SCA_DEFAULT_PREFERENCE}"
LICENSE = "BSD-2-Clause"
LIC_FILES_CHKSUM = "file://${SCA_LAYERDIR}/LICENSE;md5=a4a2bbea1db029f21b3a328c7a059172"

SRC_URI = "file://suppress \
file://fatal \
file://empty-catch-block.rule \
file://strlen-empty-str.rule"
SRC_URI = "\
file://suppress \
file://fatal \
"

inherit native

def find_cfgs(d):
sources=src_patches(d, True)
## Find all files in files-dir with ends on ".rule"
return sorted([x for x in sources if x.endswith('.rule')])

do_configure () {
rules="${@" ".join(find_cfgs(d))}"
rulefile="${WORKDIR}/user-rules.xml"
echo "<?xml version=\"1.0\"?>" > "${rulefile}"
if [ ! -z "${rules}" ]; then
for r in ${@" ".join(find_cfgs(d))}; do
cat ${r} >> "${rulefile}"
done
fi
}

do_install() {
install -d "${D}${datadir}"
install "${WORKDIR}/suppress" "${D}${datadir}/cppcheck-recipe-suppress"
install "${WORKDIR}/fatal" "${D}${datadir}/cppcheck-recipe-fatal"
install "${WORKDIR}/user-rules.xml" "${D}${datadir}/cppcheck-user-rules.xml"
}

FILES:${PN} = "${datadir}"
9 changes: 2 additions & 7 deletions recipes-sca/cppcheck-native/cppcheck-native_2.9.bb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ LIC_FILES_CHKSUM = "\
file://externals/picojson/LICENSE;md5=29d6d693711f69885bbfe08072624f2e \
"

SRC_URI = "\
git://github.com/danmar/cppcheck.git;protocol=https;nobranch=1 \
file://0001-Makefile-fixes.patch \
"
SRC_URI = "git://github.com/danmar/cppcheck.git;protocol=https;nobranch=1"
SRCREV = "aca3f6fefa6d6b8c5915f15035c7e5908961f6f1"

S = "${WORKDIR}/git"
Expand All @@ -23,11 +20,9 @@ inherit pkgconfig
inherit sca-description
inherit native

LIBPCRE = "libpcre-native"
LIBZ3 = "z3-native"

PACKAGECONFIG ??= "rules z3"
PACKAGECONFIG[rules] = "HAVE_RULES=yes,,${LIBPCRE}"
PACKAGECONFIG ??= "z3"
PACKAGECONFIG[z3] = "USE_Z3=yes,,${LIBZ3}"

SCA_TOOL_DESCRIPTION = "cppcheck"
Expand Down
33 changes: 0 additions & 33 deletions recipes-sca/cppcheck-native/files/0001-Makefile-fixes.patch

This file was deleted.

9 changes: 2 additions & 7 deletions recipes-sca/cppcheck-native/nativesdk-cppcheck_2.9.bb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ LIC_FILES_CHKSUM = "\
file://externals/picojson/LICENSE;md5=29d6d693711f69885bbfe08072624f2e \
"

SRC_URI = "\
git://github.com/danmar/cppcheck.git;protocol=https;nobranch=1 \
file://0001-Makefile-fixes.patch \
"
SRC_URI = "git://github.com/danmar/cppcheck.git;protocol=https;nobranch=1"
SRCREV = "aca3f6fefa6d6b8c5915f15035c7e5908961f6f1"

S = "${WORKDIR}/git"
Expand All @@ -23,10 +20,8 @@ inherit pkgconfig

inherit sca-description
inherit nativesdk
LIBPCRE = "nativesdk-libpcre"
LIBZ3 = "nativesdk-z3"
PACKAGECONFIG ??= "rules z3"
PACKAGECONFIG[rules] = "HAVE_RULES=yes,,${LIBPCRE}"
PACKAGECONFIG ??= "z3"
PACKAGECONFIG[z3] = "USE_Z3=yes,,${LIBZ3}"
SCA_TOOL_DESCRIPTION = "cppcheck"
do_compile() {
Expand Down

0 comments on commit 49d07f3

Please sign in to comment.