2021-01-21 14:13:59 +01:00
|
|
|
import subprocess
|
2023-09-26 14:14:33 +02:00
|
|
|
from typing import Optional, Sequence, Union
|
2021-01-21 14:13:59 +01:00
|
|
|
|
|
|
|
from build.makeproject import MakeProject
|
2023-09-26 12:47:44 +02:00
|
|
|
from .toolchain import AnyToolchain
|
2021-01-21 14:13:59 +01:00
|
|
|
|
|
|
|
class OpenSSLProject(MakeProject):
|
2023-09-26 14:14:33 +02:00
|
|
|
def __init__(self, url: Union[str, Sequence[str]], md5: str, installed: str,
|
2021-01-21 14:13:59 +01:00
|
|
|
**kwargs):
|
|
|
|
MakeProject.__init__(self, url, md5, installed, install_target='install_dev', **kwargs)
|
|
|
|
|
2023-09-26 12:47:44 +02:00
|
|
|
def get_make_args(self, toolchain: AnyToolchain) -> list[str]:
|
2021-01-21 14:13:59 +01:00
|
|
|
return MakeProject.get_make_args(self, toolchain) + [
|
|
|
|
'CC=' + toolchain.cc,
|
|
|
|
'CFLAGS=' + toolchain.cflags,
|
|
|
|
'CPPFLAGS=' + toolchain.cppflags,
|
|
|
|
'AR=' + toolchain.ar,
|
|
|
|
'RANLIB=' + toolchain.ranlib,
|
|
|
|
'build_libs',
|
|
|
|
]
|
|
|
|
|
2023-09-26 12:47:44 +02:00
|
|
|
def get_make_install_args(self, toolchain: AnyToolchain) -> list[str]:
|
2021-04-20 05:37:49 +02:00
|
|
|
# OpenSSL's Makefile runs "ranlib" during installation
|
|
|
|
return MakeProject.get_make_install_args(self, toolchain) + [
|
|
|
|
'RANLIB=' + toolchain.ranlib,
|
|
|
|
]
|
|
|
|
|
2023-09-26 12:47:44 +02:00
|
|
|
def _build(self, toolchain: AnyToolchain) -> None:
|
2021-01-21 14:13:59 +01:00
|
|
|
src = self.unpack(toolchain, out_of_tree=False)
|
|
|
|
|
|
|
|
# OpenSSL has a weird target architecture scheme with lots of
|
|
|
|
# hard-coded architectures; this table translates between our
|
|
|
|
# "toolchain_arch" (HOST_TRIPLET) and the OpenSSL target
|
|
|
|
openssl_archs = {
|
|
|
|
# not using "android-*" because those OpenSSL targets want
|
|
|
|
# to know where the SDK is, but our own build scripts
|
|
|
|
# prepared everything already to look like a regular Linux
|
|
|
|
# build
|
|
|
|
'arm-linux-androideabi': 'linux-generic32',
|
|
|
|
'aarch64-linux-android': 'linux-aarch64',
|
|
|
|
'i686-linux-android': 'linux-x86-clang',
|
|
|
|
'x86_64-linux-android': 'linux-x86_64-clang',
|
|
|
|
|
|
|
|
# Kobo
|
|
|
|
'arm-linux-gnueabihf': 'linux-generic32',
|
|
|
|
|
|
|
|
# Windows
|
|
|
|
'i686-w64-mingw32': 'mingw',
|
|
|
|
'x86_64-w64-mingw32': 'mingw64',
|
|
|
|
}
|
|
|
|
|
|
|
|
openssl_arch = openssl_archs[toolchain.arch]
|
|
|
|
|
|
|
|
subprocess.check_call(['./Configure',
|
|
|
|
'no-shared',
|
|
|
|
'no-module', 'no-engine', 'no-static-engine',
|
|
|
|
'no-async',
|
|
|
|
'no-tests',
|
|
|
|
'no-asm', # "asm" causes build failures on Windows
|
|
|
|
openssl_arch,
|
|
|
|
'--prefix=' + toolchain.install_prefix],
|
|
|
|
cwd=src, env=toolchain.env)
|
2021-08-28 22:38:02 +02:00
|
|
|
self.build_make(toolchain, src)
|