Skip to content

Commit

Permalink
(#14149) [cppcheck] Add version 2.9.1
Browse files Browse the repository at this point in the history
* Update conandata.yml

* Update config.yml

* Update conanfile.py

* Update conanfile.py

* Update conandata.yml

* Update recipes/cppcheck/all/conanfile.py

Co-authored-by: Martin Delille <martin@delille.org>

* Update conanfile.py

* Update conandata.yml

* Update conanfile.py

* Update conandata.yml

* Update conanfile.py

* Update config.yml

* Delete recipes/cppcheck/all/patches directory

* Update conanfile.py

* Update conanfile.py

* Update recipes/cppcheck/all/test_package/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/cppcheck/all/test_package/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/cppcheck/all/test_package/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update conanfile.py

* Update conanfile.py

* Update conanfile.py

* Update conanfile.py

* Update conanfile.py

* Update conanfile.py

* Update conanfile.py

* Update conanfile.py

* Update config.yml

* Update conandata.yml

* changes

* changes

* Update conandata.yml

* Update conanfile.py

* Update conanfile.py

* Update conanfile.py

* Update conanfile.py

* Update recipes/cppcheck/all/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update recipes/cppcheck/all/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update conanfile.py

* Update recipes/cppcheck/all/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update recipes/cppcheck/all/conanfile.py

Co-authored-by: Martin Delille <martin@delille.org>

* Update conanfile.py

* Update conanfile.py

* Update conanfile.py

* get test package working

* add v1 test package

* moved changes from replace to file to patches

* Update conanfile.py

* Update conanfile.py

* Update conanfile.py

* Update 0003-pcre-debuglib-name-2.7.patch

* Update 0003-pcre-debuglib-name-2.7.patch

* Update 0003-pcre-debuglib-name-2.7.patch

* Update 0003-pcre-debuglib-name-2.7.patch

* Update 0003-pcre-debuglib-name-2.7.patch

* Update 0003-pcre-debuglib-name-2.7.patch

* Update 0003-pcre-debuglib-name-2.7.patch

* Update 0003-pcre-debuglib-name-2.7.patch

* Update conanfile.py

* Update recipes/cppcheck/all/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update recipes/cppcheck/all/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update recipes/cppcheck/all/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update recipes/cppcheck/all/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update recipes/cppcheck/all/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* use tool_requires in test package, add required fields in conandata.yml file

Co-authored-by: Martin Delille <martin@delille.org>
Co-authored-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
  • Loading branch information
4 people authored Nov 28, 2022
1 parent bba092e commit afcf3ba
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 186 deletions.
14 changes: 0 additions & 14 deletions recipes/cppcheck/all/CMakeLists.txt

This file was deleted.

46 changes: 31 additions & 15 deletions recipes/cppcheck/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
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":
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_description: "Remove dmake tool from target ALL"
patch_type: "portability"
- patch_file: "patches/0002-htmlreport-python3.patch"
patch_description: "Use Python 3 in Shebang Header"
patch_type: "portability"
- patch_file: "patches/0003-pcre-debuglib-name.patch"
patch_description: "Consider the Debug suffix for Windows"
patch_type: "portability"
"2.8.2":
- patch_file: "patches/0001-cli-remove-dmake-cmake-2.8.patch"
patch_description: "Remove dmake tool from target ALL"
patch_type: "portability"
- 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_description: "Use Python 3 in Shebang Header"
patch_type: "portability"
- patch_file: "patches/0003-pcre-debuglib-name.patch"
patch_description: "Consider the Debug suffix for Windows"
patch_type: "portability"
"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_description: "Use Python 3 in Shebang Header"
patch_type: "portability"
- patch_file: "patches/0003-pcre-debuglib-name-2.7.patch"
patch_description: "Consider the Debug suffix for Windows"
patch_type: "portability"
82 changes: 43 additions & 39 deletions recipes/cppcheck/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,78 @@
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.52.0"


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 requirements(self):
if self.options.with_z3:
if self.options.get_safe("with_z3", default=False):
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) < "2.8.0":
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()
apply_conandata_patches(self)
cmake = CMake(self)
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")
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)
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 build_requirements(self):
self.tool_requires(self.tested_reference_str)

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

0 comments on commit afcf3ba

Please sign in to comment.