diff --git a/patches/openssl.patch b/patches/openssl.patch deleted file mode 100644 index 5c7cee3..0000000 --- a/patches/openssl.patch +++ /dev/null @@ -1,32 +0,0 @@ -diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf -index 7e9396868a..db6383f8ec 100644 ---- a/Configurations/10-main.conf -+++ b/Configurations/10-main.conf -@@ -908,6 +908,14 @@ my %targets = ( - perlasm_scheme => "elf32", - multilib => "x32", - }, -+ "ohos-aarch64" => { -+ inherit_from => [ "linux-aarch64" ], -+ shared_extension => ".so" -+ }, -+ "ohos-x86_64" => { -+ inherit_from => [ "linux-x86_64" ], -+ shared_extension => ".so" -+ }, - - "linux-ia64" => { - inherit_from => [ "linux-generic64" ], -diff --git a/crypto/build.info b/crypto/build.info -index 872684cd7a..f006858178 100644 ---- a/crypto/build.info -+++ b/crypto/build.info -@@ -115,7 +115,7 @@ DEFINE[../libcrypto]=$UPLINKDEF - - DEPEND[info.o]=buildinf.h - DEPEND[cversion.o]=buildinf.h --GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)" -+GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)" - - GENERATE[uplink-x86.S]=../ms/uplink-x86.pl - GENERATE[uplink-x86_64.s]=../ms/uplink-x86_64.pl diff --git a/scripts/common.py b/scripts/common.py index 1758792..c0af865 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -141,6 +141,8 @@ def get_platform_cflags() -> str: sdk = f'-isysroot {subprocess.check_output("xcrun --sdk iphonesimulator --show-sdk-path", shell=True, text=True).strip()}' version = f'-mios-simulator-version-min={IOS_VERSION}' return ' '.join((arch, sdk, version)) + if PLATFORM == 'harmony': + return f'-O3 -fPIC --target={OHOS_TARGET}' if PLATFORM == 'js': flag = '-fPIC' if not DEBUG: @@ -376,13 +378,25 @@ def configure(self): ]) def build(self): - ensure('make', [ + command = [ '-j8', self.target, f'CFLAGS="{get_platform_cflags()}"', f'CXXFLAGS="{get_platform_cflags()}"' - ]) + ] + if PLATFORM == 'harmony': + # Use environment variable so that libcrypto-lib-cversion.o in openssl doesn't contain absolute path of clang. + os.environ['PATH'] = f'{HARMONY_NATIVE}/llvm/bin:{os.environ['PATH']}' + command += [ + 'CC=clang', + 'AR=llvm-ar', + 'RANLIB=llvm-ranlib' + ] + ensure('make', command) def install(self): os.environ['DESTDIR'] = self.dest_dir - ensure('make', ['install']) + ensure('make', [ + 'install', + f'DESTDIR={self.dest_dir}', # openssl doesn't accept environment variable. + ]) diff --git a/scripts/openssl.py b/scripts/openssl.py index a1ad817..3b91573 100644 --- a/scripts/openssl.py +++ b/scripts/openssl.py @@ -1,15 +1,11 @@ import os -from common import HARMONY_NATIVE, INSTALL_PREFIX, OHOS_ARCH, OHOS_TARGET, PLATFORM, Builder, ensure, patch - -project = 'openssl' - -patch(project) +from common import INSTALL_PREFIX, OHOS_ARCH, MakeBuilder, ensure os.environ['SOURCE_DATE_EPOCH'] = '0' # Reproducible: crypto/buildinf.h -class OpenSSLBuilder(Builder): +class OpenSSLBuilder(MakeBuilder): def configure(self): - arch = 'ohos-aarch64' if OHOS_ARCH == 'arm64-v8a' else 'ohos-x86_64' + arch = 'linux-aarch64' if OHOS_ARCH == 'arm64-v8a' else 'linux-x86_64' ensure('./Configure', [ arch, f'--prefix={INSTALL_PREFIX}', @@ -21,36 +17,10 @@ def configure(self): *self.options ]) - def build(self): - ensure('make', ['clean']) - command = [] - - cflags = ['-O3', '-fPIC'] - if PLATFORM == 'harmony': - cflags += [f'--target={OHOS_TARGET}'] - - command += [ - 'make', - '-j8', - f'CFLAGS="{' '.join(cflags)}"' - ] - - if PLATFORM == 'harmony': - command += [ - f'CC={HARMONY_NATIVE}/llvm/bin/clang', - f'AR="{HARMONY_NATIVE}/llvm/bin/llvm-ar"', - f'RANLIB={HARMONY_NATIVE}/llvm/bin/llvm-ranlib' - ] - - ensure(command[0], command[1:]) - - def install(self): - ensure('make', ['install', f'DESTDIR={self.dest_dir}']) - def pre_package(self): ensure('rm', ['-rf', f'{self.dest_dir}{INSTALL_PREFIX}/bin', f'{self.dest_dir}{INSTALL_PREFIX}/ssl' ]) -OpenSSLBuilder(project).exec() +OpenSSLBuilder('openssl').exec()