[DO-978] openssl package (!8)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/8
This commit is contained in:
21
recipes/nasm/all/conandata.yml
Normal file
21
recipes/nasm/all/conandata.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
sources:
|
||||
"2.16.01":
|
||||
sha256: "c77745f4802375efeee2ec5c0ad6b7f037ea9c87c92b149a9637ff099f162558"
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-nasm-us/pub/nasm/releasebuilds/2.16.01/nasm-2.16.01.tar.xz"
|
||||
"2.15.05":
|
||||
sha256: "3caf6729c1073bf96629b57cee31eeb54f4f8129b01902c73428836550b30a3f"
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-nasm-us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.xz"
|
||||
"2.14":
|
||||
sha256: "97c615dbf02ef80e4e2b6c385f7e28368d51efc214daa98e600ca4572500eec0"
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-nasm-us/pub/nasm/releasebuilds/2.14/nasm-2.14.tar.xz"
|
||||
"2.13.02":
|
||||
sha256: "8ac3235f49a6838ff7a8d7ef7c19a4430d0deecc0c2d3e3e237b5e9f53291757"
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-nasm-us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.xz"
|
||||
"2.13.01":
|
||||
sha256: "aa0213008f0433ecbe07bb628506a5c4be8079be20fc3532a5031fd639db9a5e"
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-nasm-us/pub/nasm/releasebuilds/2.13.01/nasm-2.13.01.tar.xz"
|
||||
patches:
|
||||
"2.16.01":
|
||||
- patch_file: "patches/2.16.01-0001-disable-newly-integrated-dependency-tracking.patch"
|
||||
"2.15.05":
|
||||
- patch_file: "patches/2.15.05-0001-disable-newly-integrated-dependency-tracking.patch"
|
||||
130
recipes/nasm/all/conanfile.py
Normal file
130
recipes/nasm/all/conanfile.py
Normal file
@@ -0,0 +1,130 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.env import VirtualBuildEnv
|
||||
from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, replace_in_file, rmdir
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.microsoft import NMakeToolchain, is_msvc
|
||||
import os
|
||||
import shutil
|
||||
|
||||
required_conan_version = ">=1.55.0"
|
||||
|
||||
|
||||
class NASMConan(ConanFile):
|
||||
name = "nasm"
|
||||
package_type = "application"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "http://www.nasm.us"
|
||||
description = "The Netwide Assembler, NASM, is an 80x86 and x86-64 assembler"
|
||||
license = "BSD-2-Clause"
|
||||
topics = ("asm", "installer", "assembler",)
|
||||
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
|
||||
@property
|
||||
def _settings_build(self):
|
||||
return getattr(self, "settings_build", self.settings)
|
||||
|
||||
@property
|
||||
def _nasm(self):
|
||||
suffix = "w.exe" if is_msvc(self) else ""
|
||||
return os.path.join(self.package_folder, "bin", f"nasm{suffix}")
|
||||
|
||||
@property
|
||||
def _ndisasm(self):
|
||||
suffix = "w.exe" if is_msvc(self) else ""
|
||||
return os.path.join(self.package_folder, "bin", f"ndisasm{suffix}")
|
||||
|
||||
def _chmod_plus_x(self, filename):
|
||||
if os.name == "posix":
|
||||
os.chmod(filename, os.stat(filename).st_mode | 0o111)
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
def configure(self):
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def package_id(self):
|
||||
del self.info.settings.compiler
|
||||
|
||||
def build_requirements(self):
|
||||
if self._settings_build.os == "Windows":
|
||||
self.tool_requires("strawberryperl/5.32.1.1")
|
||||
if not is_msvc(self):
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
env = VirtualBuildEnv(self)
|
||||
env.generate()
|
||||
if is_msvc(self):
|
||||
tc = NMakeToolchain(self)
|
||||
tc.generate()
|
||||
else:
|
||||
tc = AutotoolsToolchain(self)
|
||||
if self.settings.arch == "x86":
|
||||
tc.extra_cflags.append("-m32")
|
||||
elif self.settings.arch == "x86_64":
|
||||
tc.extra_cflags.append("-m64")
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
apply_conandata_patches(self)
|
||||
if is_msvc(self):
|
||||
with chdir(self, self.source_folder):
|
||||
self.run(f'nmake /f {os.path.join("Mkfiles", "msvc.mak")}')
|
||||
else:
|
||||
with chdir(self, self.source_folder):
|
||||
autotools = Autotools(self)
|
||||
autotools.configure()
|
||||
|
||||
# GCC9 - "pure" attribute on function returning "void"
|
||||
replace_in_file(self, "Makefile", "-Werror=attributes", "")
|
||||
|
||||
# Need "-arch" flag for the linker when cross-compiling.
|
||||
# FIXME: Revisit after https://github.com/conan-io/conan/issues/9069, using new Autotools integration
|
||||
# TODO it is time to revisit, not sure what to do here though...
|
||||
if str(self.version).startswith("2.13"):
|
||||
replace_in_file(self, "Makefile", "$(CC) $(LDFLAGS) -o", "$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o")
|
||||
replace_in_file(self, "Makefile", "$(INSTALLROOT)", "$(DESTDIR)")
|
||||
autotools.make()
|
||||
|
||||
def package(self):
|
||||
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
|
||||
if is_msvc(self):
|
||||
copy(self, pattern="*.exe", src=self.source_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False)
|
||||
with chdir(self, os.path.join(self.package_folder, "bin")):
|
||||
shutil.copy2("nasm.exe", "nasmw.exe")
|
||||
shutil.copy2("ndisasm.exe", "ndisasmw.exe")
|
||||
else:
|
||||
with chdir(self, self.source_folder):
|
||||
autotools = Autotools(self)
|
||||
autotools.install()
|
||||
rmdir(self, os.path.join(self.package_folder, "share"))
|
||||
self._chmod_plus_x(self._nasm)
|
||||
self._chmod_plus_x(self._ndisasm)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.libdirs = []
|
||||
self.cpp_info.includedirs = []
|
||||
|
||||
compiler_executables = {"asm": self._nasm}
|
||||
self.conf_info.update("tools.build:compiler_executables", compiler_executables)
|
||||
self.buildenv_info.define_path("NASM", self._nasm)
|
||||
self.buildenv_info.define_path("NDISASM", self._ndisasm)
|
||||
self.buildenv_info.define_path("AS", self._nasm)
|
||||
|
||||
# TODO: Legacy, to be removed on Conan 2.0
|
||||
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
|
||||
self.env_info.NASM = self._nasm
|
||||
self.env_info.NDISASM = self._ndisasm
|
||||
self.env_info.AS = self._nasm
|
||||
@@ -0,0 +1,34 @@
|
||||
--- Mkfiles/msvc.mak
|
||||
+++ Mkfiles/msvc.mak
|
||||
@@ -218,7 +218,7 @@
|
||||
x86\regs.h: x86\regs.dat x86\regs.pl
|
||||
$(RUNPERL) $(srcdir)\x86\regs.pl h \
|
||||
$(srcdir)\x86\regs.dat > x86\regs.h
|
||||
-
|
||||
+!IF 0
|
||||
# Extract warnings from source code. This is done automatically if any
|
||||
# C files have changed; the script is fast enough that that is
|
||||
# reasonable, but doesn't update the time stamp if the files aren't
|
||||
@@ -242,7 +242,7 @@ include\warnings.h: asm\warnings.pl asm\warnings.time
|
||||
|
||||
doc\warnings.src: asm\warnings.pl asm\warnings.time
|
||||
$(RUNPERL) $(srcdir)\asm\warnings.pl doc doc\warnings.src $(srcdir)
|
||||
-
|
||||
+!ENDIF
|
||||
# Assembler token hash
|
||||
asm\tokhash.c: x86\insns.dat x86\regs.dat asm\tokens.dat asm\tokhash.pl \
|
||||
perllib\phash.ph
|
||||
@@ -426,7 +426,7 @@
|
||||
# @exclude: "config/config.h"
|
||||
# @external: "msvc.dep"
|
||||
# @selfrule: "1"
|
||||
-#-- Everything below is generated by mkdep.pl - do not edit --#
|
||||
+!IF 0
|
||||
asm\assemble.$(O): asm\assemble.c asm\assemble.h asm\directiv.h \
|
||||
asm\listing.h asm\pptok.h asm\preproc.h asm\srcfile.h asm\tokens.h \
|
||||
config\msvc.h config\unconfig.h config\unknown.h config\watcom.h \
|
||||
@@ -935,3 +935,4 @@
|
||||
x86\regvals.$(O): x86\regvals.c config\msvc.h config\unconfig.h \
|
||||
config\unknown.h config\watcom.h include\compiler.h include\nasmint.h \
|
||||
include\tables.h x86\insnsi.h
|
||||
+!ENDIF
|
||||
@@ -0,0 +1,34 @@
|
||||
--- Mkfiles/msvc.mak
|
||||
+++ Mkfiles/msvc.mak
|
||||
@@ -226,7 +226,7 @@
|
||||
x86\regs.h: x86\regs.dat x86\regs.pl
|
||||
$(RUNPERL) $(srcdir)\x86\regs.pl h \
|
||||
$(srcdir)\x86\regs.dat > x86\regs.h
|
||||
-
|
||||
+!IF 0
|
||||
# Extract warnings from source code. This is done automatically if any
|
||||
# C files have changed; the script is fast enough that that is
|
||||
# reasonable, but doesn't update the time stamp if the files aren't
|
||||
@@ -262,7 +262,7 @@
|
||||
|
||||
doc\warnings.src : doc\warnings.src.time
|
||||
@: Side effect
|
||||
-
|
||||
+!ENDIF
|
||||
# Assembler token hash
|
||||
asm\tokhash.c: x86\insns.dat x86\insnsn.c asm\tokens.dat asm\tokhash.pl \
|
||||
perllib\phash.ph
|
||||
@@ -402,7 +402,7 @@
|
||||
# @exclude: "config/config.h"
|
||||
# @external: "msvc.dep"
|
||||
# @selfrule: "1"
|
||||
-#-- Everything below is generated by mkdep.pl - do not edit --#
|
||||
+!IF 0
|
||||
asm\assemble.$(O): asm\assemble.c asm\assemble.h asm\directiv.h \
|
||||
asm\listing.h asm\pptok.h asm\preproc.h asm\srcfile.h asm\tokens.h \
|
||||
config\msvc.h config\unconfig.h config\unknown.h config\watcom.h \
|
||||
@@ -854,3 +854,4 @@
|
||||
x86\regvals.$(O): x86\regvals.c config\msvc.h config\unconfig.h \
|
||||
config\unknown.h config\watcom.h include\compiler.h include\nasmint.h \
|
||||
include\tables.h x86\insnsi.h
|
||||
+!ENDIF
|
||||
30
recipes/nasm/all/test_package/conanfile.py
Normal file
30
recipes/nasm/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import cmake_layout
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "VirtualBuildEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def build_requirements(self):
|
||||
self.tool_requires(self.tested_reference_str)
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def test(self):
|
||||
self.run("nasm --version")
|
||||
asm_file = os.path.join(self.source_folder, "hello_linux.asm")
|
||||
out_file = os.path.join(self.build_folder, "hello_linux.o")
|
||||
self.run(f"nasm -felf64 {asm_file} -o {out_file}")
|
||||
if can_run(self):
|
||||
if self.settings.os == "Linux" and self.settings.arch == "x86_64":
|
||||
# TODO was tools.get_env, what should it be?
|
||||
ld = os.getenv("LD", "ld")
|
||||
bin_file = os.path.join(self.build_folder, "hello_linux")
|
||||
self.run(f"{ld} hello_linux.o -o {bin_file}")
|
||||
self.run(bin_file)
|
||||
16
recipes/nasm/all/test_package/hello_linux.asm
Normal file
16
recipes/nasm/all/test_package/hello_linux.asm
Normal file
@@ -0,0 +1,16 @@
|
||||
; Print "Hello, Conan"
|
||||
|
||||
global _start
|
||||
|
||||
section .text
|
||||
_start: mov rax, 1 ; system call for write
|
||||
mov rdi, 1 ; file handle 1 is stdout
|
||||
mov rsi, message ; address of string to output
|
||||
mov rdx, 13 ; number of bytes
|
||||
syscall ; invoke operating system to do the write
|
||||
mov rax, 60 ; system call for exit
|
||||
xor rdi, rdi ; exit code 0
|
||||
syscall ; invoke operating system to exit
|
||||
|
||||
section .data
|
||||
message: db "Hello, Conan", 10 ; note the newline at the end
|
||||
22
recipes/nasm/all/test_v1_package/conanfile.py
Normal file
22
recipes/nasm/all/test_v1_package/conanfile.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
from conans import ConanFile, tools
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
test_type = "explicit"
|
||||
|
||||
def build_requirements(self):
|
||||
self.build_requires(self.tested_reference_str)
|
||||
|
||||
def test(self):
|
||||
self.run("nasm --version")
|
||||
asm_file = os.path.join(self.source_folder, "hello_linux.asm")
|
||||
out_file = os.path.join(self.build_folder, "hello_linux.o")
|
||||
self.run(f"nasm -felf64 {asm_file} -o {out_file}")
|
||||
if not tools.cross_building(self):
|
||||
if self.settings.os == "Linux" and self.settings.arch == "x86_64":
|
||||
ld = tools.get_env("LD", "ld")
|
||||
bin_file = os.path.join(self.build_folder, "hello_linux")
|
||||
self.run(f"{ld} hello_linux.o -o {bin_file}")
|
||||
self.run(bin_file)
|
||||
16
recipes/nasm/all/test_v1_package/hello_linux.asm
Normal file
16
recipes/nasm/all/test_v1_package/hello_linux.asm
Normal file
@@ -0,0 +1,16 @@
|
||||
; Print "Hello, Conan"
|
||||
|
||||
global _start
|
||||
|
||||
section .text
|
||||
_start: mov rax, 1 ; system call for write
|
||||
mov rdi, 1 ; file handle 1 is stdout
|
||||
mov rsi, message ; address of string to output
|
||||
mov rdx, 13 ; number of bytes
|
||||
syscall ; invoke operating system to do the write
|
||||
mov rax, 60 ; system call for exit
|
||||
xor rdi, rdi ; exit code 0
|
||||
syscall ; invoke operating system to exit
|
||||
|
||||
section .data
|
||||
message: db "Hello, Conan", 10 ; note the newline at the end
|
||||
11
recipes/nasm/config.yml
Normal file
11
recipes/nasm/config.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
versions:
|
||||
"2.16.01":
|
||||
folder: all
|
||||
"2.15.05":
|
||||
folder: all
|
||||
"2.14":
|
||||
folder: all
|
||||
"2.13.02":
|
||||
folder: all
|
||||
"2.13.01":
|
||||
folder: all
|
||||
9
recipes/openssl/1.x.x/conandata.yml
Normal file
9
recipes/openssl/1.x.x/conandata.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
sources:
|
||||
1.1.1w:
|
||||
sha256: cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz"
|
||||
patches:
|
||||
1.1.1w:
|
||||
- patch_file: patches/1.1.1-tvos-watchos.patch
|
||||
patch_description: "TVOS and WatchOS don't like fork()"
|
||||
patch_type: "portability"
|
||||
648
recipes/openssl/1.x.x/conanfile.py
Normal file
648
recipes/openssl/1.x.x/conanfile.py
Normal file
@@ -0,0 +1,648 @@
|
||||
from conan import ConanFile, conan_version
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.apple import is_apple_os, XCRun
|
||||
from conan.tools.build import cross_building
|
||||
from conan.tools.env import Environment, VirtualBuildEnv
|
||||
from conan.tools.files import (
|
||||
apply_conandata_patches, chdir, copy, export_conandata_patches,
|
||||
get, load, replace_in_file, rm, rmdir, save
|
||||
)
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path
|
||||
from conan.tools.scm import Version
|
||||
from contextlib import contextmanager
|
||||
import fnmatch
|
||||
import json
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
required_conan_version = ">=1.53.0"
|
||||
|
||||
|
||||
class OpenSSLConan(ConanFile):
|
||||
name = "openssl"
|
||||
package_type = "library"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://github.com/openssl/openssl"
|
||||
license = "OpenSSL"
|
||||
topics = ("openssl", "ssl", "tls", "encryption", "security")
|
||||
description = "A toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols"
|
||||
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"no_threads": [True, False],
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"no_asm": [True, False],
|
||||
"enable_weak_ssl_ciphers": [True, False],
|
||||
"386": [True, False],
|
||||
"no_stdio": [True, False],
|
||||
"no_tests": [True, False],
|
||||
"no_sse2": [True, False],
|
||||
"no_bf": [True, False],
|
||||
"no_cast": [True, False],
|
||||
"no_des": [True, False],
|
||||
"no_dh": [True, False],
|
||||
"no_dsa": [True, False],
|
||||
"no_hmac": [True, False],
|
||||
"no_md5": [True, False],
|
||||
"no_mdc2": [True, False],
|
||||
"no_rc2": [True, False],
|
||||
"no_rsa": [True, False],
|
||||
"no_sha": [True, False],
|
||||
"no_async": [True, False],
|
||||
"no_dso": [True, False],
|
||||
"no_aria": [True, False],
|
||||
"no_blake2": [True, False],
|
||||
"no_camellia": [True, False],
|
||||
"no_chacha": [True, False],
|
||||
"no_cms": [True, False],
|
||||
"no_comp": [True, False],
|
||||
"no_ct": [True, False],
|
||||
"no_deprecated": [True, False],
|
||||
"no_dgram": [True, False],
|
||||
"no_engine": [True, False],
|
||||
"no_filenames": [True, False],
|
||||
"no_gost": [True, False],
|
||||
"no_idea": [True, False],
|
||||
"no_md4": [True, False],
|
||||
"no_ocsp": [True, False],
|
||||
"no_pinshared": [True, False],
|
||||
"no_rmd160": [True, False],
|
||||
"no_sm2": [True, False],
|
||||
"no_sm3": [True, False],
|
||||
"no_sm4": [True, False],
|
||||
"no_srp": [True, False],
|
||||
"no_srtp": [True, False],
|
||||
"no_ssl": [True, False],
|
||||
"no_ts": [True, False],
|
||||
"no_whirlpool": [True, False],
|
||||
"no_ec": [True, False],
|
||||
"no_ecdh": [True, False],
|
||||
"no_ecdsa": [True, False],
|
||||
"no_rfc3779": [True, False],
|
||||
"no_seed": [True, False],
|
||||
"no_sock": [True, False],
|
||||
"no_ssl3": [True, False],
|
||||
"no_tls1": [True, False],
|
||||
"capieng_dialog": [True, False],
|
||||
"enable_capieng": [True, False],
|
||||
"openssldir": [None, "ANY"],
|
||||
}
|
||||
default_options = {key: False for key in options.keys()}
|
||||
default_options["fPIC"] = True
|
||||
default_options["openssldir"] = None
|
||||
|
||||
@property
|
||||
def _is_clang_cl(self):
|
||||
return self.settings.os == "Windows" and self.settings.compiler == "clang" and \
|
||||
self.settings.compiler.get_safe("runtime")
|
||||
|
||||
@property
|
||||
def _is_mingw(self):
|
||||
return self.settings.os == "Windows" and self.settings.compiler == "gcc"
|
||||
|
||||
@property
|
||||
def _use_nmake(self):
|
||||
return self._is_clang_cl or is_msvc(self)
|
||||
|
||||
@property
|
||||
def _settings_build(self):
|
||||
return getattr(self, "settings_build", self.settings)
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
else:
|
||||
del self.options.capieng_dialog
|
||||
del self.options.enable_capieng
|
||||
|
||||
if self.settings.os == "Emscripten":
|
||||
self.options.no_asm = True
|
||||
self.options.no_threads = True
|
||||
self.options.no_stdio = True
|
||||
self.options.no_tests = True
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.os == "Emscripten":
|
||||
if not all((self.options.no_asm, self.options.no_threads, self.options.no_stdio, self.options.no_tests)):
|
||||
raise ConanInvalidConfiguration("os=Emscripten requires openssl:{no_asm,no_threads,no_stdio,no_tests}=True")
|
||||
|
||||
def build_requirements(self):
|
||||
if self._settings_build.os == "Windows":
|
||||
if not self.options.no_asm:
|
||||
self.tool_requires("nasm/2.16.01")
|
||||
if self._use_nmake:
|
||||
self.tool_requires("strawberryperl/5.32.1.1")
|
||||
else:
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
VirtualBuildEnv(self).generate()
|
||||
|
||||
tc = AutotoolsToolchain(self)
|
||||
if self.settings.os == "Macos" and not cross_building(self):
|
||||
tc.extra_cflags = [f"-isysroot {XCRun(self).sdk_path}"]
|
||||
tc.extra_cxxflags = [f"-isysroot {XCRun(self).sdk_path}"]
|
||||
tc.extra_ldflags = [f"-isysroot {XCRun(self).sdk_path}"]
|
||||
env = tc.environment()
|
||||
env.define("PERL", self._perl)
|
||||
tc.generate(env)
|
||||
gen_info = {}
|
||||
gen_info["CFLAGS"] = tc.cflags
|
||||
gen_info["CXXFLAGS"] = tc.cxxflags
|
||||
gen_info["DEFINES"] = tc.defines
|
||||
gen_info["LDFLAGS"] = tc.ldflags
|
||||
save(self, "gen_info.conf", json.dumps(gen_info))
|
||||
tc = AutotoolsDeps(self)
|
||||
tc.generate()
|
||||
|
||||
@property
|
||||
def _target(self):
|
||||
target = "conan-%s-%s-%s-%s-%s" % (self.settings.build_type,
|
||||
self.settings.os,
|
||||
self.settings.arch,
|
||||
self.settings.compiler,
|
||||
self.settings.compiler.version)
|
||||
if self._use_nmake:
|
||||
target = "VC-" + target # VC- prefix is important as it's checked by Configure
|
||||
if self._is_mingw:
|
||||
target = "mingw-" + target
|
||||
return target
|
||||
|
||||
@property
|
||||
def _perlasm_scheme(self):
|
||||
# right now, we need to tweak this for iOS & Android only, as they inherit from generic targets
|
||||
the_arch = str(self.settings.arch)
|
||||
the_os = str(self.settings.os)
|
||||
if the_os in ["iOS", "watchOS", "tvOS"]:
|
||||
return {"armv7": "ios32",
|
||||
"armv7s": "ios32",
|
||||
"armv8": "ios64",
|
||||
"armv8_32": "ios64",
|
||||
"armv8.3": "ios64",
|
||||
"armv7k": "ios32"}.get(the_arch, None)
|
||||
if the_os == "Android":
|
||||
return {"armv7": "void",
|
||||
"armv8": "linux64",
|
||||
"mips": "o32",
|
||||
"mips64": "64",
|
||||
"x86": "android",
|
||||
"x86_64": "elf"}.get(the_arch, None)
|
||||
return None
|
||||
|
||||
@property
|
||||
def _targets(self):
|
||||
is_cygwin = self.settings.get_safe("os.subsystem") == "cygwin"
|
||||
return {
|
||||
"Linux-x86-clang": "linux-x86-clang",
|
||||
"Linux-x86_64-clang": "linux-x86_64-clang",
|
||||
"Linux-x86-*": "linux-x86",
|
||||
"Linux-x86_64-*": "linux-x86_64",
|
||||
"Linux-armv4-*": "linux-armv4",
|
||||
"Linux-armv4i-*": "linux-armv4",
|
||||
"Linux-armv5el-*": "linux-armv4",
|
||||
"Linux-armv5hf-*": "linux-armv4",
|
||||
"Linux-armv6-*": "linux-armv4",
|
||||
"Linux-armv7-*": "linux-armv4",
|
||||
"Linux-armv7hf-*": "linux-armv4",
|
||||
"Linux-armv7s-*": "linux-armv4",
|
||||
"Linux-armv7k-*": "linux-armv4",
|
||||
"Linux-armv8-*": "linux-aarch64",
|
||||
"Linux-armv8.3-*": "linux-aarch64",
|
||||
"Linux-armv8-32-*": "linux-arm64ilp32",
|
||||
"Linux-mips-*": "linux-mips32",
|
||||
"Linux-mips64-*": "linux-mips64",
|
||||
"Linux-ppc32-*": "linux-ppc32",
|
||||
"Linux-ppc32le-*": "linux-pcc32",
|
||||
"Linux-ppc32be-*": "linux-ppc32",
|
||||
"Linux-ppc64-*": "linux-ppc64",
|
||||
"Linux-ppc64le-*": "linux-ppc64le",
|
||||
"Linux-pcc64be-*": "linux-pcc64",
|
||||
"Linux-s390x-*": "linux64-s390x",
|
||||
"Linux-e2k-*": "linux-generic64",
|
||||
"Linux-sparc-*": "linux-sparcv8",
|
||||
"Linux-sparcv9-*": "linux64-sparcv9",
|
||||
"Linux-*-*": "linux-generic32",
|
||||
"Macos-x86-*": "darwin-i386-cc",
|
||||
"Macos-x86_64-*": "darwin64-x86_64-cc",
|
||||
"Macos-ppc32-*": "darwin-ppc-cc",
|
||||
"Macos-ppc32be-*": "darwin-ppc-cc",
|
||||
"Macos-ppc64-*": "darwin64-ppc-cc",
|
||||
"Macos-ppc64be-*": "darwin64-ppc-cc",
|
||||
"Macos-armv8-*": "darwin64-arm64-cc",
|
||||
"Macos-*-*": "darwin-common",
|
||||
"iOS-x86_64-*": "darwin64-x86_64-cc",
|
||||
"iOS-*-*": "iphoneos-cross",
|
||||
"watchOS-*-*": "iphoneos-cross",
|
||||
"tvOS-*-*": "iphoneos-cross",
|
||||
# Android targets are very broken, see https://github.com/openssl/openssl/issues/7398
|
||||
"Android-armv7-*": "linux-generic32",
|
||||
"Android-armv7hf-*": "linux-generic32",
|
||||
"Android-armv8-*": "linux-generic64",
|
||||
"Android-x86-*": "linux-x86-clang",
|
||||
"Android-x86_64-*": "linux-x86_64-clang",
|
||||
"Android-mips-*": "linux-generic32",
|
||||
"Android-mips64-*": "linux-generic64",
|
||||
"Android-*-*": "linux-generic32",
|
||||
"Windows-x86-gcc": "Cygwin-x86" if is_cygwin else "mingw",
|
||||
"Windows-x86_64-gcc": "Cygwin-x86_64" if is_cygwin else "mingw64",
|
||||
"Windows-*-gcc": "Cygwin-common" if is_cygwin else "mingw-common",
|
||||
"Windows-ia64-Visual Studio": "VC-WIN64I", # Itanium
|
||||
"Windows-x86-Visual Studio": "VC-WIN32",
|
||||
"Windows-x86_64-Visual Studio": "VC-WIN64A",
|
||||
"Windows-armv7-Visual Studio": "VC-WIN32-ARM",
|
||||
"Windows-armv8-Visual Studio": "VC-WIN64-ARM",
|
||||
"Windows-*-Visual Studio": "VC-noCE-common",
|
||||
"Windows-ia64-clang": "VC-WIN64I", # Itanium
|
||||
"Windows-x86-clang": "VC-WIN32",
|
||||
"Windows-x86_64-clang": "VC-WIN64A",
|
||||
"Windows-armv7-clang": "VC-WIN32-ARM",
|
||||
"Windows-armv8-clang": "VC-WIN64-ARM",
|
||||
"Windows-*-clang": "VC-noCE-common",
|
||||
"WindowsStore-x86-*": "VC-WIN32-UWP",
|
||||
"WindowsStore-x86_64-*": "VC-WIN64A-UWP",
|
||||
"WindowsStore-armv7-*": "VC-WIN32-ARM-UWP",
|
||||
"WindowsStore-armv8-*": "VC-WIN64-ARM-UWP",
|
||||
"WindowsStore-*-*": "VC-WIN32-ONECORE",
|
||||
"WindowsCE-*-*": "VC-CE",
|
||||
"SunOS-x86-gcc": "solaris-x86-gcc",
|
||||
"SunOS-x86_64-gcc": "solaris64-x86_64-gcc",
|
||||
"SunOS-sparc-gcc": "solaris-sparcv8-gcc",
|
||||
"SunOS-sparcv9-gcc": "solaris64-sparcv9-gcc",
|
||||
"SunOS-x86-suncc": "solaris-x86-cc",
|
||||
"SunOS-x86_64-suncc": "solaris64-x86_64-cc",
|
||||
"SunOS-sparc-suncc": "solaris-sparcv8-cc",
|
||||
"SunOS-sparcv9-suncc": "solaris64-sparcv9-cc",
|
||||
"SunOS-*-*": "solaris-common",
|
||||
"*BSD-x86-*": "BSD-x86",
|
||||
"*BSD-x86_64-*": "BSD-x86_64",
|
||||
"*BSD-ia64-*": "BSD-ia64",
|
||||
"*BSD-sparc-*": "BSD-sparcv8",
|
||||
"*BSD-sparcv9-*": "BSD-sparcv9",
|
||||
"*BSD-armv8-*": "BSD-generic64",
|
||||
"*BSD-mips64-*": "BSD-generic64",
|
||||
"*BSD-ppc64-*": "BSD-generic64",
|
||||
"*BSD-ppc64le-*": "BSD-generic64",
|
||||
"*BSD-ppc64be-*": "BSD-generic64",
|
||||
"AIX-ppc32-gcc": "aix-gcc",
|
||||
"AIX-ppc64-gcc": "aix64-gcc",
|
||||
"AIX-pcc32-*": "aix-cc",
|
||||
"AIX-ppc64-*": "aix64-cc",
|
||||
"AIX-*-*": "aix-common",
|
||||
"*BSD-*-*": "BSD-generic32",
|
||||
"Emscripten-*-*": "cc",
|
||||
"Neutrino-*-*": "BASE_unix",
|
||||
}
|
||||
|
||||
@property
|
||||
def _ancestor_target(self):
|
||||
if "CONAN_OPENSSL_CONFIGURATION" in os.environ:
|
||||
return os.environ["CONAN_OPENSSL_CONFIGURATION"]
|
||||
compiler = "Visual Studio" if self.settings.compiler == "msvc" else self.settings.compiler
|
||||
query = f"{self.settings.os}-{self.settings.arch}-{compiler}"
|
||||
ancestor = next((self._targets[i] for i in self._targets if fnmatch.fnmatch(query, i)), None)
|
||||
if not ancestor:
|
||||
raise ConanInvalidConfiguration(
|
||||
f"Unsupported configuration ({self.settings.os}/{self.settings.arch}/{self.settings.compiler}).\n"
|
||||
f"Please open an issue at {self.url}.\n"
|
||||
f"Alternatively, set the CONAN_OPENSSL_CONFIGURATION environment variable into your conan profile."
|
||||
)
|
||||
return ancestor
|
||||
|
||||
def _tool(self, env_name, apple_name):
|
||||
if env_name in os.environ:
|
||||
return os.environ[env_name]
|
||||
if self.settings.compiler == "apple-clang":
|
||||
return getattr(XCRun(self), apple_name)
|
||||
return None
|
||||
|
||||
def _get_default_openssl_dir(self):
|
||||
if self.settings.os == "Linux":
|
||||
return "/etc/ssl"
|
||||
return "res"
|
||||
|
||||
@property
|
||||
def _configure_args(self):
|
||||
openssldir = self.options.openssldir or self._get_default_openssl_dir()
|
||||
openssldir = unix_path(self, openssldir) if self.win_bash else openssldir
|
||||
args = [
|
||||
f'"{self._target}"',
|
||||
"shared" if self.options.shared else "no-shared",
|
||||
"--prefix=/",
|
||||
f"--openssldir=\"{openssldir}\"",
|
||||
"no-unit-test",
|
||||
"no-threads" if self.options.no_threads else "threads",
|
||||
f"PERL={self._perl}",
|
||||
"no-tests",
|
||||
"--debug" if self.settings.build_type == "Debug" else "--release",
|
||||
"--libdir=lib", # See https://github.com/openssl/openssl/blob/master/INSTALL.md#libdir
|
||||
]
|
||||
|
||||
if self.settings.os in ["tvOS", "watchOS"]:
|
||||
args.append(" -DNO_FORK") # fork is not available on tvOS and watchOS
|
||||
if self.settings.os == "Android":
|
||||
args.append(" -D__ANDROID_API__=%s" % str(self.settings.os.api_level)) # see NOTES.ANDROID
|
||||
if self.settings.os == "Emscripten":
|
||||
args.append("-D__STDC_NO_ATOMICS__=1")
|
||||
if self.settings.os == "Windows":
|
||||
if self.options.enable_capieng:
|
||||
args.append("enable-capieng")
|
||||
if self.options.capieng_dialog:
|
||||
args.append("-DOPENSSL_CAPIENG_DIALOG=1")
|
||||
else:
|
||||
args.append("-fPIC" if self.options.get_safe("fPIC", True) else "no-pic")
|
||||
|
||||
args.append("no-md2")
|
||||
|
||||
if self.settings.os == "Neutrino":
|
||||
args.append("no-asm -lsocket -latomic")
|
||||
if self._is_clang_cl:
|
||||
# #error <stdatomic.h> is not yet supported when compiling as C, but this is planned for a future release.
|
||||
args.append("-D__STDC_NO_ATOMICS__")
|
||||
|
||||
if Version(conan_version).major < 2:
|
||||
possible_values = self.options.values.fields
|
||||
else:
|
||||
possible_values = self.options.possible_values
|
||||
for option_name in possible_values:
|
||||
activated = self.options.get_safe(option_name)
|
||||
if activated and option_name not in ["fPIC", "openssldir", "capieng_dialog", "enable_capieng"]:
|
||||
self.output.info("activated option: %s" % option_name)
|
||||
args.append(option_name.replace("_", "-"))
|
||||
return args
|
||||
|
||||
def _create_targets(self):
|
||||
config_template = """{targets} = (
|
||||
"{target}" => {{
|
||||
inherit_from => {ancestor},
|
||||
cflags => add("{cflags}"),
|
||||
cxxflags => add("{cxxflags}"),
|
||||
{defines}
|
||||
includes => add({includes}),
|
||||
lflags => add("{lflags}"),
|
||||
{shared_target}
|
||||
{shared_cflag}
|
||||
{shared_extension}
|
||||
{cc}
|
||||
{cxx}
|
||||
{ar}
|
||||
{ranlib}
|
||||
{perlasm_scheme}
|
||||
}},
|
||||
);
|
||||
"""
|
||||
gen_info = json.loads(load(self, os.path.join(self.generators_folder, "gen_info.conf")))
|
||||
self.output.info(f"gen_info = {gen_info}")
|
||||
cflags = []
|
||||
cxxflags = []
|
||||
cflags.extend(gen_info["CFLAGS"])
|
||||
cxxflags.extend(gen_info["CXXFLAGS"])
|
||||
|
||||
cc = self._tool("CC", "cc")
|
||||
cxx = self._tool("CXX", "cxx")
|
||||
ar = self._tool("AR", "ar")
|
||||
ranlib = self._tool("RANLIB", "ranlib")
|
||||
|
||||
perlasm_scheme = ""
|
||||
if self._perlasm_scheme:
|
||||
perlasm_scheme = 'perlasm_scheme => "%s",' % self._perlasm_scheme
|
||||
|
||||
cc = 'cc => "%s",' % cc if cc else ""
|
||||
cxx = 'cxx => "%s",' % cxx if cxx else ""
|
||||
ar = 'ar => "%s",' % ar if ar else ""
|
||||
defines = ", ".join(f'"{d}"' for d in gen_info["DEFINES"])
|
||||
defines = 'defines => add([%s]),' % defines if defines else ""
|
||||
ranlib = 'ranlib => "%s",' % ranlib if ranlib else ""
|
||||
targets = "my %targets"
|
||||
includes = ""
|
||||
|
||||
ancestor = f'[ "{self._ancestor_target}" ]'
|
||||
shared_cflag = ''
|
||||
shared_extension = ''
|
||||
shared_target = ''
|
||||
if self.settings.os == 'Neutrino':
|
||||
if self.options.shared:
|
||||
shared_extension = r'shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",'
|
||||
shared_target = 'shared_target => "gnu-shared",'
|
||||
if self.options.get_safe("fPIC", True):
|
||||
shared_cflag='shared_cflag => "-fPIC",'
|
||||
|
||||
if self.settings.os in ["iOS", "tvOS", "watchOS"] and self.conf.get("tools.apple:enable_bitcode", check_type=bool):
|
||||
cflags.append("-fembed-bitcode")
|
||||
cxxflags.append("-fembed-bitcode")
|
||||
|
||||
config = config_template.format(targets=targets,
|
||||
target=self._target,
|
||||
ancestor=ancestor,
|
||||
cc=cc,
|
||||
cxx=cxx,
|
||||
ar=ar,
|
||||
ranlib=ranlib,
|
||||
cflags=" ".join(cflags),
|
||||
cxxflags=" ".join(cxxflags),
|
||||
defines=defines,
|
||||
includes=includes,
|
||||
perlasm_scheme=perlasm_scheme,
|
||||
shared_target=shared_target,
|
||||
shared_extension=shared_extension,
|
||||
shared_cflag=shared_cflag,
|
||||
lflags=" ".join(gen_info["LDFLAGS"]))
|
||||
self.output.info("using target: %s -> %s" % (self._target, self._ancestor_target))
|
||||
self.output.info(config)
|
||||
|
||||
save(self, os.path.join(self.source_folder, "Configurations", "20-conan.conf"), config)
|
||||
|
||||
@property
|
||||
def _perl(self):
|
||||
if self._use_nmake:
|
||||
return self.dependencies.build["strawberryperl"].conf_info.get("user.strawberryperl:perl", check_type=str)
|
||||
return "perl"
|
||||
|
||||
@contextmanager
|
||||
def _make_context(self):
|
||||
if self._use_nmake:
|
||||
# Windows: when cmake generates its cache, it populates some environment variables as well.
|
||||
# If cmake also initiates openssl build, their values (containing spaces and forward slashes)
|
||||
# break nmake (don't know about mingw make). So we fix them
|
||||
def sanitize_env_var(var):
|
||||
return '"{}"'.format(var).replace('/', '\\') if '"' not in var else var
|
||||
env = Environment()
|
||||
for key in ("CC", "RC"):
|
||||
if os.getenv(key):
|
||||
env.define(key, sanitize_env_var(os.getenv(key)))
|
||||
with env.vars(self).apply():
|
||||
yield
|
||||
else:
|
||||
yield
|
||||
|
||||
def build(self):
|
||||
apply_conandata_patches(self)
|
||||
autotools = Autotools(self)
|
||||
self._create_targets()
|
||||
with self._make_context():
|
||||
with chdir(self, self.source_folder):
|
||||
# workaround for clang-cl not producing .pdb files
|
||||
if self._is_clang_cl:
|
||||
save(self, "ossl_static.pdb", "")
|
||||
args = " ".join(self._configure_args)
|
||||
self.output.info(self._configure_args)
|
||||
|
||||
if self._use_nmake:
|
||||
self._replace_runtime_in_file(os.path.join("Configurations", "10-main.conf"))
|
||||
|
||||
self.run(f'{self._perl} ./Configure {args}')
|
||||
|
||||
self._patch_install_name()
|
||||
|
||||
if self._use_nmake:
|
||||
self.run("nmake /F Makefile")
|
||||
else:
|
||||
autotools.make()
|
||||
|
||||
def _patch_install_name(self):
|
||||
if is_apple_os(self) and self.options.shared:
|
||||
old_str = '-install_name $(INSTALLTOP)/$(LIBDIR)/'
|
||||
new_str = '-install_name @rpath/'
|
||||
replace_in_file(self, "Makefile", old_str, new_str)
|
||||
if self._use_nmake:
|
||||
# NMAKE interprets trailing backslash as line continuation
|
||||
replace_in_file(self, "Makefile", 'INSTALLTOP_dir=\\', 'INSTALLTOP_dir=/')
|
||||
|
||||
def _replace_runtime_in_file(self, filename):
|
||||
runtime = msvc_runtime_flag(self)
|
||||
for e in ["MDd", "MTd", "MD", "MT"]:
|
||||
replace_in_file(self, filename, "/{} ".format(e), "/{} ".format(runtime), strict=False)
|
||||
replace_in_file(self, filename, "/{}\"".format(e), "/{}\"".format(runtime), strict=False)
|
||||
|
||||
def package(self):
|
||||
copy(self, "*LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"), keep_path=False)
|
||||
if self._use_nmake:
|
||||
with chdir(self, self.source_folder):
|
||||
self.run(f"nmake -f Makefile install_sw DESTDIR={self.package_folder}")
|
||||
rm(self, "*.pdb", self.package_folder, recursive=True)
|
||||
else:
|
||||
autotools = Autotools(self)
|
||||
with chdir(self, self.source_folder):
|
||||
args = [f"DESTDIR={unix_path(self, self.package_folder)}"]
|
||||
autotools.make(target="install_sw", args=args)
|
||||
|
||||
if self.options.shared:
|
||||
libdir = os.path.join(self.package_folder, "lib")
|
||||
for file in os.listdir(libdir):
|
||||
if self._is_mingw and file.endswith(".dll.a"):
|
||||
continue
|
||||
if file.endswith(".a"):
|
||||
os.unlink(os.path.join(libdir, file))
|
||||
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
|
||||
self._create_cmake_module_variables(
|
||||
os.path.join(self.package_folder, self._module_file_rel_path)
|
||||
)
|
||||
|
||||
def _create_cmake_module_variables(self, module_file):
|
||||
content = textwrap.dedent("""\
|
||||
set(OPENSSL_FOUND TRUE)
|
||||
if(DEFINED OpenSSL_INCLUDE_DIR)
|
||||
set(OPENSSL_INCLUDE_DIR ${OpenSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_Crypto_LIBS)
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${OpenSSL_Crypto_LIBS})
|
||||
set(OPENSSL_CRYPTO_LIBRARIES ${OpenSSL_Crypto_LIBS}
|
||||
${OpenSSL_Crypto_DEPENDENCIES}
|
||||
${OpenSSL_Crypto_FRAMEWORKS}
|
||||
${OpenSSL_Crypto_SYSTEM_LIBS})
|
||||
elseif(DEFINED openssl_OpenSSL_Crypto_LIBS_%(config)s)
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${openssl_OpenSSL_Crypto_LIBS_%(config)s})
|
||||
set(OPENSSL_CRYPTO_LIBRARIES ${openssl_OpenSSL_Crypto_LIBS_%(config)s}
|
||||
${openssl_OpenSSL_Crypto_DEPENDENCIES_%(config)s}
|
||||
${openssl_OpenSSL_Crypto_FRAMEWORKS_%(config)s}
|
||||
${openssl_OpenSSL_Crypto_SYSTEM_LIBS_%(config)s})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_SSL_LIBS)
|
||||
set(OPENSSL_SSL_LIBRARY ${OpenSSL_SSL_LIBS})
|
||||
set(OPENSSL_SSL_LIBRARIES ${OpenSSL_SSL_LIBS}
|
||||
${OpenSSL_SSL_DEPENDENCIES}
|
||||
${OpenSSL_SSL_FRAMEWORKS}
|
||||
${OpenSSL_SSL_SYSTEM_LIBS})
|
||||
elseif(DEFINED openssl_OpenSSL_SSL_LIBS_%(config)s)
|
||||
set(OPENSSL_SSL_LIBRARY ${openssl_OpenSSL_SSL_LIBS_%(config)s})
|
||||
set(OPENSSL_SSL_LIBRARIES ${openssl_OpenSSL_SSL_LIBS_%(config)s}
|
||||
${openssl_OpenSSL_SSL_DEPENDENCIES_%(config)s}
|
||||
${openssl_OpenSSL_SSL_FRAMEWORKS_%(config)s}
|
||||
${openssl_OpenSSL_SSL_SYSTEM_LIBS_%(config)s})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_LIBRARIES)
|
||||
set(OPENSSL_LIBRARIES ${OpenSSL_LIBRARIES})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_VERSION)
|
||||
set(OPENSSL_VERSION ${OpenSSL_VERSION})
|
||||
endif()
|
||||
""" % {"config":str(self.settings.build_type).upper()})
|
||||
save(self, module_file, content)
|
||||
|
||||
@property
|
||||
def _module_file_rel_path(self):
|
||||
return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake")
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
self.cpp_info.set_property("cmake_file_name", "OpenSSL")
|
||||
self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path])
|
||||
self.cpp_info.set_property("pkg_config_name", "openssl")
|
||||
|
||||
self.cpp_info.components["crypto"].set_property("cmake_target_name", "OpenSSL::Crypto")
|
||||
self.cpp_info.components["crypto"].set_property("pkg_config_name", "libcrypto")
|
||||
self.cpp_info.components["ssl"].set_property("cmake_target_name", "OpenSSL::SSL")
|
||||
self.cpp_info.components["ssl"].set_property("pkg_config_name", "libssl")
|
||||
if self._use_nmake:
|
||||
self.cpp_info.components["ssl"].libs = ["libssl"]
|
||||
self.cpp_info.components["crypto"].libs = ["libcrypto"]
|
||||
else:
|
||||
self.cpp_info.components["ssl"].libs = ["ssl"]
|
||||
self.cpp_info.components["crypto"].libs = ["crypto"]
|
||||
|
||||
self.cpp_info.components["ssl"].requires = ["crypto"]
|
||||
|
||||
if self.settings.os == "Windows":
|
||||
self.cpp_info.components["crypto"].system_libs.extend(["crypt32", "ws2_32", "advapi32", "user32", "bcrypt"])
|
||||
elif self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.components["crypto"].system_libs.extend(["dl", "rt"])
|
||||
self.cpp_info.components["ssl"].system_libs.append("dl")
|
||||
if not self.options.no_threads:
|
||||
self.cpp_info.components["crypto"].system_libs.append("pthread")
|
||||
self.cpp_info.components["ssl"].system_libs.append("pthread")
|
||||
elif self.settings.os == "Neutrino":
|
||||
self.cpp_info.components["crypto"].system_libs.append("atomic")
|
||||
self.cpp_info.components["ssl"].system_libs.append("atomic")
|
||||
self.cpp_info.components["crypto"].system_libs.append("socket")
|
||||
self.cpp_info.components["ssl"].system_libs.append("socket")
|
||||
|
||||
# TODO: to remove in conan v2 once cmake_find_package* generators removed
|
||||
self.cpp_info.names["cmake_find_package"] = "OpenSSL"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "OpenSSL"
|
||||
self.cpp_info.components["ssl"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
|
||||
self.cpp_info.components["crypto"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
|
||||
self.cpp_info.components["crypto"].names["cmake_find_package"] = "Crypto"
|
||||
self.cpp_info.components["crypto"].names["cmake_find_package_multi"] = "Crypto"
|
||||
self.cpp_info.components["ssl"].names["cmake_find_package"] = "SSL"
|
||||
self.cpp_info.components["ssl"].names["cmake_find_package_multi"] = "SSL"
|
||||
32
recipes/openssl/1.x.x/patches/1.1.1-tvos-watchos.patch
Normal file
32
recipes/openssl/1.x.x/patches/1.1.1-tvos-watchos.patch
Normal file
@@ -0,0 +1,32 @@
|
||||
--- apps/ocsp.c
|
||||
+++ apps/ocsp.c
|
||||
@@ -33,6 +33,13 @@
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
+/* fork() breaks AppleTVOS, WatchOS, AppleTVSimulator and WatchSimulator */
|
||||
+/* Users should configure with -DNO_FORK */
|
||||
+#if defined(NO_FORK)
|
||||
+# undef HAVE_FORK
|
||||
+# define HAVE_FORK 0
|
||||
+#endif
|
||||
+
|
||||
#ifndef HAVE_FORK
|
||||
#if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS)
|
||||
# define HAVE_FORK 0
|
||||
--- apps/speed.c
|
||||
+++ apps/speed.c
|
||||
@@ -99,6 +99,13 @@
|
||||
#endif
|
||||
#include <openssl/modes.h>
|
||||
|
||||
+/* fork() breaks AppleTVOS, WatchOS, AppleTVSimulator and WatchSimulator */
|
||||
+/* Users should configure with -DNO_FORK */
|
||||
+#if defined(NO_FORK)
|
||||
+# undef HAVE_FORK
|
||||
+# define HAVE_FORK 0
|
||||
+#endif
|
||||
+
|
||||
#ifndef HAVE_FORK
|
||||
# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_VXWORKS)
|
||||
# define HAVE_FORK 0
|
||||
31
recipes/openssl/1.x.x/test_package/CMakeLists.txt
Normal file
31
recipes/openssl/1.x.x/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(test_package C)
|
||||
|
||||
option(OPENSSL_WITH_ZLIB "OpenSSL with zlib support" ON)
|
||||
|
||||
set(OpenSSL_DEBUG 1)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
# Test whether variables from https://cmake.org/cmake/help/latest/module/FindOpenSSL.html
|
||||
# are properly defined in conan generators
|
||||
set(_custom_vars
|
||||
OPENSSL_FOUND
|
||||
OPENSSL_INCLUDE_DIR
|
||||
OPENSSL_CRYPTO_LIBRARY
|
||||
OPENSSL_CRYPTO_LIBRARIES
|
||||
OPENSSL_SSL_LIBRARY
|
||||
OPENSSL_SSL_LIBRARIES
|
||||
OPENSSL_LIBRARIES
|
||||
OPENSSL_VERSION
|
||||
)
|
||||
foreach(_custom_var ${_custom_vars})
|
||||
if(DEFINED ${_custom_var})
|
||||
message(STATUS "${_custom_var}: ${${_custom_var}}")
|
||||
else()
|
||||
message(FATAL_ERROR "${_custom_var} not defined")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
add_executable(${PROJECT_NAME} digest.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<BOOL:${OPENSSL_WITH_ZLIB}>:WITH_ZLIB>)
|
||||
31
recipes/openssl/1.x.x/test_package/conanfile.py
Normal file
31
recipes/openssl/1.x.x/test_package/conanfile.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeDeps", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.variables["OPENSSL_WITH_ZLIB"] = not self.dependencies["openssl"].options.get_safe("no_zlib", True)
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
||||
106
recipes/openssl/1.x.x/test_package/digest.c
Normal file
106
recipes/openssl/1.x.x/test_package/digest.c
Normal file
@@ -0,0 +1,106 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/ssl.h>
|
||||
#if defined(WITH_ZLIB)
|
||||
#include <openssl/comp.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER > 0x10101000L
|
||||
#define OPENSSL_1_1_1_OR_LATER
|
||||
#endif
|
||||
|
||||
void SHA3_hash(const EVP_MD *type, const unsigned char *message, size_t message_len, unsigned char *digest, unsigned int *digest_len) {
|
||||
EVP_MD_CTX *mdctx;
|
||||
|
||||
if((mdctx = EVP_MD_CTX_create()) == NULL)
|
||||
printf("EVP_MD_CTX_create error!\n");
|
||||
|
||||
if(EVP_DigestInit_ex(mdctx, type, NULL) != 1)
|
||||
printf("EVP_DigestInit_ex error!\n");
|
||||
|
||||
if(EVP_DigestUpdate(mdctx, message, message_len) != 1)
|
||||
printf("EVP_DigestUpdate error!\n");
|
||||
|
||||
if(EVP_DigestFinal_ex(mdctx, digest, digest_len) != 1)
|
||||
printf("EVP_DigestFinal_ex error!\n");
|
||||
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned int digest_len;
|
||||
unsigned char md5_digest[MD5_DIGEST_LENGTH],
|
||||
sha1_digest[SHA_DIGEST_LENGTH],
|
||||
sha256_digest[SHA256_DIGEST_LENGTH],
|
||||
sha512_digest[SHA512_DIGEST_LENGTH],
|
||||
sha3_256_digest[SHA256_DIGEST_LENGTH],
|
||||
sha3_512_digest[SHA512_DIGEST_LENGTH];
|
||||
char md5_string[MD5_DIGEST_LENGTH*2+1] = {0},
|
||||
sha1_string[SHA_DIGEST_LENGTH*2+1] = {0},
|
||||
sha256_string[SHA256_DIGEST_LENGTH*2+1] = {0},
|
||||
sha512_string[SHA512_DIGEST_LENGTH*2+1] = {0},
|
||||
sha3_256_string[SHA256_DIGEST_LENGTH*2+1] = {0},
|
||||
sha3_512_string[SHA512_DIGEST_LENGTH*2+1] = {0};
|
||||
char string[] = "happy";
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
SSL_library_init();
|
||||
#else
|
||||
OPENSSL_init_ssl(0, NULL);
|
||||
#endif
|
||||
|
||||
MD5((unsigned char*)&string, strlen(string), (unsigned char*)&md5_digest);
|
||||
SHA1((unsigned char*)&string, strlen(string), (unsigned char*)&sha1_digest);
|
||||
SHA256((unsigned char*)&string, strlen(string), (unsigned char*)&sha256_digest);
|
||||
SHA512((unsigned char*)&string, strlen(string), (unsigned char*)&sha512_digest);
|
||||
#ifdef OPENSSL_1_1_1_OR_LATER
|
||||
SHA3_hash(EVP_sha3_256(), (unsigned char*)&string, strlen(string), (unsigned char*)&sha3_256_digest, &digest_len);
|
||||
SHA3_hash(EVP_sha3_512(), (unsigned char*)&string, strlen(string), (unsigned char*)&sha3_512_digest, &digest_len);
|
||||
#endif
|
||||
int i;
|
||||
for(i = 0; i < MD5_DIGEST_LENGTH; i++)
|
||||
snprintf(&md5_string[i*2], sizeof(md5_string)-i*2, "%02x", (unsigned int)md5_digest[i]);
|
||||
|
||||
for(i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||
snprintf(&sha1_string[i*2], sizeof(sha1_string)-i*2, "%02x", (unsigned int)sha1_digest[i]);
|
||||
|
||||
for(i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
||||
snprintf(&sha256_string[i*2], sizeof(sha256_string)-i*2, "%02x", (unsigned int)sha256_digest[i]);
|
||||
snprintf(&sha3_256_string[i*2], sizeof(sha3_256_string)-i*2, "%02x", (unsigned int)sha3_256_digest[i]);
|
||||
}
|
||||
|
||||
for(i = 0; i < SHA512_DIGEST_LENGTH; i++) {
|
||||
snprintf(&sha512_string[i*2], sizeof(sha512_string)-i*2, "%02x", (unsigned int)sha512_digest[i]);
|
||||
snprintf(&sha3_512_string[i*2], sizeof(sha3_512_string)-i*2, "%02x", (unsigned int)sha3_512_digest[i]);
|
||||
}
|
||||
|
||||
printf("md5 digest: %s\n", md5_string);
|
||||
printf("sha1 digest: %s\n", sha1_string);
|
||||
printf("sha256 digest: %s\n", sha256_string);
|
||||
printf("sha512 digest: %s\n", sha512_string);
|
||||
#ifdef OPENSSL_1_1_1_OR_LATER
|
||||
printf("sha3 256 digest: %s\n", sha3_256_string);
|
||||
printf("sha3 512 digest: %s\n", sha3_512_string);
|
||||
#endif
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
printf("SSL library version: %s\n", SSLeay_version(SSLEAY_VERSION));
|
||||
#else
|
||||
printf("SSL library version: %s\n", OpenSSL_version(OPENSSL_VERSION));
|
||||
#endif
|
||||
#if defined(WITH_ZLIB)
|
||||
COMP_METHOD *zlib_comp = COMP_zlib();
|
||||
printf("ZLIB compression method is named: %s\n", SSL_COMP_get_name(zlib_comp));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
8
recipes/openssl/1.x.x/test_v1_package/CMakeLists.txt
Normal file
8
recipes/openssl/1.x.x/test_v1_package/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package C)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
|
||||
25
recipes/openssl/1.x.x/test_v1_package/conanfile.py
Normal file
25
recipes/openssl/1.x.x/test_v1_package/conanfile.py
Normal file
@@ -0,0 +1,25 @@
|
||||
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"
|
||||
|
||||
def _openssl_option(self, name, default):
|
||||
try:
|
||||
return getattr(self.options["openssl"], name, default)
|
||||
except (AttributeError, ConanException):
|
||||
return default
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.definitions["OPENSSL_WITH_ZLIB"] = not self._openssl_option("no_zlib", True)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if not tools.cross_building(self):
|
||||
bin_path = os.path.join("bin", "test_package")
|
||||
self.run(bin_path, run_environment=True)
|
||||
34
recipes/openssl/3.x.x/conandata.yml
Normal file
34
recipes/openssl/3.x.x/conandata.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
sources:
|
||||
3.3.2:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.3.2/openssl-3.3.2.tar.gz"
|
||||
sha256: 2e8a40b01979afe8be0bbfb3de5dc1c6709fedb46d6c89c10da114ab5fc3d281
|
||||
3.3.1:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.3.1/openssl-3.3.1.tar.gz"
|
||||
sha256: 777cd596284c883375a2a7a11bf5d2786fc5413255efab20c50d6ffe6d020b7e
|
||||
3.2.3:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.2.3/openssl-3.2.3.tar.gz"
|
||||
sha256: 52b5f1c6b8022bc5868c308c54fb77705e702d6c6f4594f99a0df216acf46239
|
||||
3.2.2:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.2.2/openssl-3.2.2.tar.gz"
|
||||
sha256: 197149c18d9e9f292c43f0400acaba12e5f52cacfe050f3d199277ea738ec2e7
|
||||
3.2.1:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.2.1/openssl-3.2.1.tar.gz"
|
||||
sha256: 83c7329fe52c850677d75e5d0b0ca245309b97e8ecbcfdc1dfdc4ab9fac35b39
|
||||
3.1.7:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.1.7/openssl-3.1.7.tar.gz"
|
||||
sha256: 053a31fa80cf4aebe1068c987d2ef1e44ce418881427c4464751ae800c31d06c
|
||||
3.1.6:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.1.6/openssl-3.1.6.tar.gz"
|
||||
sha256: 5d2be4036b478ef3cb0a854ca9b353072c3a0e26d8a56f8f0ab9fb6ed32d38d7
|
||||
3.1.5:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.1.5/openssl-3.1.5.tar.gz"
|
||||
sha256: 6ae015467dabf0469b139ada93319327be24b98251ffaeceda0221848dc09262
|
||||
3.0.15:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.0.15/openssl-3.0.15.tar.gz"
|
||||
sha256: 23c666d0edf20f14249b3d8f0368acaee9ab585b09e1de82107c66e1f3ec9533
|
||||
3.0.14:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.0.14/openssl-3.0.14.tar.gz"
|
||||
sha256: eeca035d4dd4e84fc25846d952da6297484afa0650a6f84c682e39df3a4123ca
|
||||
3.0.13:
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/openssl/openssl/releases/download/openssl-3.0.13/openssl-3.0.13.tar.gz"
|
||||
sha256: 88525753f79d3bec27d2fa7c66aa0b92b3aa9498dafd93d7cfa4b3780cdae313
|
||||
683
recipes/openssl/3.x.x/conanfile.py
Normal file
683
recipes/openssl/3.x.x/conanfile.py
Normal file
@@ -0,0 +1,683 @@
|
||||
from conan import ConanFile
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.apple import fix_apple_shared_install_name, is_apple_os, XCRun
|
||||
from conan.tools.build import build_jobs
|
||||
from conan.tools.files import chdir, copy, get, replace_in_file, rm, rmdir, save
|
||||
from conan.tools.gnu import AutotoolsToolchain
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path
|
||||
from conan.tools.scm import Version
|
||||
|
||||
import fnmatch
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
required_conan_version = ">=1.57.0"
|
||||
|
||||
|
||||
class OpenSSLConan(ConanFile):
|
||||
name = "openssl"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://github.com/openssl/openssl"
|
||||
license = "Apache-2.0"
|
||||
topics = ("ssl", "tls", "encryption", "security")
|
||||
description = "A toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols"
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"enable_weak_ssl_ciphers": [True, False],
|
||||
"386": [True, False],
|
||||
"capieng_dialog": [True, False],
|
||||
"enable_capieng": [True, False],
|
||||
"enable_trace": [True, False],
|
||||
"no_aria": [True, False],
|
||||
"no_apps": [True, False],
|
||||
"no_autoload_config": [True, False],
|
||||
"no_asm": [True, False],
|
||||
"no_async": [True, False],
|
||||
"no_blake2": [True, False],
|
||||
"no_bf": [True, False],
|
||||
"no_camellia": [True, False],
|
||||
"no_chacha": [True, False],
|
||||
"no_cms": [True, False],
|
||||
"no_comp": [True, False],
|
||||
"no_ct": [True, False],
|
||||
"no_cast": [True, False],
|
||||
"no_deprecated": [True, False],
|
||||
"no_des": [True, False],
|
||||
"no_dgram": [True, False],
|
||||
"no_dh": [True, False],
|
||||
"no_dsa": [True, False],
|
||||
"no_dso": [True, False],
|
||||
"no_ec": [True, False],
|
||||
"no_ecdh": [True, False],
|
||||
"no_ecdsa": [True, False],
|
||||
"no_engine": [True, False],
|
||||
"no_filenames": [True, False],
|
||||
"no_fips": [True, False],
|
||||
"no_gost": [True, False],
|
||||
"no_idea": [True, False],
|
||||
"no_legacy": [True, False],
|
||||
"no_md2": [True, False],
|
||||
"no_md4": [True, False],
|
||||
"no_mdc2": [True, False],
|
||||
"no_module": [True, False],
|
||||
"no_ocsp": [True, False],
|
||||
"no_pinshared": [True, False],
|
||||
"no_rc2": [True, False],
|
||||
"no_rc4": [True, False],
|
||||
"no_rc5": [True, False],
|
||||
"no_rfc3779": [True, False],
|
||||
"no_rmd160": [True, False],
|
||||
"no_sm2": [True, False],
|
||||
"no_sm3": [True, False],
|
||||
"no_sm4": [True, False],
|
||||
"no_srp": [True, False],
|
||||
"no_srtp": [True, False],
|
||||
"no_sse2": [True, False],
|
||||
"no_ssl": [True, False],
|
||||
"no_stdio": [True, False],
|
||||
"no_seed": [True, False],
|
||||
"no_sock": [True, False],
|
||||
"no_ssl3": [True, False],
|
||||
"no_threads": [True, False],
|
||||
"no_tls1": [True, False],
|
||||
"no_ts": [True, False],
|
||||
"no_whirlpool": [True, False],
|
||||
"no_zlib": [True, False],
|
||||
"openssldir": [None, "ANY"],
|
||||
"tls_security_level": [None, 0, 1, 2, 3, 4, 5],
|
||||
}
|
||||
default_options = {key: False for key in options.keys()}
|
||||
default_options["fPIC"] = True
|
||||
default_options["no_md2"] = True
|
||||
default_options["openssldir"] = None
|
||||
default_options["tls_security_level"] = None
|
||||
|
||||
@property
|
||||
def _is_clang_cl(self):
|
||||
return self.settings.os == "Windows" and self.settings.compiler == "clang" and \
|
||||
self.settings.compiler.get_safe("runtime")
|
||||
|
||||
@property
|
||||
def _is_mingw(self):
|
||||
return self.settings.os == "Windows" and self.settings.compiler == "gcc"
|
||||
|
||||
@property
|
||||
def _use_nmake(self):
|
||||
return self._is_clang_cl or is_msvc(self)
|
||||
|
||||
@property
|
||||
def _settings_build(self):
|
||||
return getattr(self, "settings_build", self.settings)
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os != "Windows":
|
||||
self.options.rm_safe("capieng_dialog")
|
||||
self.options.rm_safe("enable_capieng")
|
||||
else:
|
||||
self.options.rm_safe("fPIC")
|
||||
|
||||
if self.settings.os == "Emscripten":
|
||||
self.options.no_asm = True
|
||||
self.options.no_threads = True
|
||||
self.options.no_stdio = True
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def requirements(self):
|
||||
if not self.options.no_zlib:
|
||||
self.requires("zlib/[>=1.2.11 <2]")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.os == "Emscripten":
|
||||
if not all((self.options.no_asm, self.options.no_threads, self.options.no_stdio)):
|
||||
raise ConanInvalidConfiguration("os=Emscripten requires openssl:{no_asm,no_threads,no_stdio}=True")
|
||||
|
||||
if self.settings.os == "iOS" and self.options.shared:
|
||||
raise ConanInvalidConfiguration("OpenSSL 3 does not support building shared libraries for iOS")
|
||||
|
||||
def build_requirements(self):
|
||||
if self._settings_build.os == "Windows":
|
||||
if not self.options.no_asm:
|
||||
self.tool_requires("nasm/2.16.01")
|
||||
if self._use_nmake:
|
||||
self.tool_requires("strawberryperl/5.32.1.1")
|
||||
else:
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
@property
|
||||
def _target(self):
|
||||
target = f"conan-{self.settings.build_type}-{self.settings.os}-{self.settings.arch}-{self.settings.compiler}-{self.settings.compiler.version}"
|
||||
if self._use_nmake:
|
||||
target = f"VC-{target}" # VC- prefix is important as it's checked by Configure
|
||||
if self._is_mingw:
|
||||
target = f"mingw-{target}"
|
||||
return target
|
||||
|
||||
@property
|
||||
def _perlasm_scheme(self):
|
||||
# right now, we need to tweak this for iOS & Android only, as they inherit from generic targets
|
||||
if self.settings.os in ("iOS", "watchOS", "tvOS"):
|
||||
return {
|
||||
"armv7": "ios32",
|
||||
"armv7s": "ios32",
|
||||
"armv8": "ios64",
|
||||
"armv8_32": "ios64",
|
||||
"armv8.3": "ios64",
|
||||
"armv7k": "ios32",
|
||||
}.get(str(self.settings.arch), None)
|
||||
elif self.settings.os == "Android":
|
||||
return {
|
||||
"armv7": "void",
|
||||
"armv8": "linux64",
|
||||
"mips": "o32",
|
||||
"mips64": "64",
|
||||
"x86": "android",
|
||||
"x86_64": "elf",
|
||||
}.get(str(self.settings.arch), None)
|
||||
return None
|
||||
|
||||
@property
|
||||
def _asm_target(self):
|
||||
if self.settings.os in ("Android", "iOS", "watchOS", "tvOS"):
|
||||
return {
|
||||
"x86": "x86_asm" if self.settings.os == "Android" else None,
|
||||
"x86_64": "x86_64_asm" if self.settings.os == "Android" else None,
|
||||
"armv5el": "armv4_asm",
|
||||
"armv5hf": "armv4_asm",
|
||||
"armv6": "armv4_asm",
|
||||
"armv7": "armv4_asm",
|
||||
"armv7hf": "armv4_asm",
|
||||
"armv7s": "armv4_asm",
|
||||
"armv7k": "armv4_asm",
|
||||
"armv8": "aarch64_asm",
|
||||
"armv8_32": "aarch64_asm",
|
||||
"armv8.3": "aarch64_asm",
|
||||
"mips": "mips32_asm",
|
||||
"mips64": "mips64_asm",
|
||||
"sparc": "sparcv8_asm",
|
||||
"sparcv9": "sparcv9_asm",
|
||||
"ia64": "ia64_asm",
|
||||
"ppc32be": "ppc32_asm",
|
||||
"ppc32": "ppc32_asm",
|
||||
"ppc64le": "ppc64_asm",
|
||||
"ppc64": "ppc64_asm",
|
||||
"s390": "s390x_asm",
|
||||
"s390x": "s390x_asm"
|
||||
}.get(str(self.settings.os), None)
|
||||
|
||||
@property
|
||||
def _targets(self):
|
||||
is_cygwin = self.settings.get_safe("os.subsystem") == "cygwin"
|
||||
return {
|
||||
"Linux-x86-clang": "linux-x86-clang",
|
||||
"Linux-x86_64-clang": "linux-x86_64-clang",
|
||||
"Linux-x86-*": "linux-x86",
|
||||
"Linux-x86_64-*": "linux-x86_64",
|
||||
"Linux-armv4-*": "linux-armv4",
|
||||
"Linux-armv4i-*": "linux-armv4",
|
||||
"Linux-armv5el-*": "linux-armv4",
|
||||
"Linux-armv5hf-*": "linux-armv4",
|
||||
"Linux-armv6-*": "linux-armv4",
|
||||
"Linux-armv7-*": "linux-armv4",
|
||||
"Linux-armv7hf-*": "linux-armv4",
|
||||
"Linux-armv7s-*": "linux-armv4",
|
||||
"Linux-armv7k-*": "linux-armv4",
|
||||
"Linux-armv8-*": "linux-aarch64",
|
||||
"Linux-armv8.3-*": "linux-aarch64",
|
||||
"Linux-armv8-32-*": "linux-arm64ilp32",
|
||||
"Linux-mips-*": "linux-mips32",
|
||||
"Linux-mips64-*": "linux-mips64",
|
||||
"Linux-ppc32-*": "linux-ppc32",
|
||||
"Linux-ppc32le-*": "linux-pcc32",
|
||||
"Linux-ppc32be-*": "linux-ppc32",
|
||||
"Linux-ppc64-*": "linux-ppc64",
|
||||
"Linux-ppc64le-*": "linux-ppc64le",
|
||||
"Linux-pcc64be-*": "linux-pcc64",
|
||||
"Linux-s390x-*": "linux64-s390x",
|
||||
"Linux-e2k-*": "linux-generic64",
|
||||
"Linux-sparc-*": "linux-sparcv8",
|
||||
"Linux-sparcv9-*": "linux64-sparcv9",
|
||||
"Linux-*-*": "linux-generic32",
|
||||
"Macos-x86-*": "darwin-i386-cc",
|
||||
"Macos-x86_64-*": "darwin64-x86_64-cc",
|
||||
"Macos-ppc32-*": "darwin-ppc-cc",
|
||||
"Macos-ppc32be-*": "darwin-ppc-cc",
|
||||
"Macos-ppc64-*": "darwin64-ppc-cc",
|
||||
"Macos-ppc64be-*": "darwin64-ppc-cc",
|
||||
"Macos-armv8-*": "darwin64-arm64-cc",
|
||||
"Macos-*-*": "darwin-common",
|
||||
"iOS-x86_64-*": "darwin64-x86_64-cc",
|
||||
"iOS-*-*": "iphoneos-cross",
|
||||
"watchOS-*-*": "iphoneos-cross",
|
||||
"tvOS-*-*": "iphoneos-cross",
|
||||
# Android targets are very broken, see https://github.com/openssl/openssl/issues/7398
|
||||
"Android-armv7-*": "linux-generic32",
|
||||
"Android-armv7hf-*": "linux-generic32",
|
||||
"Android-armv8-*": "linux-generic64",
|
||||
"Android-x86-*": "linux-x86-clang",
|
||||
"Android-x86_64-*": "linux-x86_64-clang",
|
||||
"Android-mips-*": "linux-generic32",
|
||||
"Android-mips64-*": "linux-generic64",
|
||||
"Android-*-*": "linux-generic32",
|
||||
"Windows-x86-gcc": "Cygwin-x86" if is_cygwin else "mingw",
|
||||
"Windows-x86_64-gcc": "Cygwin-x86_64" if is_cygwin else "mingw64",
|
||||
"Windows-*-gcc": "Cygwin-common" if is_cygwin else "mingw-common",
|
||||
"Windows-ia64-Visual Studio": "VC-WIN64I", # Itanium
|
||||
"Windows-x86-Visual Studio": "VC-WIN32",
|
||||
"Windows-x86_64-Visual Studio": "VC-WIN64A",
|
||||
"Windows-armv7-Visual Studio": "VC-WIN32-ARM",
|
||||
"Windows-armv8-Visual Studio": "VC-WIN64-ARM",
|
||||
"Windows-*-Visual Studio": "VC-noCE-common",
|
||||
"Windows-ia64-clang": "VC-WIN64I", # Itanium
|
||||
"Windows-x86-clang": "VC-WIN32",
|
||||
"Windows-x86_64-clang": "VC-WIN64A",
|
||||
"Windows-armv7-clang": "VC-WIN32-ARM",
|
||||
"Windows-armv8-clang": "VC-WIN64-ARM",
|
||||
"Windows-*-clang": "VC-noCE-common",
|
||||
"WindowsStore-x86-*": "VC-WIN32-UWP",
|
||||
"WindowsStore-x86_64-*": "VC-WIN64A-UWP",
|
||||
"WindowsStore-armv7-*": "VC-WIN32-ARM-UWP",
|
||||
"WindowsStore-armv8-*": "VC-WIN64-ARM-UWP",
|
||||
"WindowsStore-*-*": "VC-WIN32-ONECORE",
|
||||
"WindowsCE-*-*": "VC-CE",
|
||||
"SunOS-x86-gcc": "solaris-x86-gcc",
|
||||
"SunOS-x86_64-gcc": "solaris64-x86_64-gcc",
|
||||
"SunOS-sparc-gcc": "solaris-sparcv8-gcc",
|
||||
"SunOS-sparcv9-gcc": "solaris64-sparcv9-gcc",
|
||||
"SunOS-x86-suncc": "solaris-x86-cc",
|
||||
"SunOS-x86_64-suncc": "solaris64-x86_64-cc",
|
||||
"SunOS-sparc-suncc": "solaris-sparcv8-cc",
|
||||
"SunOS-sparcv9-suncc": "solaris64-sparcv9-cc",
|
||||
"SunOS-*-*": "solaris-common",
|
||||
"*BSD-x86-*": "BSD-x86",
|
||||
"*BSD-x86_64-*": "BSD-x86_64",
|
||||
"*BSD-ia64-*": "BSD-ia64",
|
||||
"*BSD-sparc-*": "BSD-sparcv8",
|
||||
"*BSD-sparcv9-*": "BSD-sparcv9",
|
||||
"*BSD-armv8-*": "BSD-generic64",
|
||||
"*BSD-mips64-*": "BSD-generic64",
|
||||
"*BSD-ppc64-*": "BSD-generic64",
|
||||
"*BSD-ppc64le-*": "BSD-generic64",
|
||||
"*BSD-ppc64be-*": "BSD-generic64",
|
||||
"AIX-ppc32-gcc": "aix-gcc",
|
||||
"AIX-ppc64-gcc": "aix64-gcc",
|
||||
"AIX-pcc32-*": "aix-cc",
|
||||
"AIX-ppc64-*": "aix64-cc",
|
||||
"AIX-*-*": "aix-common",
|
||||
"*BSD-*-*": "BSD-generic32",
|
||||
"Emscripten-*-*": "cc",
|
||||
"Neutrino-*-*": "BASE_unix",
|
||||
}
|
||||
|
||||
@property
|
||||
def _ancestor_target(self):
|
||||
if "CONAN_OPENSSL_CONFIGURATION" in os.environ:
|
||||
return os.environ["CONAN_OPENSSL_CONFIGURATION"]
|
||||
compiler = "Visual Studio" if self.settings.compiler == "msvc" else self.settings.compiler
|
||||
query = f"{self.settings.os}-{self.settings.arch}-{compiler}"
|
||||
ancestor = next((self._targets[i] for i in self._targets if fnmatch.fnmatch(query, i)), None)
|
||||
if not ancestor:
|
||||
raise ConanInvalidConfiguration(
|
||||
f"Unsupported configuration ({self.settings.os}/{self.settings.arch}/{self.settings.compiler}).\n"
|
||||
f"Please open an issue at {self.url}.\n"
|
||||
f"Alternatively, set the CONAN_OPENSSL_CONFIGURATION environment variable into your conan profile."
|
||||
)
|
||||
return ancestor
|
||||
|
||||
def _get_default_openssl_dir(self):
|
||||
if self.settings.os == "Linux":
|
||||
return "/etc/ssl"
|
||||
return os.path.join(self.package_folder, "res")
|
||||
|
||||
def _adjust_path(self, path):
|
||||
if self._use_nmake:
|
||||
return path.replace("\\", "/")
|
||||
return unix_path(self, path)
|
||||
|
||||
@property
|
||||
def _configure_args(self):
|
||||
openssldir = self.options.openssldir or self._get_default_openssl_dir()
|
||||
openssldir = unix_path(self, openssldir) if self.win_bash else openssldir
|
||||
args = [
|
||||
f'"{self._target}"',
|
||||
"shared" if self.options.shared else "no-shared",
|
||||
"--debug" if self.settings.build_type == "Debug" else "--release",
|
||||
"--prefix=/",
|
||||
"--libdir=lib",
|
||||
f"--openssldir=\"{openssldir}\"",
|
||||
"no-threads" if self.options.no_threads else "threads",
|
||||
f"PERL={self._perl}",
|
||||
"no-unit-test",
|
||||
"no-tests",
|
||||
]
|
||||
|
||||
if self.settings.os == "Android":
|
||||
args.append(f" -D__ANDROID_API__={str(self.settings.os.api_level)}") # see NOTES.ANDROID
|
||||
if self.settings.os == "Emscripten":
|
||||
args.append("-D__STDC_NO_ATOMICS__=1")
|
||||
if self.settings.os == "Windows":
|
||||
if self.options.enable_capieng:
|
||||
args.append("enable-capieng")
|
||||
if self.options.capieng_dialog:
|
||||
args.append("-DOPENSSL_CAPIENG_DIALOG=1")
|
||||
else:
|
||||
args.append("-fPIC" if self.options.get_safe("fPIC", True) else "no-pic")
|
||||
|
||||
args.append("no-fips" if self.options.get_safe("no_fips", True) else "enable-fips")
|
||||
args.append("no-md2" if self.options.get_safe("no_md2", True) else "enable-md2")
|
||||
if str(self.options.tls_security_level) != "None":
|
||||
args.append(f"-DOPENSSL_TLS_SECURITY_LEVEL={self.options.tls_security_level}")
|
||||
|
||||
if self.options.get_safe("enable_trace"):
|
||||
args.append("enable-trace")
|
||||
|
||||
if self.settings.os == "Neutrino":
|
||||
args.append("no-asm -lsocket -latomic")
|
||||
|
||||
if not self.options.no_zlib:
|
||||
zlib_cpp_info = self.dependencies["zlib"].cpp_info.aggregated_components()
|
||||
include_path = self._adjust_path(zlib_cpp_info.includedirs[0])
|
||||
if self._use_nmake:
|
||||
lib_path = self._adjust_path(os.path.join(zlib_cpp_info.libdirs[0], f"{zlib_cpp_info.libs[0]}.lib"))
|
||||
else:
|
||||
# Just path, GNU like compilers will find the right file
|
||||
lib_path = self._adjust_path(zlib_cpp_info.libdirs[0])
|
||||
|
||||
if self.dependencies["zlib"].options.shared:
|
||||
args.append("zlib-dynamic")
|
||||
else:
|
||||
args.append("zlib")
|
||||
|
||||
args.extend([
|
||||
f'--with-zlib-include="{include_path}"',
|
||||
f'--with-zlib-lib="{lib_path}"',
|
||||
])
|
||||
|
||||
for option_name in self.default_options.keys():
|
||||
if self.options.get_safe(option_name, False) and option_name not in ("shared", "fPIC", "openssldir", "tls_security_level", "capieng_dialog", "enable_capieng", "zlib", "no_fips", "no_md2"):
|
||||
self.output.info(f"Activated option: {option_name}")
|
||||
args.append(option_name.replace("_", "-"))
|
||||
return args
|
||||
|
||||
def generate(self):
|
||||
tc = AutotoolsToolchain(self)
|
||||
env = tc.environment()
|
||||
env.define_path("PERL", self._perl)
|
||||
if self.settings.compiler == "apple-clang":
|
||||
xcrun = XCRun(self)
|
||||
env.define_path("CROSS_SDK", os.path.basename(xcrun.sdk_path))
|
||||
env.define_path("CROSS_TOP", os.path.dirname(os.path.dirname(xcrun.sdk_path)))
|
||||
|
||||
self._create_targets(tc.cflags, tc.cxxflags, tc.defines, tc.ldflags)
|
||||
tc.generate(env)
|
||||
|
||||
def _create_targets(self, cflags, cxxflags, defines, ldflags):
|
||||
config_template = textwrap.dedent("""\
|
||||
{targets} = (
|
||||
"{target}" => {{
|
||||
inherit_from => {ancestor},
|
||||
cflags => add("{cflags}"),
|
||||
cxxflags => add("{cxxflags}"),
|
||||
{defines}
|
||||
lflags => add("{lflags}"),
|
||||
{shared_target}
|
||||
{shared_cflag}
|
||||
{shared_extension}
|
||||
{perlasm_scheme}
|
||||
}},
|
||||
);
|
||||
""")
|
||||
|
||||
perlasm_scheme = ""
|
||||
if self._perlasm_scheme:
|
||||
perlasm_scheme = f'perlasm_scheme => "{self._perlasm_scheme}",'
|
||||
|
||||
defines = '", "'.join(defines)
|
||||
defines = 'defines => add("%s"),' % defines if defines else ""
|
||||
targets = "my %targets"
|
||||
|
||||
if self._asm_target:
|
||||
ancestor = f'[ "{self._ancestor_target}", asm("{self._asm_target}") ]'
|
||||
else:
|
||||
ancestor = f'[ "{self._ancestor_target}" ]'
|
||||
shared_cflag = ""
|
||||
shared_extension = ""
|
||||
shared_target = ""
|
||||
if self.settings.os == "Neutrino":
|
||||
if self.options.shared:
|
||||
shared_extension = r'shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",'
|
||||
shared_target = 'shared_target => "gnu-shared",'
|
||||
if self.options.get_safe("fPIC", True):
|
||||
shared_cflag = 'shared_cflag => "-fPIC",'
|
||||
|
||||
if self.settings.os in ["iOS", "tvOS", "watchOS"] and self.conf.get("tools.apple:enable_bitcode", check_type=bool):
|
||||
cflags.append("-fembed-bitcode")
|
||||
cxxflags.append("-fembed-bitcode")
|
||||
|
||||
config = config_template.format(
|
||||
targets=targets,
|
||||
target=self._target,
|
||||
ancestor=ancestor,
|
||||
cflags=" ".join(cflags),
|
||||
cxxflags=" ".join(cxxflags),
|
||||
defines=defines,
|
||||
perlasm_scheme=perlasm_scheme,
|
||||
shared_target=shared_target,
|
||||
shared_extension=shared_extension,
|
||||
shared_cflag=shared_cflag,
|
||||
lflags=" ".join(ldflags)
|
||||
)
|
||||
self.output.info(f"using target: {self._target} -> {self._ancestor_target}")
|
||||
self.output.info(config)
|
||||
|
||||
save(self, os.path.join(self.source_folder, "Configurations", "20-conan.conf"), config)
|
||||
|
||||
def _run_make(self, targets=None, parallel=True, install=False):
|
||||
command = [self._make_program]
|
||||
if install:
|
||||
command.append(f"DESTDIR={self._adjust_path(self.package_folder)}")
|
||||
if targets:
|
||||
command.extend(targets)
|
||||
if not self._use_nmake:
|
||||
command.append(f"-j{build_jobs(self)}" if parallel else "-j1")
|
||||
self.run(" ".join(command), env="conanbuild")
|
||||
|
||||
@property
|
||||
def _perl(self):
|
||||
if self._use_nmake:
|
||||
return self.dependencies.build["strawberryperl"].conf_info.get("user.strawberryperl:perl", check_type=str)
|
||||
return "perl"
|
||||
|
||||
def _make(self):
|
||||
with chdir(self, self.source_folder):
|
||||
args = " ".join(self._configure_args)
|
||||
|
||||
if self._use_nmake:
|
||||
self._replace_runtime_in_file(os.path.join("Configurations", "10-main.conf"))
|
||||
|
||||
self.run(f"{self._perl} ./Configure {args}", env="conanbuild")
|
||||
if self._use_nmake:
|
||||
# When `--prefix=/`, the scripts derive `\` without escaping, which
|
||||
# causes issues on Windows
|
||||
replace_in_file(self, "Makefile", "INSTALLTOP_dir=\\", "INSTALLTOP_dir=\\\\")
|
||||
if Version(self.version) >= "3.3.0":
|
||||
# replace backslashes in paths with forward slashes
|
||||
mkinstallvars_pl = os.path.join(self.source_folder, "util", "mkinstallvars.pl")
|
||||
if Version(self.version) >= "3.3.2":
|
||||
replace_in_file(self, mkinstallvars_pl, "push @{$values{$k}}, $v;", """$v =~ s|\\\\|/|g; push @{$values{$k}}, $v;""")
|
||||
replace_in_file(self, mkinstallvars_pl, "$values{$k} = $v;", """$v->[0] =~ s|\\\\|/|g; $values{$k} = $v;""")
|
||||
else:
|
||||
replace_in_file(self, mkinstallvars_pl, "$ENV{$k} = $v;", """$v =~ s|\\\\|/|g; $ENV{$k} = $v;""")
|
||||
self._run_make()
|
||||
|
||||
def _make_install(self):
|
||||
with chdir(self, self.source_folder):
|
||||
self._run_make(targets=["install_sw"], parallel=False, install=True)
|
||||
|
||||
def build(self):
|
||||
self._make()
|
||||
configdata_pm = self._adjust_path(os.path.join(self.source_folder, "configdata.pm"))
|
||||
self.run(f"{self._perl} {configdata_pm} --dump")
|
||||
|
||||
@property
|
||||
def _make_program(self):
|
||||
return "nmake" if self._use_nmake else "make"
|
||||
|
||||
def _replace_runtime_in_file(self, filename):
|
||||
runtime = msvc_runtime_flag(self)
|
||||
for e in ["MDd", "MTd", "MD", "MT"]:
|
||||
replace_in_file(self, filename, f"/{e} ", f"/{runtime} ", strict=False)
|
||||
replace_in_file(self, filename, f"/{e}\"", f"/{runtime}\"", strict=False)
|
||||
|
||||
def package(self):
|
||||
copy(self, "*LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
self._make_install()
|
||||
if is_apple_os(self):
|
||||
fix_apple_shared_install_name(self)
|
||||
|
||||
rm(self, "*.pdb", self.package_folder, "lib")
|
||||
if self.options.shared:
|
||||
libdir = os.path.join(self.package_folder, "lib")
|
||||
for file in os.listdir(libdir):
|
||||
if self._is_mingw and file.endswith(".dll.a"):
|
||||
continue
|
||||
if file.endswith(".a"):
|
||||
os.unlink(os.path.join(libdir, file))
|
||||
|
||||
if not self.options.no_fips:
|
||||
provdir = os.path.join(self.source_folder, "providers")
|
||||
modules_dir = os.path.join(self.package_folder, "lib", "ossl-modules")
|
||||
if self.settings.os == "Macos":
|
||||
copy(self, "fips.dylib", src=provdir, dst=modules_dir)
|
||||
elif self.settings.os == "Windows":
|
||||
copy(self, "fips.dll", src=provdir, dst=modules_dir)
|
||||
else:
|
||||
copy(self, "fips.so", src=provdir, dst=modules_dir)
|
||||
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
|
||||
|
||||
self._create_cmake_module_variables(
|
||||
os.path.join(self.package_folder, self._module_file_rel_path)
|
||||
)
|
||||
|
||||
def _create_cmake_module_variables(self, module_file):
|
||||
content = textwrap.dedent("""\
|
||||
set(OPENSSL_FOUND TRUE)
|
||||
if(DEFINED OpenSSL_INCLUDE_DIR)
|
||||
set(OPENSSL_INCLUDE_DIR ${OpenSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_Crypto_LIBS)
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${OpenSSL_Crypto_LIBS})
|
||||
set(OPENSSL_CRYPTO_LIBRARIES ${OpenSSL_Crypto_LIBS}
|
||||
${OpenSSL_Crypto_DEPENDENCIES}
|
||||
${OpenSSL_Crypto_FRAMEWORKS}
|
||||
${OpenSSL_Crypto_SYSTEM_LIBS})
|
||||
elseif(DEFINED openssl_OpenSSL_Crypto_LIBS_%(config)s)
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${openssl_OpenSSL_Crypto_LIBS_%(config)s})
|
||||
set(OPENSSL_CRYPTO_LIBRARIES ${openssl_OpenSSL_Crypto_LIBS_%(config)s}
|
||||
${openssl_OpenSSL_Crypto_DEPENDENCIES_%(config)s}
|
||||
${openssl_OpenSSL_Crypto_FRAMEWORKS_%(config)s}
|
||||
${openssl_OpenSSL_Crypto_SYSTEM_LIBS_%(config)s})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_SSL_LIBS)
|
||||
set(OPENSSL_SSL_LIBRARY ${OpenSSL_SSL_LIBS})
|
||||
set(OPENSSL_SSL_LIBRARIES ${OpenSSL_SSL_LIBS}
|
||||
${OpenSSL_SSL_DEPENDENCIES}
|
||||
${OpenSSL_SSL_FRAMEWORKS}
|
||||
${OpenSSL_SSL_SYSTEM_LIBS})
|
||||
elseif(DEFINED openssl_OpenSSL_SSL_LIBS_%(config)s)
|
||||
set(OPENSSL_SSL_LIBRARY ${openssl_OpenSSL_SSL_LIBS_%(config)s})
|
||||
set(OPENSSL_SSL_LIBRARIES ${openssl_OpenSSL_SSL_LIBS_%(config)s}
|
||||
${openssl_OpenSSL_SSL_DEPENDENCIES_%(config)s}
|
||||
${openssl_OpenSSL_SSL_FRAMEWORKS_%(config)s}
|
||||
${openssl_OpenSSL_SSL_SYSTEM_LIBS_%(config)s})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_LIBRARIES)
|
||||
set(OPENSSL_LIBRARIES ${OpenSSL_LIBRARIES})
|
||||
endif()
|
||||
if(DEFINED OpenSSL_VERSION)
|
||||
set(OPENSSL_VERSION ${OpenSSL_VERSION})
|
||||
endif()
|
||||
"""% {"config":str(self.settings.build_type).upper()})
|
||||
save(self, module_file, content)
|
||||
|
||||
@property
|
||||
def _module_subfolder(self):
|
||||
return os.path.join("lib", "cmake")
|
||||
|
||||
@property
|
||||
def _module_file_rel_path(self):
|
||||
return os.path.join(self._module_subfolder,
|
||||
f"conan-official-{self.name}-variables.cmake")
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_file_name", "OpenSSL")
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
self.cpp_info.set_property("pkg_config_name", "openssl")
|
||||
self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path])
|
||||
self.cpp_info.names["cmake_find_package"] = "OpenSSL"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "OpenSSL"
|
||||
self.cpp_info.components["ssl"].builddirs.append(self._module_subfolder)
|
||||
self.cpp_info.components["ssl"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
|
||||
self.cpp_info.components["ssl"].set_property("cmake_build_modules", [self._module_file_rel_path])
|
||||
self.cpp_info.components["crypto"].builddirs.append(self._module_subfolder)
|
||||
self.cpp_info.components["crypto"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
|
||||
self.cpp_info.components["crypto"].set_property("cmake_build_modules", [self._module_file_rel_path])
|
||||
|
||||
if self._use_nmake:
|
||||
self.cpp_info.components["ssl"].libs = ["libssl"]
|
||||
self.cpp_info.components["crypto"].libs = ["libcrypto"]
|
||||
else:
|
||||
self.cpp_info.components["ssl"].libs = ["ssl"]
|
||||
self.cpp_info.components["crypto"].libs = ["crypto"]
|
||||
|
||||
self.cpp_info.components["ssl"].requires = ["crypto"]
|
||||
|
||||
if not self.options.no_zlib:
|
||||
self.cpp_info.components["crypto"].requires.append("zlib::zlib")
|
||||
|
||||
if self.settings.os == "Windows":
|
||||
self.cpp_info.components["crypto"].system_libs.extend(["crypt32", "ws2_32", "advapi32", "user32", "bcrypt"])
|
||||
elif self.settings.os == "Linux":
|
||||
self.cpp_info.components["crypto"].system_libs.extend(["dl", "rt"])
|
||||
self.cpp_info.components["ssl"].system_libs.append("dl")
|
||||
if not self.options.no_threads:
|
||||
self.cpp_info.components["crypto"].system_libs.append("pthread")
|
||||
self.cpp_info.components["ssl"].system_libs.append("pthread")
|
||||
elif self.settings.os == "Neutrino":
|
||||
self.cpp_info.components["crypto"].system_libs.append("atomic")
|
||||
self.cpp_info.components["ssl"].system_libs.append("atomic")
|
||||
self.cpp_info.components["crypto"].system_libs.append("socket")
|
||||
self.cpp_info.components["ssl"].system_libs.append("socket")
|
||||
|
||||
self.cpp_info.components["crypto"].set_property("cmake_target_name", "OpenSSL::Crypto")
|
||||
self.cpp_info.components["crypto"].set_property("pkg_config_name", "libcrypto")
|
||||
self.cpp_info.components["ssl"].set_property("cmake_target_name", "OpenSSL::SSL")
|
||||
self.cpp_info.components["ssl"].set_property("pkg_config_name", "libssl")
|
||||
self.cpp_info.components["crypto"].names["cmake_find_package"] = "Crypto"
|
||||
self.cpp_info.components["crypto"].names["cmake_find_package_multi"] = "Crypto"
|
||||
self.cpp_info.components["ssl"].names["cmake_find_package"] = "SSL"
|
||||
self.cpp_info.components["ssl"].names["cmake_find_package_multi"] = "SSL"
|
||||
|
||||
openssl_modules_dir = os.path.join(self.package_folder, "lib", "ossl-modules")
|
||||
self.runenv_info.define_path("OPENSSL_MODULES", openssl_modules_dir)
|
||||
|
||||
# For legacy 1.x downstream consumers, remove once recipe is 2.0 only:
|
||||
self.env_info.OPENSSL_MODULES = openssl_modules_dir
|
||||
44
recipes/openssl/3.x.x/test_package/CMakeLists.txt
Normal file
44
recipes/openssl/3.x.x/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
option(OPENSSL_WITH_LEGACY "OpenSSL with support for the legacy provider" ON)
|
||||
option(OPENSSL_WITH_MD4 "OpenSSL with MD4 support (needs legacy provider)" ON)
|
||||
option(OPENSSL_WITH_RIPEMD160 "OpenSSL with RIPEMD16 support (needs legacy provider)" ON)
|
||||
|
||||
set(OpenSSL_DEBUG 1)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
# Test whether variables from https://cmake.org/cmake/help/latest/module/FindOpenSSL.html
|
||||
# are properly defined in conan generators
|
||||
set(_custom_vars
|
||||
OPENSSL_FOUND
|
||||
OPENSSL_INCLUDE_DIR
|
||||
OPENSSL_CRYPTO_LIBRARY
|
||||
OPENSSL_CRYPTO_LIBRARIES
|
||||
OPENSSL_SSL_LIBRARY
|
||||
OPENSSL_SSL_LIBRARIES
|
||||
OPENSSL_LIBRARIES
|
||||
OPENSSL_VERSION
|
||||
)
|
||||
foreach(_custom_var ${_custom_vars})
|
||||
if(DEFINED ${_custom_var})
|
||||
message(STATUS "${_custom_var}: ${${_custom_var}}")
|
||||
else()
|
||||
message(FATAL_ERROR "${_custom_var} not defined")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
add_executable(test_package test_package.c digest.c)
|
||||
target_link_libraries(test_package PRIVATE OpenSSL::SSL OpenSSL::Crypto)
|
||||
|
||||
if(OPENSSL_WITH_LEGACY)
|
||||
target_sources(test_package PRIVATE digest_legacy.c)
|
||||
# do now show deperecation warnings
|
||||
target_compile_definitions(test_package PRIVATE OPENSSL_SUPPRESS_DEPRECATED TEST_OPENSSL_LEGACY)
|
||||
if(OPENSSL_WITH_MD4)
|
||||
target_compile_definitions(test_package PRIVATE OPENSSL_WITH_MD4)
|
||||
endif()
|
||||
if(OPENSSL_WITH_RIPEMD160)
|
||||
target_compile_definitions(test_package PRIVATE OPENSSL_WITH_RIPEMD160)
|
||||
endif()
|
||||
endif()
|
||||
38
recipes/openssl/3.x.x/test_package/conanfile.py
Normal file
38
recipes/openssl/3.x.x/test_package/conanfile.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeDeps", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def _with_legacy(self):
|
||||
return (not self.dependencies["openssl"].options.no_legacy and
|
||||
((not self.dependencies["openssl"].options.no_md4) or
|
||||
(not self.dependencies["openssl"].options.no_rmd160)))
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.cache_variables["OPENSSL_WITH_LEGACY"] = self._with_legacy()
|
||||
tc.cache_variables["OPENSSL_WITH_MD4"] = not self.dependencies["openssl"].options.no_md4
|
||||
tc.cache_variables["OPENSSL_WITH_RIPEMD160"] = not self.dependencies["openssl"].options.no_rmd160
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
||||
65
recipes/openssl/3.x.x/test_package/digest.c
Normal file
65
recipes/openssl/3.x.x/test_package/digest.c
Normal file
@@ -0,0 +1,65 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
void SHA3_hash(const EVP_MD *type, const unsigned char *message, size_t message_len, unsigned char *digest, unsigned int *digest_len) {
|
||||
EVP_MD_CTX *mdctx;
|
||||
|
||||
if((mdctx = EVP_MD_CTX_create()) == NULL)
|
||||
printf("EVP_MD_CTX_create error!\n");
|
||||
|
||||
if(EVP_DigestInit_ex(mdctx, type, NULL) != 1)
|
||||
printf("EVP_DigestInit_ex error!\n");
|
||||
|
||||
if(EVP_DigestUpdate(mdctx, message, message_len) != 1)
|
||||
printf("EVP_DigestUpdate error!\n");
|
||||
|
||||
if(EVP_DigestFinal_ex(mdctx, digest, digest_len) != 1)
|
||||
printf("EVP_DigestFinal_ex error!\n");
|
||||
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
}
|
||||
|
||||
void digest()
|
||||
{
|
||||
unsigned int digest_len;
|
||||
unsigned char sha256_digest[SHA256_DIGEST_LENGTH],
|
||||
sha512_digest[SHA512_DIGEST_LENGTH],
|
||||
sha3_256_digest[SHA256_DIGEST_LENGTH],
|
||||
sha3_512_digest[SHA512_DIGEST_LENGTH];
|
||||
char sha256_string[SHA256_DIGEST_LENGTH*2+1] = {0},
|
||||
sha512_string[SHA512_DIGEST_LENGTH*2+1] = {0},
|
||||
sha3_256_string[SHA256_DIGEST_LENGTH*2+1] = {0},
|
||||
sha3_512_string[SHA512_DIGEST_LENGTH*2+1] = {0};
|
||||
char string[] = "happy";
|
||||
|
||||
SHA256((unsigned char*)&string, strlen(string), (unsigned char*)&sha256_digest);
|
||||
SHA512((unsigned char*)&string, strlen(string), (unsigned char*)&sha512_digest);
|
||||
SHA3_hash(EVP_sha3_256(), (unsigned char*)&string, strlen(string), (unsigned char*)&sha3_256_digest, &digest_len);
|
||||
SHA3_hash(EVP_sha3_512(), (unsigned char*)&string, strlen(string), (unsigned char*)&sha3_512_digest, &digest_len);
|
||||
|
||||
for(int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
||||
snprintf(&sha256_string[i*2], sizeof(sha256_string)-i*2, "%02x", (unsigned int)sha256_digest[i]);
|
||||
snprintf(&sha3_256_string[i*2], sizeof(sha3_256_string)-i*2, "%02x", (unsigned int)sha3_256_digest[i]);
|
||||
}
|
||||
|
||||
for(int i = 0; i < SHA512_DIGEST_LENGTH; i++) {
|
||||
snprintf(&sha512_string[i*2], sizeof(sha512_string)-i*2, "%02x", (unsigned int)sha512_digest[i]);
|
||||
snprintf(&sha3_512_string[i*2], sizeof(sha3_512_string)-i*2, "%02x", (unsigned int)sha3_512_digest[i]);
|
||||
}
|
||||
|
||||
printf("sha256 digest: %s\n", sha256_string);
|
||||
printf("sha512 digest: %s\n", sha512_string);
|
||||
printf("sha3 256 digest: %s\n", sha3_256_string);
|
||||
printf("sha3 512 digest: %s\n", sha3_512_string);
|
||||
|
||||
}
|
||||
141
recipes/openssl/3.x.x/test_package/digest_legacy.c
Normal file
141
recipes/openssl/3.x.x/test_package/digest_legacy.c
Normal file
@@ -0,0 +1,141 @@
|
||||
#include <openssl/evp.h>
|
||||
#if OPENSSL_WITH_MD4
|
||||
#include <openssl/md4.h> // MD4 needs legacy provider
|
||||
#endif
|
||||
#if OPENSSL_WITH_RIPEMD160
|
||||
#include <openssl/ripemd.h> // RIPEMD160 needs legacy provider
|
||||
#endif
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
int MDx_hash(const EVP_MD *type, const unsigned char *message, size_t message_len, unsigned char *digest, unsigned int *digest_len) {
|
||||
EVP_MD_CTX *mdctx;
|
||||
|
||||
if((mdctx = EVP_MD_CTX_create()) == NULL)
|
||||
{
|
||||
printf("EVP_MD_CTX_create error!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(EVP_DigestInit_ex(mdctx, type, NULL) != 1)
|
||||
{
|
||||
printf("EVP_DigestInit_ex error!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(EVP_DigestUpdate(mdctx, message, message_len) != 1)
|
||||
{
|
||||
printf("EVP_DigestUpdate error!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(EVP_DigestFinal_ex(mdctx, digest, digest_len) != 1)
|
||||
{
|
||||
printf("EVP_DigestFinal_ex error!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int digest_legacy()
|
||||
{
|
||||
unsigned int digest_len;
|
||||
unsigned char md5_digest[MD5_DIGEST_LENGTH];
|
||||
unsigned char md5_digest2[MD5_DIGEST_LENGTH];
|
||||
char md5_string[MD5_DIGEST_LENGTH*2+1] = {0};
|
||||
char md5_string2[MD5_DIGEST_LENGTH*2+1] = {0};
|
||||
char string[] = "happy";
|
||||
|
||||
MD5((unsigned char*)&string, strlen(string), (unsigned char*)&md5_digest);
|
||||
if (MDx_hash(EVP_md5(), (unsigned char*)&string, strlen(string), (unsigned char*)&md5_digest2, &digest_len))
|
||||
return 1;
|
||||
|
||||
for(int i = 0; i < MD5_DIGEST_LENGTH; i++) {
|
||||
snprintf(&md5_string[i*2], sizeof(md5_string)-i*2, "%02x", (unsigned int)md5_digest[i]);
|
||||
snprintf(&md5_string2[i*2], sizeof(md5_string2)-i*2, "%02x", (unsigned int)md5_digest2[i]);
|
||||
}
|
||||
|
||||
// MD4 needs the legacy provider
|
||||
OSSL_LIB_CTX* context = OSSL_LIB_CTX_new();
|
||||
// From https://wiki.openssl.org/index.php/OpenSSL_3.0
|
||||
/* Load Multiple providers into the default (nullptr) library context */
|
||||
OSSL_PROVIDER* legacy = OSSL_PROVIDER_load(context, "legacy");
|
||||
if (0 == legacy) {
|
||||
const char* error_string = ERR_error_string(ERR_get_error(), 0);
|
||||
fprintf(stderr, "Loading legacy provider failed with this error:\n");
|
||||
fprintf(stderr, "\t%s\n", error_string);
|
||||
return 1;
|
||||
}
|
||||
OSSL_LIB_CTX* oldcontex = OSSL_LIB_CTX_set0_default(context);
|
||||
printf("Legacy provider successfully loaded.\n");
|
||||
|
||||
#if OPENSSL_WITH_MD4
|
||||
unsigned char md4_digest[MD4_DIGEST_LENGTH];
|
||||
unsigned char md4_digest2[MD4_DIGEST_LENGTH];
|
||||
char md4_string[MD4_DIGEST_LENGTH*2+1] = {0};
|
||||
char md4_string2[MD4_DIGEST_LENGTH*2+1] = {0};
|
||||
|
||||
MD4((unsigned char*)&string, strlen(string), (unsigned char*)&md4_digest);
|
||||
if (MDx_hash(EVP_md4(), (unsigned char*)&string, strlen(string), (unsigned char*)&md4_digest2, &digest_len)) {
|
||||
const char* error_string = ERR_error_string(ERR_get_error(), 0);
|
||||
fprintf(stderr, "MD4 calculation failed with this error:\n");
|
||||
fprintf(stderr, "\t%s\n", error_string);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < MD4_DIGEST_LENGTH; i++) {
|
||||
snprintf(&md4_string[i*2], sizeof(md4_string)-i*2, "%02x", (unsigned int)md4_digest[i]);
|
||||
snprintf(&md4_string2[i*2], sizeof(md4_string2)-i*2, "%02x", (unsigned int)md4_digest2[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENSSL_WITH_RIPEMD160
|
||||
unsigned char ripemd160_digest[RIPEMD160_DIGEST_LENGTH];
|
||||
unsigned char ripemd160_digest2[RIPEMD160_DIGEST_LENGTH];
|
||||
char ripemd160_string[RIPEMD160_DIGEST_LENGTH*2+1] = {0};
|
||||
char ripemd160_string2[RIPEMD160_DIGEST_LENGTH*2+1] = {0};
|
||||
|
||||
RIPEMD160((unsigned char*)&string, strlen(string), (unsigned char*)&ripemd160_digest);
|
||||
if (MDx_hash(EVP_ripemd160(), (unsigned char*)&string, strlen(string), (unsigned char*)&ripemd160_digest2, &digest_len)) {
|
||||
const char* error_string = ERR_error_string(ERR_get_error(), 0);
|
||||
fprintf(stderr, "RIPEMD160 calculation failed with this error:\n");
|
||||
fprintf(stderr, "\t%s\n", error_string);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < RIPEMD160_DIGEST_LENGTH; i++) {
|
||||
snprintf(&ripemd160_string[i*2], sizeof(ripemd160_string)-i*2, "%02x", (unsigned int)ripemd160_digest[i]);
|
||||
snprintf(&ripemd160_string2[i*2], sizeof(ripemd160_string2)-i*2, "%02x", (unsigned int)ripemd160_digest2[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
OSSL_LIB_CTX_set0_default(oldcontex);
|
||||
OSSL_PROVIDER_unload(legacy);
|
||||
OSSL_LIB_CTX_free(context);
|
||||
|
||||
printf("MD5 digest: %s\n", md5_string);
|
||||
printf("MD5 digest (variant 2): %s\n", md5_string2);
|
||||
#if OPENSSL_WITH_MD4
|
||||
printf("MD4 digest: %s\n", md4_string);
|
||||
printf("MD4 digest (variant 2): %s\n", md4_string2);
|
||||
#endif
|
||||
#if OPENSSL_WITH_RIPEMD160
|
||||
printf("RIPEMD160 digest: %s\n", ripemd160_string);
|
||||
printf("RIPEMD160 digest (variant 2): %s\n", ripemd160_string2);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
24
recipes/openssl/3.x.x/test_package/test_package.c
Normal file
24
recipes/openssl/3.x.x/test_package/test_package.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
void digest();
|
||||
int digest_legacy();
|
||||
|
||||
int main()
|
||||
{
|
||||
int legacy_result = 0;
|
||||
OPENSSL_init_ssl(0, NULL);
|
||||
printf("OpenSSL version: %s\n", OpenSSL_version(OPENSSL_VERSION));
|
||||
|
||||
digest();
|
||||
|
||||
#if defined(TEST_OPENSSL_LEGACY)
|
||||
legacy_result = digest_legacy();
|
||||
if (legacy_result != 0) {
|
||||
printf("Error testing the digest_legacy() function\n");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
recipes/openssl/3.x.x/test_v1_package/CMakeLists.txt
Normal file
44
recipes/openssl/3.x.x/test_v1_package/CMakeLists.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package C)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
option(OPENSSL_WITH_ZLIB "OpenSSL with zlib support" ON)
|
||||
option(OPENSSL_WITH_LEGACY "OpenSSL with support for the legacy provider" ON)
|
||||
option(OPENSSL_WITH_MD4 "OpenSSL with MD4 support (needs legacy provider)" ON)
|
||||
option(OPENSSL_WITH_RIPEMD160 "OpenSSL with RIPEMD16 support (needs legacy provider)" ON)
|
||||
|
||||
set(OpenSSL_DEBUG 1)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
message("OPENSSL_FOUND: ${OPENSSL_FOUND}")
|
||||
message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
|
||||
message("OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}")
|
||||
message("OPENSSL_CRYPTO_LIBRARIES: ${OPENSSL_CRYPTO_LIBRARIES}")
|
||||
message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}")
|
||||
message("OPENSSL_SSL_LIBRARIES: ${OPENSSL_SSL_LIBRARIES}")
|
||||
message("OPENSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
|
||||
message("OPENSSL_VERSION: ${OPENSSL_VERSION}")
|
||||
|
||||
add_executable(digest digest.c)
|
||||
if(OPENSSL_WITH_ZLIB)
|
||||
target_compile_definitions(digest PRIVATE WITH_ZLIB)
|
||||
endif()
|
||||
target_link_libraries(digest OpenSSL::Crypto)
|
||||
|
||||
if(OPENSSL_WITH_LEGACY)
|
||||
add_executable(digest_legacy digest_legacy.c)
|
||||
# do now show deperecation warnings
|
||||
target_compile_definitions(digest_legacy PRIVATE OPENSSL_SUPPRESS_DEPRECATED)
|
||||
if(OPENSSL_WITH_MD4)
|
||||
target_compile_definitions(digest_legacy PRIVATE OPENSSL_WITH_MD4)
|
||||
endif()
|
||||
if(OPENSSL_WITH_RIPEMD160)
|
||||
target_compile_definitions(digest_legacy PRIVATE OPENSSL_WITH_RIPEMD160)
|
||||
endif()
|
||||
if(OPENSSL_WITH_ZLIB)
|
||||
target_compile_definitions(digest_legacy PRIVATE WITH_ZLIB)
|
||||
endif()
|
||||
target_link_libraries(digest_legacy OpenSSL::Crypto)
|
||||
endif()
|
||||
40
recipes/openssl/3.x.x/test_v1_package/conanfile.py
Normal file
40
recipes/openssl/3.x.x/test_v1_package/conanfile.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from conans import CMake, tools, ConanFile
|
||||
from conan.tools.build import cross_building
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "compiler", "arch", "build_type"
|
||||
generators = "cmake", "cmake_find_package", "pkg_config"
|
||||
|
||||
def _with_legacy(self):
|
||||
return (not self.options["openssl"].no_legacy and
|
||||
((not self.options["openssl"].no_md4) or
|
||||
(not self.options["openssl"].no_rmd160)))
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.definitions["OPENSSL_WITH_ZLIB"] = not self.options["openssl"].no_zlib
|
||||
cmake.definitions["OPENSSL_WITH_LEGACY"] = self._with_legacy()
|
||||
cmake.definitions["OPENSSL_WITH_MD4"] = not self.options["openssl"].no_md4
|
||||
cmake.definitions["OPENSSL_WITH_RIPEMD160"] = not self.options["openssl"].no_rmd160
|
||||
if self.settings.os == "Android":
|
||||
cmake.definitions["CONAN_LIBCXX"] = ""
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if not cross_building(self):
|
||||
bin_path = os.path.join("bin", "digest")
|
||||
self.run(bin_path, run_environment=True)
|
||||
|
||||
if not self.options["openssl"].no_legacy:
|
||||
bin_legacy_path = os.path.join("bin", "digest_legacy")
|
||||
self.run(bin_legacy_path, run_environment=True)
|
||||
|
||||
if not self.options["openssl"].no_stdio:
|
||||
self.run("openssl version", run_environment=True)
|
||||
assert os.path.exists(os.path.join(self.deps_cpp_info["openssl"].rootpath, "licenses", "LICENSE.txt"))
|
||||
|
||||
for fn in ("libcrypto.pc", "libssl.pc", "openssl.pc",):
|
||||
assert os.path.isfile(os.path.join(self.build_folder, fn))
|
||||
73
recipes/openssl/3.x.x/test_v1_package/digest.c
Normal file
73
recipes/openssl/3.x.x/test_v1_package/digest.c
Normal file
@@ -0,0 +1,73 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/ssl.h>
|
||||
#if defined(WITH_ZLIB)
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
void SHA3_hash(const EVP_MD *type, const unsigned char *message, size_t message_len, unsigned char *digest, unsigned int *digest_len) {
|
||||
EVP_MD_CTX *mdctx;
|
||||
|
||||
if((mdctx = EVP_MD_CTX_create()) == NULL)
|
||||
printf("EVP_MD_CTX_create error!\n");
|
||||
|
||||
if(EVP_DigestInit_ex(mdctx, type, NULL) != 1)
|
||||
printf("EVP_DigestInit_ex error!\n");
|
||||
|
||||
if(EVP_DigestUpdate(mdctx, message, message_len) != 1)
|
||||
printf("EVP_DigestUpdate error!\n");
|
||||
|
||||
if(EVP_DigestFinal_ex(mdctx, digest, digest_len) != 1)
|
||||
printf("EVP_DigestFinal_ex error!\n");
|
||||
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned int digest_len;
|
||||
unsigned char sha256_digest[SHA256_DIGEST_LENGTH],
|
||||
sha512_digest[SHA512_DIGEST_LENGTH],
|
||||
sha3_256_digest[SHA256_DIGEST_LENGTH],
|
||||
sha3_512_digest[SHA512_DIGEST_LENGTH];
|
||||
char sha256_string[SHA256_DIGEST_LENGTH*2+1] = {0},
|
||||
sha512_string[SHA512_DIGEST_LENGTH*2+1] = {0},
|
||||
sha3_256_string[SHA256_DIGEST_LENGTH*2+1] = {0},
|
||||
sha3_512_string[SHA512_DIGEST_LENGTH*2+1] = {0};
|
||||
char string[] = "happy";
|
||||
|
||||
SHA256((unsigned char*)&string, strlen(string), (unsigned char*)&sha256_digest);
|
||||
SHA512((unsigned char*)&string, strlen(string), (unsigned char*)&sha512_digest);
|
||||
SHA3_hash(EVP_sha3_256(), (unsigned char*)&string, strlen(string), (unsigned char*)&sha3_256_digest, &digest_len);
|
||||
SHA3_hash(EVP_sha3_512(), (unsigned char*)&string, strlen(string), (unsigned char*)&sha3_512_digest, &digest_len);
|
||||
|
||||
for(int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
||||
snprintf(&sha256_string[i*2], sizeof(sha256_string)-i*2, "%02x", (unsigned int)sha256_digest[i]);
|
||||
snprintf(&sha3_256_string[i*2], sizeof(sha3_256_string)-i*2, "%02x", (unsigned int)sha3_256_digest[i]);
|
||||
}
|
||||
|
||||
for(int i = 0; i < SHA512_DIGEST_LENGTH; i++) {
|
||||
snprintf(&sha512_string[i*2], sizeof(sha512_string)-i*2, "%02x", (unsigned int)sha512_digest[i]);
|
||||
snprintf(&sha3_512_string[i*2], sizeof(sha3_512_string)-i*2, "%02x", (unsigned int)sha3_512_digest[i]);
|
||||
}
|
||||
|
||||
printf("sha256 digest: %s\n", sha256_string);
|
||||
printf("sha512 digest: %s\n", sha512_string);
|
||||
printf("sha3 256 digest: %s\n", sha3_256_string);
|
||||
printf("sha3 512 digest: %s\n", sha3_512_string);
|
||||
printf("OpenSSL version: %s\n", OpenSSL_version(OPENSSL_VERSION));
|
||||
#if defined(WITH_ZLIB)
|
||||
printf("ZLIB version: %s\n", ZLIB_VERSION);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
148
recipes/openssl/3.x.x/test_v1_package/digest_legacy.c
Normal file
148
recipes/openssl/3.x.x/test_v1_package/digest_legacy.c
Normal file
@@ -0,0 +1,148 @@
|
||||
#include <openssl/evp.h>
|
||||
#if OPENSSL_WITH_MD4
|
||||
#include <openssl/md4.h> // MD4 needs legacy provider
|
||||
#endif
|
||||
#if OPENSSL_WITH_RIPEMD160
|
||||
#include <openssl/ripemd.h> // RIPEMD160 needs legacy provider
|
||||
#endif
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/ssl.h>
|
||||
#if defined(WITH_ZLIB)
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
int MDx_hash(const EVP_MD *type, const unsigned char *message, size_t message_len, unsigned char *digest, unsigned int *digest_len) {
|
||||
EVP_MD_CTX *mdctx;
|
||||
|
||||
if((mdctx = EVP_MD_CTX_create()) == NULL)
|
||||
{
|
||||
printf("EVP_MD_CTX_create error!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(EVP_DigestInit_ex(mdctx, type, NULL) != 1)
|
||||
{
|
||||
printf("EVP_DigestInit_ex error!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(EVP_DigestUpdate(mdctx, message, message_len) != 1)
|
||||
{
|
||||
printf("EVP_DigestUpdate error!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(EVP_DigestFinal_ex(mdctx, digest, digest_len) != 1)
|
||||
{
|
||||
printf("EVP_DigestFinal_ex error!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned int digest_len;
|
||||
unsigned char md5_digest[MD5_DIGEST_LENGTH];
|
||||
unsigned char md5_digest2[MD5_DIGEST_LENGTH];
|
||||
char md5_string[MD5_DIGEST_LENGTH*2+1] = {0};
|
||||
char md5_string2[MD5_DIGEST_LENGTH*2+1] = {0};
|
||||
char string[] = "happy";
|
||||
|
||||
MD5((unsigned char*)&string, strlen(string), (unsigned char*)&md5_digest);
|
||||
if (MDx_hash(EVP_md5(), (unsigned char*)&string, strlen(string), (unsigned char*)&md5_digest2, &digest_len))
|
||||
return 1;
|
||||
|
||||
for(int i = 0; i < MD5_DIGEST_LENGTH; i++) {
|
||||
snprintf(&md5_string[i*2], sizeof(md5_string)-i*2, "%02x", (unsigned int)md5_digest[i]);
|
||||
snprintf(&md5_string2[i*2], sizeof(md5_string2)-i*2, "%02x", (unsigned int)md5_digest2[i]);
|
||||
}
|
||||
|
||||
// MD4 needs the legacy provider
|
||||
OSSL_LIB_CTX* context = OSSL_LIB_CTX_new();
|
||||
// From https://wiki.openssl.org/index.php/OpenSSL_3.0
|
||||
/* Load Multiple providers into the default (nullptr) library context */
|
||||
OSSL_PROVIDER* legacy = OSSL_PROVIDER_load(context, "legacy");
|
||||
if (0 == legacy) {
|
||||
const char* error_string = ERR_error_string(ERR_get_error(), 0);
|
||||
fprintf(stderr, "Loading legacy provider failed with this error:\n");
|
||||
fprintf(stderr, "\t%s\n", error_string);
|
||||
return 1;
|
||||
}
|
||||
OSSL_LIB_CTX* oldcontex = OSSL_LIB_CTX_set0_default(context);
|
||||
printf("Legacy provider successfully loaded.\n");
|
||||
|
||||
#if OPENSSL_WITH_MD4
|
||||
unsigned char md4_digest[MD4_DIGEST_LENGTH];
|
||||
unsigned char md4_digest2[MD4_DIGEST_LENGTH];
|
||||
char md4_string[MD4_DIGEST_LENGTH*2+1] = {0};
|
||||
char md4_string2[MD4_DIGEST_LENGTH*2+1] = {0};
|
||||
|
||||
MD4((unsigned char*)&string, strlen(string), (unsigned char*)&md4_digest);
|
||||
if (MDx_hash(EVP_md4(), (unsigned char*)&string, strlen(string), (unsigned char*)&md4_digest2, &digest_len)) {
|
||||
const char* error_string = ERR_error_string(ERR_get_error(), 0);
|
||||
fprintf(stderr, "MD4 calculation failed with this error:\n");
|
||||
fprintf(stderr, "\t%s\n", error_string);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < MD4_DIGEST_LENGTH; i++) {
|
||||
snprintf(&md4_string[i*2], sizeof(md4_string)-i*2, "%02x", (unsigned int)md4_digest[i]);
|
||||
snprintf(&md4_string2[i*2], sizeof(md4_string2)-i*2, "%02x", (unsigned int)md4_digest2[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENSSL_WITH_RIPEMD160
|
||||
unsigned char ripemd160_digest[RIPEMD160_DIGEST_LENGTH];
|
||||
unsigned char ripemd160_digest2[RIPEMD160_DIGEST_LENGTH];
|
||||
char ripemd160_string[RIPEMD160_DIGEST_LENGTH*2+1] = {0};
|
||||
char ripemd160_string2[RIPEMD160_DIGEST_LENGTH*2+1] = {0};
|
||||
|
||||
RIPEMD160((unsigned char*)&string, strlen(string), (unsigned char*)&ripemd160_digest);
|
||||
if (MDx_hash(EVP_ripemd160(), (unsigned char*)&string, strlen(string), (unsigned char*)&ripemd160_digest2, &digest_len)) {
|
||||
const char* error_string = ERR_error_string(ERR_get_error(), 0);
|
||||
fprintf(stderr, "RIPEMD160 calculation failed with this error:\n");
|
||||
fprintf(stderr, "\t%s\n", error_string);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < RIPEMD160_DIGEST_LENGTH; i++) {
|
||||
snprintf(&ripemd160_string[i*2], sizeof(ripemd160_string)-i*2, "%02x", (unsigned int)ripemd160_digest[i]);
|
||||
snprintf(&ripemd160_string2[i*2], sizeof(ripemd160_string2)-i*2, "%02x", (unsigned int)ripemd160_digest2[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
OSSL_LIB_CTX_set0_default(oldcontex);
|
||||
OSSL_PROVIDER_unload(legacy);
|
||||
OSSL_LIB_CTX_free(context);
|
||||
|
||||
printf("MD5 digest: %s\n", md5_string);
|
||||
printf("MD5 digest (variant 2): %s\n", md5_string2);
|
||||
#if OPENSSL_WITH_MD4
|
||||
printf("MD4 digest: %s\n", md4_string);
|
||||
printf("MD4 digest (variant 2): %s\n", md4_string2);
|
||||
#endif
|
||||
#if OPENSSL_WITH_RIPEMD160
|
||||
printf("RIPEMD160 digest: %s\n", ripemd160_string);
|
||||
printf("RIPEMD160 digest (variant 2): %s\n", ripemd160_string2);
|
||||
#endif
|
||||
printf("OpenSSL version: %s\n", OpenSSL_version(OPENSSL_VERSION));
|
||||
#if defined(WITH_ZLIB)
|
||||
printf("ZLIB version: %s\n", ZLIB_VERSION);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
25
recipes/openssl/config.yml
Normal file
25
recipes/openssl/config.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
versions:
|
||||
"3.3.2":
|
||||
folder: "3.x.x"
|
||||
"3.3.1":
|
||||
folder: "3.x.x"
|
||||
"3.2.3":
|
||||
folder: "3.x.x"
|
||||
"3.2.2":
|
||||
folder: "3.x.x"
|
||||
"3.2.1":
|
||||
folder: "3.x.x"
|
||||
"3.1.7":
|
||||
folder: "3.x.x"
|
||||
"3.1.6":
|
||||
folder: "3.x.x"
|
||||
"3.1.5":
|
||||
folder: "3.x.x"
|
||||
"3.0.15":
|
||||
folder: "3.x.x"
|
||||
"3.0.14":
|
||||
folder: "3.x.x"
|
||||
"3.0.13":
|
||||
folder: "3.x.x"
|
||||
"1.1.1w":
|
||||
folder: "1.x.x"
|
||||
Reference in New Issue
Block a user