From 40b7c01b8484360397a115a3ba80ac9f096c80eb Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 16 Jan 2024 14:43:06 +0200 Subject: [PATCH] ignition-tools: do not export a library, update test_package accordingly --- recipes/ignition-tools/all/conanfile.py | 44 ++++++++----------- .../all/test_package/CMakeLists.txt | 18 -------- .../all/test_package/conanfile.py | 30 ++++--------- .../all/test_package/test_package.cpp | 5 --- 4 files changed, 27 insertions(+), 70 deletions(-) delete mode 100644 recipes/ignition-tools/all/test_package/CMakeLists.txt delete mode 100644 recipes/ignition-tools/all/test_package/test_package.cpp diff --git a/recipes/ignition-tools/all/conanfile.py b/recipes/ignition-tools/all/conanfile.py index e6a5d1fe1b981b..1a952d068e8ed0 100644 --- a/recipes/ignition-tools/all/conanfile.py +++ b/recipes/ignition-tools/all/conanfile.py @@ -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) @@ -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 "" @@ -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) diff --git a/recipes/ignition-tools/all/test_package/CMakeLists.txt b/recipes/ignition-tools/all/test_package/CMakeLists.txt deleted file mode 100644 index a3968e98e25dd4..00000000000000 --- a/recipes/ignition-tools/all/test_package/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 3.15) -project(test_package LANGUAGES CXX) - -set(IGN_TOOLS_MAJOR_VER "" CACHE STRING "Version of igition-tools") - -if(NOT IGN_TOOLS_MAJOR_VER) - message(FATAL_ERROR "IGN_MAJOR_MAJOR_VER not set") -endif() - -find_package(ignition-tools${IGN_TOOLS_MAJOR_VER} REQUIRED CONFIG) - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ignition-tools${IGN_TOOLS_MAJOR_VER}::ignition-tools${IGN_TOOLS_MAJOR_VER}) -set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED ON - CXX_EXTENSIONS ON -) diff --git a/recipes/ignition-tools/all/test_package/conanfile.py b/recipes/ignition-tools/all/test_package/conanfile.py index b1040edb571c85..871b2e239dd5a8 100644 --- a/recipes/ignition-tools/all/test_package/conanfile.py +++ b/recipes/ignition-tools/all/test_package/conanfile.py @@ -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") diff --git a/recipes/ignition-tools/all/test_package/test_package.cpp b/recipes/ignition-tools/all/test_package/test_package.cpp deleted file mode 100644 index e7e472dbae28ae..00000000000000 --- a/recipes/ignition-tools/all/test_package/test_package.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - std::cout << "Hello from ignition-tools test_package\n"; -}