From 1791c17577287717616911c13a75982f0aac1197 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 10 Feb 2023 11:07:59 +0100 Subject: [PATCH] (#15841) openssl 1.x.x: modernize a little bit more + do not skip tests if macOS armv8 shared * modernize more * do not skip tests if macOS armv8 shared * typo --- recipes/openssl/1.x.x/conanfile.py | 23 ++------- .../openssl/1.x.x/test_package/conanfile.py | 48 +++---------------- .../1.x.x/test_v1_package/conanfile.py | 38 +++++---------- 3 files changed, 24 insertions(+), 85 deletions(-) diff --git a/recipes/openssl/1.x.x/conanfile.py b/recipes/openssl/1.x.x/conanfile.py index 2daf4aa9ca0017..4a1bb6ee9b0f64 100644 --- a/recipes/openssl/1.x.x/conanfile.py +++ b/recipes/openssl/1.x.x/conanfile.py @@ -273,10 +273,8 @@ def generate(self): gen_info["CXXFLAGS"] = tc.cxxflags gen_info["DEFINES"] = tc.defines gen_info["LDFLAGS"] = tc.ldflags - # Support for self.dependencies in build() method is currently restricted to `generate()` and `validate()` - # See https://github.com/conan-io/conan/issues/12411 for more details if self._full_version < "1.1.0" and not self.options.get_safe("no_zlib"): - zlib_cpp_info = self.dependencies["zlib"].cpp_info + zlib_cpp_info = self.dependencies["zlib"].cpp_info.aggregated_components() gen_info["zlib_include_path"] = zlib_cpp_info.includedirs[0] if self.settings.os == "Windows": gen_info["zlib_lib_path"] = f"{zlib_cpp_info.libdirs[0]}/{zlib_cpp_info.libs[0]}.lib" @@ -573,16 +571,10 @@ def _configure_args(self): include_path = self._adjust_path(include_path) lib_path = self._adjust_path(lib_path) - if Version(conan_version).major <2 : - if self.options["zlib"].shared: - args.append("zlib-dynamic") - else: - args.append("zlib") + if self.dependencies["zlib"].options.shared: + args.append("zlib-dynamic") else: - if self.dependencies["zlib"].options.shared: - args.append("zlib-dynamic") - else: - args.append("zlib") + args.append("zlib") args.extend(['--with-zlib-include="%s"' % include_path, '--with-zlib-lib="%s"' % lib_path]) @@ -681,12 +673,7 @@ def _create_targets(self): @property def _perl(self): if self._use_nmake: - # enforce strawberry perl, otherwise wrong perl could be used (from Git bash, MSYS, etc.) - build_deps = (dependency.ref.name for require, dependency in self.dependencies.build.items()) - if "strawberryperl" in build_deps: - return os.path.join(self.dependencies.build["strawberryperl"].package_folder, "bin", "perl.exe") - if hasattr(self, "user_info_build") and "strawberryperl" in self.user_info_build: - return self.user_info_build["strawberryperl"].perl + return self.dependencies.build["strawberryperl"].conf_info.get("user.strawberryperl:perl", check_type=str) return "perl" @property diff --git a/recipes/openssl/1.x.x/test_package/conanfile.py b/recipes/openssl/1.x.x/test_package/conanfile.py index ef4c0e036136c3..5bbdbb3e0e7bc7 100644 --- a/recipes/openssl/1.x.x/test_package/conanfile.py +++ b/recipes/openssl/1.x.x/test_package/conanfile.py @@ -1,10 +1,7 @@ from conan import ConanFile -from conan.tools.scm import Version from conan.tools.build import can_run from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain -from conan.tools.files import save, load import os -import json class TestPackageConan(ConanFile): @@ -12,54 +9,23 @@ class TestPackageConan(ConanFile): generators = "CMakeDeps", "VirtualRunEnv" test_type = "explicit" - @property - def _skip_test_filename(self): - return os.path.join(self.build_folder, "skip_test.json") - - def _generate_skip_test_file(self): - # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being - # set. This could be because you are using a Mac OS X version less than 10.5 - # or because CMake's platform configuration is corrupt. - # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. - # Actually the workaround should be to add cmake/3.22.0 to build requires, - # but for the specific case of openssl it fails because it is also a requirement of cmake. - # see https://github.com/conan-io/conan/pull/9839 - dict_test = {"skip_test": self.settings.os == "Macos" and \ - self.settings.arch == "armv8" and \ - bool(self.dependencies[self.tested_reference_str].options.shared)} - save(self, self._skip_test_filename, json.dumps(dict_test)) - - @property - def _skip_test(self): - return bool(json.loads(load(self, self._skip_test_filename)).get("skip_test")) + def layout(self): + cmake_layout(self) def requirements(self): self.requires(self.tested_reference_str) - def layout(self): - cmake_layout(self) - def generate(self): tc = CMakeToolchain(self) - if self.settings.os == "Android": - tc.cache_variables["CONAN_LIBCXX"] = "" - openssl = self.dependencies[self.tested_reference_str] - openssl_version = Version(openssl.ref.version) - if openssl_version.major == "1" and openssl_version.minor == "1": - tc.cache_variables["OPENSSL_WITH_ZLIB"] = False - else: - tc.cache_variables["OPENSSL_WITH_ZLIB"] = not openssl.options.no_zlib + tc.variables["OPENSSL_WITH_ZLIB"] = not self.dependencies["openssl"].options.get_safe("no_zlib", True) tc.generate() - self._generate_skip_test_file() - def build(self): - if not self._skip_test: - cmake = CMake(self) - cmake.configure() - cmake.build() + cmake = CMake(self) + cmake.configure() + cmake.build() def test(self): - if not self._skip_test and can_run(self): + if can_run(self): bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") self.run(bin_path, env="conanrun") diff --git a/recipes/openssl/1.x.x/test_v1_package/conanfile.py b/recipes/openssl/1.x.x/test_v1_package/conanfile.py index 468ca6bb29e988..57b42bea43378d 100644 --- a/recipes/openssl/1.x.x/test_v1_package/conanfile.py +++ b/recipes/openssl/1.x.x/test_v1_package/conanfile.py @@ -1,6 +1,5 @@ -from conans import CMake, ConanFile -from conan.tools.scm import Version -from conan.tools.build import cross_building +from conans import CMake, ConanFile, tools +from conans.errors import ConanException import os @@ -8,32 +7,19 @@ class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package" - @property - def _skip_test(self): - # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being - # set. This could be because you are using a Mac OS X version less than 10.5 - # or because CMake's platform configuration is corrupt. - # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. - # Actually the workaround should be to add cmake/3.22.0 to build requires, - # but for the specific case of openssl it fails because it is also a requirement of cmake. - # see https://github.com/conan-io/conan/pull/9839 - return self.settings.os == "Macos" and self.settings.arch == "armv8" \ - and self.options["openssl"].shared + def _openssl_option(self, name, default): + try: + return getattr(self.options["openssl"], name, default) + except (AttributeError, ConanException): + return default def build(self): - if not self._skip_test: - cmake = CMake(self) - if self.settings.os == "Android": - cmake.definitions["CONAN_LIBCXX"] = "" - openssl_version = Version(self.deps_cpp_info["openssl"].version) - if openssl_version.major == "1" and openssl_version.minor == "1": - cmake.definitions["OPENSSL_WITH_ZLIB"] = False - else: - cmake.definitions["OPENSSL_WITH_ZLIB"] = not self.options["openssl"].no_zlib - cmake.configure() - cmake.build() + cmake = CMake(self) + cmake.definitions["OPENSSL_WITH_ZLIB"] = not self._openssl_option("no_zlib", True) + cmake.configure() + cmake.build() def test(self): - if not self._skip_test and not cross_building(self): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True)