Skip to content

Commit

Permalink
Build openssl universal binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusTomlinson committed Jul 3, 2022
1 parent 11de63e commit 7bf2e37
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 13 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ jobs:
- if: matrix.os == 'macos-11'
name: Build - Release (MacOS)
run: |
cd openssl
meson setup builddir --buildtype=release
meson compile -C builddir
cd ..
bash openssl/build-universal.sh
mkdir -p builddir
cd builddir
cp -r ../openssl/subprojects/openssl-3.0.2/generated-config/archs/darwin64-arm64-cc/asm/include ../openssl/subprojects/openssl-3.0.2
cp -r ../openssl/subprojects/openssl-3.0.2/generated-config/archs/darwin64-x86_64-cc/asm/include ../openssl/subprojects/openssl-3.0.2
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=bundle -DENABLE_CRYPTO=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
cmake --build . --config Release -- -j8
Expand Down
18 changes: 9 additions & 9 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
"windows": {
"command": [
"cd openssl;",
"meson setup builddir --buildtype=release -Dmt=enabled;",
"meson setup builddir --buildtype=release -Dmt=disabled;",
"meson compile -C builddir;",
"cd ..;",
"mkdir -force builddir;",
"cd builddir;",
"cp -r -force ../openssl/subprojects/openssl-3.0.2/generated-config/archs/VC-WIN64A/no-asm/include ../openssl/subprojects/openssl-3.0.2;",
"cmake .. -DCMAKE_INSTALL_PREFIX=bundle -DENABLE_CRYPTO=ON -DBUILD_SHARED_LIBS=OFF -DPOCO_MT=ON;",
"cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=bundle -DENABLE_CRYPTO=ON -DBUILD_SHARED_LIBS=OFF -DPOCO_MT=OFF -DCMAKE_CXX_FLAGS=\"-DPOCO_NO_AUTOMATIC_LIBS -DPOCO_STATIC\";",
"cmake --build . --config Release;",
"cmake --build . --target install"
"cmake --build . --target install;",
"python3 ../scripts/bundle.py win release_md done"
],
"problemMatcher": {
"base": "$msCompile",
Expand All @@ -31,16 +32,15 @@
},
"osx": {
"command": [
"cd openssl &&",
"meson setup builddir --buildtype=release &&",
"meson compile -C builddir &&",
"cd .. &&",
"bash openssl/build-universal.sh &&",
"mkdir -p builddir &&",
"cd builddir &&",
"cp -r ../openssl/subprojects/openssl-3.0.2/generated-config/archs/darwin64-arm64-cc/asm/include ../openssl/subprojects/openssl-3.0.2 &&",
"cp -r ../openssl/subprojects/openssl-3.0.2/generated-config/archs/darwin64-x86_64-cc/asm/include ../openssl/subprojects/openssl-3.0.2 &&",
"cmake .. -DCMAKE_INSTALL_PREFIX=bundle -DENABLE_CRYPTO=ON -DBUILD_SHARED_LIBS=OFF &&",
"cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=bundle -DENABLE_CRYPTO=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES=\"arm64;x86_64\" &&",
"cmake --build . --config Release -- -j8 &&",
"cmake --build . --target install"
"cmake --build . --target install &&",
"python3 ../scripts/bundle.py mac release done"
],
"problemMatcher": {
"base": "$gcc",
Expand Down
9 changes: 9 additions & 0 deletions openssl/arm-build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[host_machine]
system = 'darwin'
cpu_family = 'aarch64'
cpu = 'arm64'
endian = 'little'

[binaries]
c = 'clang'
strip = 'strip'
52 changes: 52 additions & 0 deletions openssl/build-universal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

DIR=$(cd `dirname $0` && pwd)
cd $DIR

meson setup arm-build --buildtype=release --cross-file=arm-build.txt
meson compile -C arm-build

meson setup x64-build --buildtype=release --cross-file=x64-build.txt
meson compile -C x64-build

mkdir -p builddir/subprojects/openssl-3.0.2/libcrypto.a.p
mkdir -p builddir/subprojects/openssl-3.0.2/libssl.a.p

lipo -create -output builddir/subprojects/openssl-3.0.2/libcrypto.a arm-build/subprojects/openssl-3.0.2/libcrypto.a x64-build/subprojects/openssl-3.0.2/libcrypto.a
lipo -create -output builddir/subprojects/openssl-3.0.2/libssl.a arm-build/subprojects/openssl-3.0.2/libssl.a x64-build/subprojects/openssl-3.0.2/libssl.a

cd arm-build

for filename in subprojects/openssl-3.0.2/libcrypto.a.p/*.o; do
if [ -f "../x64-build/$filename" ]
then
lipo -create -output ../builddir/$filename ../x64-build/$filename $filename
else
cp $filename ../builddir/$filename
fi
done

for filename in subprojects/openssl-3.0.2/libssl.a.p/*.o; do
if [ -f "../x64-build/$filename" ]
then
lipo -create -output ../builddir/$filename ../x64-build/$filename $filename
else
cp $filename ../builddir/$filename
fi
done

cd ../x64-build

for filename in subprojects/openssl-3.0.2/libcrypto.a.p/*.o; do
if [ ! -f "../arm-build/$filename" ]
then
cp $filename ../builddir/$filename
fi
done

for filename in subprojects/openssl-3.0.2/libssl.a.p/*.o; do
if [ ! -f "../arm-build/$filename" ]
then
cp $filename ../builddir/$filename
fi
done
9 changes: 9 additions & 0 deletions openssl/x64-build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[host_machine]
system = 'darwin'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

[binaries]
c = 'clang'
strip = 'strip'

0 comments on commit 7bf2e37

Please sign in to comment.