diff --git a/recipes/kcov/all/CMakeLists.txt b/recipes/kcov/all/CMakeLists.txt deleted file mode 100644 index a69305eb3971f9..00000000000000 --- a/recipes/kcov/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/kcov/all/conandata.yml b/recipes/kcov/all/conandata.yml index b98fb5f6098f56..3ef0bf1e4dfd17 100644 --- a/recipes/kcov/all/conandata.yml +++ b/recipes/kcov/all/conandata.yml @@ -9,6 +9,4 @@ patches: "40": [] "38": - patch_file: "patches/0001-fix-SOLIB-path.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-fix-missing-libssl-dependency.patch" - base_path: "source_subfolder" diff --git a/recipes/kcov/all/conanfile.py b/recipes/kcov/all/conanfile.py index 563b33b2f010e9..a962ae19660ca5 100644 --- a/recipes/kcov/all/conanfile.py +++ b/recipes/kcov/all/conanfile.py @@ -1,63 +1,75 @@ import os + from conan import ConanFile -from conans import CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir + +required_conan_version = ">=1.47.0" + class KcovConan(ConanFile): name = "kcov" + description = ( + "Code coverage tool for compiled programs, Python and Bash which uses " + "debugging information to collect and report data without special compilation options" + ) license = "GPL-2.0" - url = "https://github.com/conan-io/conan-center-index/" + url = "https://github.com/conan-io/conan-center-index" homepage = "http://simonkagstrom.github.io/kcov/index.html" - description = "Code coverage tool for compiled programs, Python and Bash\ - which uses debugging information to collect and report data without\ - special compilation options" topics = ("coverage", "linux", "debug") - settings = "os", "compiler", "build_type", "arch" - exports_sources = "CMakeLists.txt", "patches/**" - requires = ["zlib/1.2.12", - "libiberty/9.1.0", - "libcurl/7.83.1", - "elfutils/0.180"] - generators = "cmake" - _cmake = None - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" - - def configure(self): + + package_type = "application" + settings = "os", "arch", "compiler", "build_type" + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("zlib/1.2.13") + self.requires("libiberty/9.1.0") + self.requires("libcurl/[>=7.78 <9]") + self.requires("elfutils/0.186") + + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type + + def validate(self): if self.settings.os == "Windows": - raise ConanInvalidConfiguration( - "kcov can not be built on windows.") + raise ConanInvalidConfiguration("kcov can not be built on windows.") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + get(self, **self.conan_data["sources"][self.version], strip_root=True) - def _configure_cmake(self): - if self._cmake is not None: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + tc = CMakeDeps(self) + tc.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): - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - self.copy("COPYING*", dst="licenses", src=self._source_subfolder) + rmdir(self, os.path.join(self.package_folder, "share")) + copy(self, "COPYING*", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) def package_info(self): + self.cpp_info.includedirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 bindir = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}" - .format(bindir)) + self.output.info(f"Appending PATH environment variable: {bindir}") self.env_info.PATH.append(bindir) - self.cpp_info.includedirs = [] diff --git a/recipes/kcov/all/test_package/conanfile.py b/recipes/kcov/all/test_package/conanfile.py index ea5ad0c50ed3e3..698c29f674eeb2 100644 --- a/recipes/kcov/all/test_package/conanfile.py +++ b/recipes/kcov/all/test_package/conanfile.py @@ -1,9 +1,13 @@ -from conans import ConanFile, tools +from conan import ConanFile -class KcovTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) def test(self): - if not tools.cross_building(self.settings): - self.run("kcov --version", run_environment=True) + self.run("kcov --version") diff --git a/recipes/kcov/all/test_v1_package/conanfile.py b/recipes/kcov/all/test_v1_package/conanfile.py new file mode 100644 index 00000000000000..ea5ad0c50ed3e3 --- /dev/null +++ b/recipes/kcov/all/test_v1_package/conanfile.py @@ -0,0 +1,9 @@ +from conans import ConanFile, tools + + +class KcovTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + + def test(self): + if not tools.cross_building(self.settings): + self.run("kcov --version", run_environment=True)