Skip to content

Commit

Permalink
ignition-tools: do not export a library, update test_package accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Jan 16, 2024
1 parent 3539503 commit 40b7c01
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 70 deletions.
44 changes: 18 additions & 26 deletions recipes/ignition-tools/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._minimum_cpp_standard)
min_version = self._minimum_compilers_version.get(str(self.settings.compiler))
if not min_version:
self.output.warning(
f"{self.name} recipe lacks information about the {self.settings.compiler} compiler support."
if min_version and Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration(
f"{self.name} requires c++17 support. "
f"The current compiler {self.settings.compiler} {self.settings.compiler.version} does not support it."
)
else:
if Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration(
f"{self.name} requires c++17 support. "
f"The current compiler {self.settings.compiler} {self.settings.compiler.version} does not support it."
)

def build_requirements(self):
# FIXME: Ruby is required as a transitive dependency for the `ign` Ruby script
# FIXME: The ign script has additional Ruby dependencies
# self.tool_requires("ruby/3.1.0")
pass

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
Expand Down Expand Up @@ -95,6 +96,7 @@ def package(self):

# Generate ign.rb
ign_rb_content = load(self, os.path.join(self.source_folder, "src", "ign.in"))
# FIXME: this is not relocatable
ign_rb_content = ign_rb_content.replace("@CMAKE_INSTALL_PREFIX@", self.package_folder.replace("\\", "/"))
ign_rb_content = ign_rb_content.replace("@ENV_PATH_DELIMITER@", os.pathsep)
suffix = ".rb" if self.settings.os == "Windows" else ""
Expand All @@ -112,21 +114,11 @@ def package(self):

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

# The package builds an ignition-tools-backward wrapper library,
# but it's only meant to be used as a runtime dependency of the ign script

version_major = Version(self.version).major
pkg_name = f"ignition-tools{version_major}"
self.cpp_info.set_property("cmake_file_name", pkg_name)
self.cpp_info.set_property("cmake_target_name", f"{pkg_name}::{pkg_name}")

component = self.cpp_info.components["libignition-tools"]
component.includedirs = []
component.libs = ["ignition-tools-backward"]
component.requires = ["backward-cpp::backward-cpp"]
component.set_property("cmake_target_name", pkg_name)
component.set_property("pkg_config_name", pkg_name)

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.names["cmake_find_package"] = pkg_name
self.cpp_info.names["cmake_find_package_multi"] = pkg_name
component.names["cmake_find_package"] = pkg_name
component.names["cmake_find_package_multi"] = pkg_name
# TODO: Legacy, to be removed on Conan 2.0
bin_folder = os.path.join(self.package_folder, "bin")
self.env_info.PATH.append(bin_folder)
18 changes: 0 additions & 18 deletions recipes/ignition-tools/all/test_package/CMakeLists.txt

This file was deleted.

30 changes: 9 additions & 21 deletions recipes/ignition-tools/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
import os

from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
from conan.tools.scm import Version
from conan.tools.layout import basic_layout


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

def requirements(self):
self.requires(self.tested_reference_str)
self.requires(self.tested_reference_str, run=True)

def layout(self):
cmake_layout(self)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["IGN_TOOLS_MAJOR_VER"] = Version(self.dependencies["ignition-tools"].ref.version).major
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
basic_layout(self)

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
# FIXME: Can't actually run this since Ruby and required Ruby gems are not set up
if self.settings.os == "Windows":
self.run("where ign", scope="conanrun")
else:
self.run("which ign", scope="conanrun")
5 changes: 0 additions & 5 deletions recipes/ignition-tools/all/test_package/test_package.cpp

This file was deleted.

0 comments on commit 40b7c01

Please sign in to comment.