Skip to content

Commit

Permalink
(conan-io#15841) openssl 1.x.x: modernize a little bit more + do not …
Browse files Browse the repository at this point in the history
…skip tests if macOS armv8 shared

* modernize more

* do not skip tests if macOS armv8 shared

* typo
  • Loading branch information
SpaceIm authored and sabelka committed Feb 12, 2023
1 parent 7f380b9 commit 1791c17
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 85 deletions.
23 changes: 5 additions & 18 deletions recipes/openssl/1.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand Down
48 changes: 7 additions & 41 deletions recipes/openssl/1.x.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,65 +1,31 @@
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):
settings = "os", "arch", "compiler", "build_type"
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")
38 changes: 12 additions & 26 deletions recipes/openssl/1.x.x/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
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


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)

0 comments on commit 1791c17

Please sign in to comment.