-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenSSL 1.x.x Conan 2.0 compatibility #14066
Merged
conan-center-bot
merged 23 commits into
conan-io:master
from
System-Arch:System-Arch-openssl-1
Dec 23, 2022
Merged
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
95eb74f
OpenSSL 1.x.x Conan 2.0 compatibility
System-Arch 69dda7c
Removed legacy code
System-Arch 4973607
Fix lint issues
System-Arch 1ae68df
Fix pedantic lint issue
System-Arch aed24c8
Work around linter limitations
System-Arch 1dcb03a
Require Conan 1.53
System-Arch 889cd1d
nmake doesn't like -j1
System-Arch 4480966
1.53 is not enough to rely on settings_build
System-Arch 2ef2e24
Remove legacy code to try to molify github-actions bot
System-Arch 5c2e578
Fix lint warning in test recipe
System-Arch 85f776f
Moved 'r' prefix to correct location
System-Arch 6f8bede
conandata.yml schema now requires patch_description and patch_type
System-Arch 5655e4a
Use 'if' rather than 'elif' per linter
System-Arch db635f9
Use f-strings per lint
System-Arch fecba6b
Put back legacy support
System-Arch 0f49c07
Don't require msys2 when using nmake
System-Arch 8689ec1
Fixes for review comments
System-Arch dbb440e
Apply suggestions from code review
System-Arch 30fbde2
Use self.settings in validate()
System-Arch 43d914f
Removed use of shutil.which as override mechanism
System-Arch 8ea95fc
Use explicit calls to nmake; removed Conan-version-specific code
System-Arch a71f585
Revise comment regra
System-Arch 1a18f9e
Removed unused shutil import
System-Arch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -20,8 +20,9 @@ | |
|
||
@total_ordering | ||
class OpenSSLVersion(object): | ||
def __init__(self, version_str): | ||
def __init__(self, version): | ||
self._pre = "" | ||
version_str = str(version) | ||
|
||
tokens = version_str.split("-") | ||
if len(tokens) > 1: | ||
|
@@ -219,7 +220,6 @@ def configure(self): | |
self.options.rm_safe("fPIC") | ||
self.settings.rm_safe("compiler.libcxx") | ||
self.settings.rm_safe("compiler.cppstd") | ||
self.conf.define("tools.gnu:make_program", self._make_program) | ||
|
||
def requirements(self): | ||
if self._full_version < "1.1.0" and not self.options.get_safe("no_zlib"): | ||
|
@@ -234,7 +234,7 @@ def build_requirements(self): | |
if self._settings_build.os == "Windows": | ||
if not self.win_bash: | ||
self.tool_requires("strawberryperl/5.30.0.1") | ||
if not self.options.no_asm and not shutil.which("nasm"): | ||
if not self.options.no_asm: | ||
self.tool_requires("nasm/2.15.05") | ||
if self.win_bash and not os.getenv("CONAN_BASH_PATH") and not self._use_nmake: | ||
self.build_requires("msys2/cci.latest") | ||
|
@@ -267,6 +267,14 @@ def generate(self): | |
gen_info["CXXFLAGS"] = tc.cxxflags | ||
gen_info["DEFINES"] = tc.defines | ||
gen_info["LDFLAGS"] = tc.ldflags | ||
# Workaround lack of support for self.dependencies in build() method in Conan 1.x | ||
System-Arch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if self._full_version < "1.1.0" and not self.options.get_safe("no_zlib"): | ||
zlib_cpp_info = self.dependencies["zlib"].cpp_info | ||
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" | ||
else: | ||
gen_info["zlib_lib_path"] = zlib_cpp_info.libdirs[0] # Just path, linux will find the right file | ||
save(self, "gen_info.conf", json.dumps(gen_info)) | ||
tc = AutotoolsDeps(self) | ||
tc.generate() | ||
|
@@ -550,23 +558,12 @@ def _configure_args(self): | |
if self.options.get_safe("no_zlib"): | ||
args.append("no-zlib") | ||
else: | ||
if Version(conan_version).major < 2: | ||
zlib_info = self.deps_cpp_info["zlib"] | ||
include_path = zlib_info.include_paths[0] | ||
if self.settings.os == "Windows": | ||
lib_path = "%s/%s.lib" % (zlib_info.lib_paths[0], zlib_info.libs[0]) | ||
else: | ||
lib_path = zlib_info.lib_paths[0] # Just path, linux will find the right file | ||
else: | ||
zlib_cpp_info = self.dependencies["zlib"].cpp_info | ||
include_path = zlib_cpp_info.includedirs[0] | ||
if self.settings.os == "Windows": | ||
lib_path = "%s/%s.lib" % (zlib_cpp_info.libdirs[0], zlib_cpp_info.libs[0]) | ||
else: | ||
lib_path = zlib_cpp_info.libdirs[0] # Just path, linux will find the right file | ||
gen_info = json.loads(load(self, os.path.join(self.generators_folder, "gen_info.conf"))) | ||
include_path = gen_info["zlib_include_path"] | ||
lib_path = gen_info["zlib_lib_path"] | ||
# clang-cl doesn't like backslashes in #define CFLAGS (builldinf.h -> cversion.c) | ||
include_path = self._adjust_path(include_path) | ||
lib_path = self._adjust_path(lib_path) | ||
lib_path = self._adjust_path(lib_path) | ||
|
||
if Version(conan_version).major <2 : | ||
if self.options["zlib"].shared: | ||
|
@@ -614,7 +611,7 @@ def _create_targets(self): | |
); | ||
""" | ||
gen_info = json.loads(load(self, os.path.join(self.generators_folder, "gen_info.conf"))) | ||
self.output.info("gen_info = %s" % gen_info) | ||
self.output.info(f"gen_info = {gen_info}") | ||
cflags = [] | ||
cxxflags = [] | ||
cflags.extend(gen_info["CFLAGS"]) | ||
|
@@ -728,35 +725,31 @@ def build(self): | |
|
||
self._patch_install_name() | ||
|
||
if self._use_nmake and self._full_version < "1.1.0": | ||
if not self.options.no_asm and self.settings.arch == "x86": | ||
self.run(r"ms\do_nasm") | ||
else: | ||
self.run(r"ms\do_ms" if self.settings.arch == "x86" else r"ms\do_win64a") | ||
|
||
self._replace_runtime_in_file(os.path.join("ms", "nt.mak")) | ||
self._replace_runtime_in_file(os.path.join("ms", "ntdll.mak")) | ||
if self.settings.arch == "x86": | ||
replace_in_file(self, os.path.join("ms", "nt.mak"), "-WX", "") | ||
replace_in_file(self, os.path.join("ms", "ntdll.mak"), "-WX", "") | ||
|
||
# NMAKE interprets trailing backslash as line continuation | ||
replace_in_file(self, self._nmake_makefile, 'INSTALLTOP=\\', 'INSTALLTOP=/') | ||
|
||
autotools.make(args=[f'-f {self._nmake_makefile}']) | ||
else: | ||
if not self._use_nmake: | ||
autotools.make() | ||
else: | ||
if self._full_version >= "1.1.0": | ||
self.run(f'nmake /F Makefile') | ||
else: # nmake 1.0.2 support | ||
# Note: 1.0.2 should not be used according to the OpenSSL Project | ||
# See https://www.openssl.org/source/ | ||
|
||
if not self.options.no_asm and self.settings.arch == "x86": | ||
self.run(r"ms\do_nasm") | ||
else: | ||
self.run(r"ms\do_ms" if self.settings.arch == "x86" else r"ms\do_win64a") | ||
|
||
self._replace_runtime_in_file(os.path.join("ms", "nt.mak")) | ||
self._replace_runtime_in_file(os.path.join("ms", "ntdll.mak")) | ||
if self.settings.arch == "x86": | ||
replace_in_file(self, os.path.join("ms", "nt.mak"), "-WX", "") | ||
replace_in_file(self, os.path.join("ms", "ntdll.mak"), "-WX", "") | ||
|
||
# NMAKE interprets trailing backslash as line continuation | ||
replace_in_file(self, self._nmake_makefile, 'INSTALLTOP=\\', 'INSTALLTOP=/') | ||
|
||
self.run(f'nmake /F {self._nmake_makefile}') | ||
|
||
@property | ||
def _make_program(self): | ||
if self._use_nmake: | ||
return "nmake" | ||
make_program = os.getenv("CONAN_MAKE_PROGRAM") or shutil.which("make") or shutil.which('mingw32-make') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 for future readers, this is replaced by the conf |
||
make_program = unix_path(self, make_program) if self._settings_build.os == "Windows" else make_program | ||
if not make_program: | ||
raise Exception('could not find "make" executable. please set "CONAN_MAKE_PROGRAM" environment variable') | ||
return make_program | ||
|
||
def _patch_install_name(self): | ||
if is_apple_os(self) and self.options.shared: | ||
old_str = '-install_name $(INSTALLTOP)/$(LIBDIR)/' | ||
|
@@ -777,24 +770,32 @@ def _replace_runtime_in_file(self, filename): | |
def package(self): | ||
copy(self, "*LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"), keep_path=False) | ||
autotools = Autotools(self) | ||
if self._use_nmake and self._full_version < "1.1.0": | ||
target = "install" | ||
args = [f'-f {self._nmake_makefile}'] | ||
else: | ||
target = "install_sw" | ||
args = [] | ||
args = [] | ||
if self._full_version >= "1.1.0": | ||
target = "install_sw" | ||
args.append(f"DESTDIR={self.package_folder}") | ||
else: | ||
else: # 1.0.2 support | ||
# Note: 1.0.2 should not be used according to the OpenSSL Project | ||
# See https://www.openssl.org/source/ | ||
if not self._use_nmake: | ||
target = "install_sw" | ||
args.append(f"INSTALL_PREFIX={self.package_folder}") | ||
else: | ||
target = "install" | ||
args.append(f"INSTALLTOP={self.package_folder}") | ||
openssldir = self.options.openssldir or self._get_default_openssl_dir() | ||
args.append(f"OPENSSLDIR={os.path.join(self.package_folder, openssldir)}") | ||
|
||
with chdir(self, self.source_folder): | ||
autotools.make(target=target, args=args) | ||
if not self._use_nmake: | ||
autotools.make(target=target, args=args) | ||
else: | ||
if self._full_version >= "1.1.0": | ||
self.run(f'nmake /F Makefile {target} {" ".join(args)}') | ||
else: # nmake 1.0.2 support | ||
# Note: 1.0.2 should not be used according to the OpenSSL Project | ||
# See https://www.openssl.org/source/ | ||
self.run(f'nmake /F {self._nmake_makefile} {target} {" ".join(args)}') | ||
|
||
for root, _, files in os.walk(self.package_folder): | ||
for filename in files: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new way for future readers https://docs.conan.io/en/latest/migrating_to_2.0/recipes.html?highlight=win_bash#windows-subsystems