Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cppcheck] Add version 2.9.1 #14149

Merged
merged 68 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
9730f93
Merge pull request #1 from conan-io/master
Sneder89 Nov 10, 2022
066ae22
Merge branch 'conan-io:master' into master
Sneder89 Nov 10, 2022
5c4559a
Update conandata.yml
Sneder89 Nov 10, 2022
114d9da
Update config.yml
Sneder89 Nov 10, 2022
a50f637
Update conanfile.py
Sneder89 Nov 10, 2022
9b03147
Update conanfile.py
Sneder89 Nov 10, 2022
531c2cc
Merge branch 'conan-io:master' into add-new-cppcheck-versions
Sneder89 Nov 14, 2022
f67f5a9
Update conandata.yml
Sneder89 Nov 14, 2022
05a1f72
Update recipes/cppcheck/all/conanfile.py
Sneder89 Nov 14, 2022
10f9d5e
Update conanfile.py
Sneder89 Nov 14, 2022
9676552
Update conandata.yml
Sneder89 Nov 14, 2022
4063067
Update conanfile.py
Sneder89 Nov 14, 2022
86b9e34
Update conandata.yml
Sneder89 Nov 14, 2022
0f2b2b3
Update conanfile.py
Sneder89 Nov 14, 2022
1dd7b53
Update config.yml
Sneder89 Nov 14, 2022
a452dcc
Delete recipes/cppcheck/all/patches directory
Sneder89 Nov 14, 2022
4339b8a
Update conanfile.py
Sneder89 Nov 14, 2022
5bbf062
Update conanfile.py
Sneder89 Nov 14, 2022
df72e43
Update recipes/cppcheck/all/test_package/conanfile.py
Sneder89 Nov 14, 2022
ec1e2ec
Update recipes/cppcheck/all/test_package/conanfile.py
Sneder89 Nov 14, 2022
72cd7cb
Update recipes/cppcheck/all/test_package/conanfile.py
Sneder89 Nov 14, 2022
ebc7804
Update conanfile.py
Sneder89 Nov 14, 2022
976c112
Update conanfile.py
Sneder89 Nov 14, 2022
b5a038f
Update conanfile.py
Sneder89 Nov 14, 2022
d77dd0d
Update conanfile.py
Sneder89 Nov 15, 2022
00bbc49
Merge branch 'conan-io:master' into add-new-cppcheck-versions
Sneder89 Nov 15, 2022
dd2acda
Update conanfile.py
Sneder89 Nov 15, 2022
65da535
Update conanfile.py
Sneder89 Nov 15, 2022
e2f9b32
Update conanfile.py
Sneder89 Nov 15, 2022
ea1e5e7
Update conanfile.py
Sneder89 Nov 15, 2022
e4c366b
Update config.yml
Sneder89 Nov 15, 2022
a24240a
Update conandata.yml
Sneder89 Nov 15, 2022
bcc3534
changes
Sneder89 Nov 15, 2022
f554350
changes
Sneder89 Nov 16, 2022
f37bbc1
Update conandata.yml
Sneder89 Nov 16, 2022
ad4c120
Update conanfile.py
Sneder89 Nov 16, 2022
b9505d0
Update conanfile.py
Sneder89 Nov 16, 2022
37302c6
Update conanfile.py
Sneder89 Nov 17, 2022
a66c5a1
Update conanfile.py
Sneder89 Nov 17, 2022
42952e5
Update recipes/cppcheck/all/conanfile.py
Sneder89 Nov 17, 2022
99c3348
Update recipes/cppcheck/all/conanfile.py
Sneder89 Nov 17, 2022
b9456c1
Update conanfile.py
Sneder89 Nov 17, 2022
25679b1
Update recipes/cppcheck/all/conanfile.py
Sneder89 Nov 17, 2022
ca0d6d6
Update recipes/cppcheck/all/conanfile.py
Sneder89 Nov 18, 2022
f5cc2d7
Update conanfile.py
Sneder89 Nov 21, 2022
bef7fb4
Update conanfile.py
Sneder89 Nov 21, 2022
ef656c1
Update conanfile.py
Sneder89 Nov 21, 2022
d6f5067
get test package working
Sneder89 Nov 23, 2022
d7a26a7
add v1 test package
Sneder89 Nov 23, 2022
9474cd8
moved changes from replace to file to patches
Sneder89 Nov 23, 2022
1e32c7f
Update conanfile.py
Sneder89 Nov 23, 2022
f4c12e0
Update conanfile.py
Sneder89 Nov 24, 2022
a09e6a5
Update conanfile.py
Sneder89 Nov 24, 2022
677a868
Update 0003-pcre-debuglib-name-2.7.patch
Sneder89 Nov 24, 2022
2e0c5bf
Update 0003-pcre-debuglib-name-2.7.patch
Sneder89 Nov 24, 2022
f4b5353
Update 0003-pcre-debuglib-name-2.7.patch
Sneder89 Nov 24, 2022
564733c
Update 0003-pcre-debuglib-name-2.7.patch
Sneder89 Nov 24, 2022
c582056
Update 0003-pcre-debuglib-name-2.7.patch
Sneder89 Nov 24, 2022
abd73fa
Update 0003-pcre-debuglib-name-2.7.patch
Sneder89 Nov 24, 2022
4727039
Update 0003-pcre-debuglib-name-2.7.patch
Sneder89 Nov 24, 2022
aca06fe
Update 0003-pcre-debuglib-name-2.7.patch
Sneder89 Nov 24, 2022
a6bb28e
Update conanfile.py
Sneder89 Nov 25, 2022
7a3131c
Update recipes/cppcheck/all/conanfile.py
Sneder89 Nov 27, 2022
e71f6d0
Update recipes/cppcheck/all/conanfile.py
Sneder89 Nov 27, 2022
bfabc97
Update recipes/cppcheck/all/conanfile.py
Sneder89 Nov 27, 2022
bd67112
Update recipes/cppcheck/all/conanfile.py
Sneder89 Nov 27, 2022
01fa00a
Update recipes/cppcheck/all/conanfile.py
Sneder89 Nov 27, 2022
3247619
use tool_requires in test package, add required fields in conandata.y…
Sneder89 Nov 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions recipes/cppcheck/all/CMakeLists.txt

This file was deleted.

30 changes: 15 additions & 15 deletions recipes/cppcheck/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
sources:
"2.9.2":
url: "https://github.com/danmar/cppcheck/archive/2.9.2.tar.gz"
sha256: "93920d24d4442856bf7916ee0e3fc31308bc23948e7029b4fd332e01cac63c3e"
"2.8.2":
url: "https://github.com/danmar/cppcheck/archive/2.8.2.tar.gz"
sha256: "30ba99ab54089c44b83f02e2453da046a7edff5237950d4A0eb1eba4afcb4f45"
"2.7.5":
Sneder89 marked this conversation as resolved.
Show resolved Hide resolved
url: "https://github.com/danmar/cppcheck/archive/2.7.5.tar.gz"
sha256: "6c7ac29e57fa8b3ac7be224510200e579d5a90217e2152591ef46ffc947d8f78"
"2.7.4":
url: "https://github.com/danmar/cppcheck/archive/2.7.4.tar.gz"
sha256: "f0558c497b7807763325f3a821f1c72b743e5d888b037b8d32157dd07d6c26e1"
patches:
"2.7.5":
- patch_file: "patches/0001-cmake-source-dir-2.5.patch"
base_path: "source_subfolder"
"2.9.2":
- patch_file: "patches/0001-cli-remove-dmake-cmake.patch"
- patch_file: "patches/0002-htmlreport-python3.patch"
- patch_file: "patches/0003-pcre-debuglib-name.patch"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"2.8.2":
- patch_file: "patches/0001-cli-remove-dmake-cmake-2.8.patch"
- patch_file: "patches/0002-htmlreport-python3.patch"
base_path: "source_subfolder"
- patch_file: "patches/0003-handle-exename-on-macos.patch"
base_path: "source_subfolder"
"2.7.4":
- patch_file: "patches/0001-cmake-source-dir-2.5.patch"
base_path: "source_subfolder"
- patch_file: "patches/0003-pcre-debuglib-name.patch"
"2.7.5":
- patch_file: "patches/0002-htmlreport-python3.patch"
base_path: "source_subfolder"
- patch_file: "patches/0003-handle-exename-on-macos.patch"
base_path: "source_subfolder"
- patch_file: "patches/0003-pcre-debuglib-name-2.7.patch"
86 changes: 47 additions & 39 deletions recipes/cppcheck/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,82 @@
from conans import ConanFile, CMake, tools
import functools
from conan import ConanFile
from conan.tools.apple import is_apple_os
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
from conan.tools.scm import Version
import os

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.46.0"
Sneder89 marked this conversation as resolved.
Show resolved Hide resolved


class CppcheckConan(ConanFile):
name = "cppcheck"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/danmar/cppcheck"
topics = ("Cpp Check", "static analyzer")
topics = ("code quality", "static analyzer", "linter")
description = "Cppcheck is an analysis tool for C/C++ code."
license = "GPL-3.0-or-later"
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
options = {"with_z3": [True, False], "have_rules": [True, False]}
default_options = {"with_z3": True, "have_rules": True}
exports_sources = ["CMakeLists.txt", "patches/**"]

@property
def _source_subfolder(self):
return "source_subfolder"
def layout(self):
cmake_layout(self)

@property
def _build_subfolder(self):
return "build_subfolder"
def export_sources(self):
export_conandata_patches(self)

def _patch_sources(self):
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)
tools.replace_in_file(os.path.join(self._source_subfolder, "cli", "CMakeLists.txt"),
"RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}",
"DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}")
def config_options(self):
if Version(self.version) >= Version("2.8.0"):
del self.options.with_z3

def package_id(self):
del self.info.options.with_z3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be required 🤔 we want it to change 2.8.0 and once it's deleted in config options than it's not taken into account

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I removed that from the package_id method


def requirements(self):
if self.options.with_z3:
if Version(self.version) < Version("2.8.0") and self.options.with_z3:
Sneder89 marked this conversation as resolved.
Show resolved Hide resolved
self.requires("z3/4.8.8")
if self.options.have_rules:
self.requires("pcre/8.45")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

@functools.lru_cache(1)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["USE_Z3"] = self.options.with_z3
cmake.definitions["HAVE_RULES"] = self.options.have_rules
cmake.definitions["USE_MATCHCOMPILER"] = "Auto"
cmake.definitions["ENABLE_OSS_FUZZ"] = False
cmake.configure(build_folder=self._build_subfolder)
return cmake
def generate(self):
tc = CMakeToolchain(self)
if Version(self.version) < Version("2.8.0"):
Sneder89 marked this conversation as resolved.
Show resolved Hide resolved
tc.variables["USE_Z3"] = self.options.with_z3
tc.variables["HAVE_RULES"] = self.options.have_rules
tc.variables["USE_MATCHCOMPILER"] = "Auto"
tc.variables["ENABLE_OSS_FUZZ"] = False
if is_apple_os(self):
tc.variables["FILESDIR"] = os.path.join(self.package_folder, "bin", "cfg")
tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
self._patch_sources()
cmake = self._configure_cmake()
cmake = CMake(self)
apply_conandata_patches(self)
Sneder89 marked this conversation as resolved.
Show resolved Hide resolved
cmake.configure()
cmake.build()

def package(self):
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
self.copy("*", dst=os.path.join("bin","cfg"), src=os.path.join(self._source_subfolder,"cfg"))
self.copy("cppcheck-htmlreport", dst=os.path.join("bin"), src=os.path.join(self._source_subfolder,"htmlreport"))
cmake = self._configure_cmake()
copy(self, "COPYING", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder))
copy(self, "*", dst=os.path.join(self.package_folder, "bin", "cfg"), src=os.path.join(self.source_folder, "cfg"))
copy(self, "cppcheck-htmlreport", dst=os.path.join(self.package_folder, "bin"), src=os.path.join(self.source_folder, "htmlreport"))
cmake = CMake(self)
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []

bin_folder = os.path.join(self.package_folder, "bin")
self.output.info("Append %s to environment variable PATH" % bin_folder)
self.env_info.PATH.append(bin_folder)
# This is required to run the python script on windows, as we cannot simply add it to the PATH
self.env_info.CPPCHECK_HTMLREPORT = os.path.join(bin_folder, "cppcheck-htmlreport")
self.runenv_info.append_path("PATH", bin_folder)
Sneder89 marked this conversation as resolved.
Show resolved Hide resolved
cppcheck_htmlreport = os.path.join(bin_folder, "cppcheck-htmlreport")
self.env_info.CPPCHECK_HTMLREPORT = cppcheck_htmlreport
self.runenv_info.define_path("CPPCHECK_HTMLREPORT", cppcheck_htmlreport)
14 changes: 14 additions & 0 deletions recipes/cppcheck/all/patches/0001-cli-remove-dmake-cmake-2.8.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/cli/CMakeLists.txt 2022-07-12 23:11:29.000000000 +0200
+++ b/cli/CMakeLists.txt 2022-11-23 22:01:29.111581500 +0100
@@ -45,10 +45,9 @@

add_dependencies(cppcheck copy_cfg)
add_dependencies(cppcheck copy_addons)
-add_dependencies(cppcheck run-dmake)

install(TARGETS cppcheck
- RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
+ DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
COMPONENT applications)

install(FILES ${addons}
14 changes: 14 additions & 0 deletions recipes/cppcheck/all/patches/0001-cli-remove-dmake-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/cli/CMakeLists.txt 2022-11-08 20:22:59.000000000 +0100
+++ b/cli/CMakeLists.txt 2022-11-23 21:33:49.347849300 +0100
@@ -43,10 +43,9 @@

add_dependencies(cppcheck copy_cfg)
add_dependencies(cppcheck copy_addons)
-add_dependencies(cppcheck run-dmake)

install(TARGETS cppcheck
- RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
+ DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
COMPONENT applications)

install(FILES ${addons}
36 changes: 0 additions & 36 deletions recipes/cppcheck/all/patches/0001-cmake-source-dir-2.5.patch

This file was deleted.

35 changes: 0 additions & 35 deletions recipes/cppcheck/all/patches/0001-cmake-source-dir.patch

This file was deleted.

35 changes: 0 additions & 35 deletions recipes/cppcheck/all/patches/0003-handle-exename-on-macos.patch

This file was deleted.

28 changes: 28 additions & 0 deletions recipes/cppcheck/all/patches/0003-pcre-debuglib-name-2.7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--- a/cmake/findDependencies.cmake 2022-04-15 20:23:30.000000000 +0200
+++ b/cmake/findDependencies.cmake 2022-11-24 13:57:22.099453500 +0100
@@ -16,7 +16,7 @@

if (HAVE_RULES)
find_path(PCRE_INCLUDE pcre.h)
- find_library(PCRE_LIBRARY pcre)
+ find_library(PCRE_LIBRARY NAMES pcre pcred)
if (NOT PCRE_LIBRARY OR NOT PCRE_INCLUDE)
message(FATAL_ERROR "pcre dependency for RULES has not been found")
endif()
@@ -24,16 +24,8 @@

if (USE_Z3)
find_package(Z3 QUIET)
- if (NOT Z3_FOUND)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait I am confused --- When is this option added? this is a new patch but I thought the option was removed 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I made some changes to the patch. z3 is still required for 2.7.5, but removed for 2.8 and above. So if 2.10 is released, somebody can remove all these things.

find_library(Z3_LIBRARIES z3)
- if (NOT Z3_LIBRARIES)
- message(FATAL_ERROR "z3 dependency has not been found")
- endif()
find_path(Z3_CXX_INCLUDE_DIRS z3++.h PATH_SUFFIXES "z3")
- if (NOT Z3_CXX_INCLUDE_DIRS)
- message(FATAL_ERROR "z3++.h has not been found")
- endif()
- endif()
endif()

set(CMAKE_INCLUDE_CURRENT_DIR ON)
11 changes: 11 additions & 0 deletions recipes/cppcheck/all/patches/0003-pcre-debuglib-name.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/cmake/findDependencies.cmake 2022-11-08 20:22:59.000000000 +0100
+++ b/cmake/findDependencies.cmake 2022-11-23 21:29:50.222152900 +0100
@@ -36,7 +36,7 @@

if (HAVE_RULES)
find_path(PCRE_INCLUDE pcre.h)
- find_library(PCRE_LIBRARY pcre)
+ find_library(PCRE_LIBRARY NAMES pcre pcred)
if (NOT PCRE_LIBRARY OR NOT PCRE_INCLUDE)
message(FATAL_ERROR "pcre dependency for RULES has not been found")
endif()
21 changes: 11 additions & 10 deletions recipes/cppcheck/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
from conans import ConanFile, tools
from conan import ConanFile
from conan.tools.build import can_run
import sys
import os
import shutil


class TestPackageConan(ConanFile):
settings = "os", "arch"
generators = "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a tool rquires?


def test(self):
shutil.copy(os.path.join(self.source_folder, "file_to_check.cpp"),
os.path.join(self.build_folder, "file_to_check.cpp"))
if not tools.cross_building(self.settings):
if can_run(self):
self.run("cppcheck --enable=warning,style,performance --std=c++11 .",
cwd=self.source_folder, run_environment=True)
# On windows we need to explicitly use python to run the python script
if self.settings.os == 'Windows':
self.run("{} {} -h".format(sys.executable, tools.get_env("CPPCHECK_HTMLREPORT")))
cwd=self.source_folder, run_environment=True)
if self.settings.os == "Windows":
self.run(f"{sys.executable} %CPPCHECK_HTMLREPORT% -h", run_environment=True)
else:
self.run("cppcheck-htmlreport -h", run_environment=True)
Loading