-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
71 additions
and
55 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]") | ||
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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |