Skip to content
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
merged 23 commits into from
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 Nov 6, 2022
69dda7c
Removed legacy code
System-Arch Nov 6, 2022
4973607
Fix lint issues
System-Arch Nov 6, 2022
1ae68df
Fix pedantic lint issue
System-Arch Nov 6, 2022
aed24c8
Work around linter limitations
System-Arch Nov 6, 2022
1dcb03a
Require Conan 1.53
System-Arch Nov 6, 2022
889cd1d
nmake doesn't like -j1
System-Arch Nov 6, 2022
4480966
1.53 is not enough to rely on settings_build
System-Arch Nov 6, 2022
2ef2e24
Remove legacy code to try to molify github-actions bot
System-Arch Nov 7, 2022
5c2e578
Fix lint warning in test recipe
System-Arch Nov 7, 2022
85f776f
Moved 'r' prefix to correct location
System-Arch Nov 7, 2022
6f8bede
conandata.yml schema now requires patch_description and patch_type
System-Arch Nov 7, 2022
5655e4a
Use 'if' rather than 'elif' per linter
System-Arch Nov 7, 2022
db635f9
Use f-strings per lint
System-Arch Nov 8, 2022
fecba6b
Put back legacy support
System-Arch Nov 9, 2022
0f49c07
Don't require msys2 when using nmake
System-Arch Dec 1, 2022
8689ec1
Fixes for review comments
System-Arch Dec 14, 2022
dbb440e
Apply suggestions from code review
System-Arch Dec 14, 2022
30fbde2
Use self.settings in validate()
System-Arch Dec 14, 2022
43d914f
Removed use of shutil.which as override mechanism
System-Arch Dec 16, 2022
8ea95fc
Use explicit calls to nmake; removed Conan-version-specific code
System-Arch Dec 17, 2022
a71f585
Revise comment regra
System-Arch Dec 20, 2022
1a18f9e
Removed unused shutil import
System-Arch Dec 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 55 additions & 54 deletions recipes/openssl/1.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"):
Expand All @@ -234,7 +234,7 @@ def build_requirements(self):
if self._settings_build.os == "Windows":
if not self.win_bash:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for future readers, this is replaced by the conf tools.gnu:make_program https://docs.conan.io/en/latest/reference/config_files/global_conf.html?highlight=make%20program#tools-configurations with the new generators

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)/'
Expand All @@ -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:
Expand Down