-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ffi: add script to build xcframework
We need to use a custom target spec for the iOS simulator. More details: rust-lang/rust#79408 Since that issue, all the targets except the x86_64 simulator have been updated (one landed last night). There is a PR that updates the simulator: rust-lang/rust#87699 Once that PR is merged we can remove the `x86_64-apple-ios7.0.json` custom target spec and use the builtin.
- Loading branch information
Showing
5 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
libs/ | ||
out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ authors = ["David Cowden <[email protected]>"] | |
license = "AGPL-3.0-only" | ||
edition = "2018" | ||
|
||
[lib] | ||
name = "uno" | ||
crate-type = ["staticlib"] | ||
|
||
[dependencies] | ||
uno = "0.1" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
|
||
# libuno-*.a | ||
rm libs/* | ||
|
||
# Uno.xcframework | ||
rm out/* | ||
|
||
rmdir libs out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
: "${LIBNAME:=libuno}" | ||
: "${OUTNAME:=Uno}" | ||
: "${TOOLCHAIN:=nightly}" | ||
: "${PROFILE:=release}" | ||
: "${PROFDIR:=$PROFILE}" | ||
|
||
# | ||
# Build an archs table because the triple arch is not the same as lipo arch. | ||
# | ||
ARCHS=" | ||
aarch64 | ||
x86_64 | ||
" | ||
subarchs=$(mktemp -d) | ||
echo "arm64v8" > $subarchs/aarch64 | ||
echo "x86_64" > $subarchs/x86_64 | ||
|
||
mkdir -p libs | ||
|
||
# | ||
# Build macOS. | ||
# | ||
lipo_args="" | ||
|
||
for ARCH in $ARCHS | ||
do | ||
TRIPLE="$ARCH-apple-darwin" | ||
cargo +$TOOLCHAIN build \ | ||
-Z unstable-options --profile $PROFILE \ | ||
-Z build-std \ | ||
--target $TRIPLE | ||
|
||
larch=$(< $subarchs/$ARCH) | ||
lipo_args="$lipo_args | ||
-arch $larch ../target/$TRIPLE/$PROFDIR/$LIBNAME.a" | ||
done | ||
|
||
lipo -create $lipo_args -output libs/$LIBNAME-macos.a | ||
|
||
xc_args="$xc_args | ||
-library libs/$LIBNAME-macos.a" | ||
xc_args="$xc_args | ||
-headers include" | ||
|
||
|
||
# | ||
# Build iOS. | ||
# | ||
cargo +$TOOLCHAIN build \ | ||
-Z unstable-options --profile $PROFILE \ | ||
-Z build-std \ | ||
--target aarch64-apple-ios | ||
|
||
cp ../target/aarch64-apple-ios/$PROFDIR/$LIBNAME.a libs/$LIBNAME-ios.a | ||
|
||
xc_args="$xc_args | ||
-library libs/$LIBNAME-ios.a" | ||
xc_args="$xc_args | ||
-headers include" | ||
|
||
|
||
# | ||
# Build ios simulator. | ||
# | ||
cargo +$TOOLCHAIN build \ | ||
-Z unstable-options --profile $PROFILE \ | ||
-Z build-std \ | ||
--target aarch64-apple-ios-sim | ||
|
||
lipo_args=" | ||
-arch arm64v8 ../target/aarch64-apple-ios-sim/$PROFDIR/$LIBNAME.a" | ||
|
||
# | ||
# The simulator rustc target on x86_64 does not have the correct load_command. | ||
# Use a custom target with the correct one specified. Can be removed when: | ||
# | ||
# https://github.com/rust-lang/rust/pull/87699 | ||
# | ||
# is merged. | ||
# | ||
cargo +$TOOLCHAIN build \ | ||
-Z unstable-options --profile $PROFILE \ | ||
-Z build-std \ | ||
--target x86_64-apple-ios7.0.json | ||
|
||
lipo_args="$lipo_args | ||
-arch x86_64 ../target/x86_64-apple-ios7.0/$PROFDIR/$LIBNAME.a" | ||
|
||
lipo -create $lipo_args -output libs/$LIBNAME-ios-sim.a | ||
|
||
xc_args="$xc_args | ||
-library libs/$LIBNAME-ios-sim.a" | ||
xc_args="$xc_args | ||
-headers include" | ||
|
||
|
||
# | ||
# Build mac catalyst. | ||
# | ||
lipo_args="" | ||
for ARCH in $ARCHS | ||
do | ||
TRIPLE="$ARCH-apple-ios-macabi" | ||
cargo +$TOOLCHAIN build \ | ||
-Z unstable-options --profile $PROFILE \ | ||
-Z build-std \ | ||
--target $TRIPLE | ||
|
||
larch=$(< $subarchs/$ARCH) | ||
lipo_args="$lipo_args | ||
-arch $larch ../target/$TRIPLE/$PROFDIR/$LIBNAME.a" | ||
done | ||
|
||
lipo -create $lipo_args -output libs/$LIBNAME-ios-macabi.a | ||
|
||
xc_args="$xc_args | ||
-library libs/$LIBNAME-ios-macabi.a" | ||
xc_args="$xc_args | ||
-headers include" | ||
|
||
|
||
# | ||
# Build the sumo xcframework. | ||
# | ||
mkdir -p out | ||
xcodebuild -create-xcframework $xc_args -output out/$OUTNAME.xcframework | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"abi-return-struct-as-int": true, | ||
"arch": "x86_64", | ||
"archive-format": "darwin", | ||
"cpu": "core2", | ||
"data-layout": "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", | ||
"dll-suffix": ".dylib", | ||
"dwarf-version": 2, | ||
"eh-frame-header": false, | ||
"emit-debug-gdb-scripts": false, | ||
"executables": true, | ||
"frame-pointer": "always", | ||
"function-sections": false, | ||
"has-rpath": true, | ||
"is-builtin": false, | ||
"is-like-osx": true, | ||
"link-env": [ | ||
"ZERO_AR_DATE=1" | ||
], | ||
"link-env-remove": [ | ||
"MACOSX_DEPLOYMENT_TARGET" | ||
], | ||
"linker-is-gnu": false, | ||
"llvm-target": "x86_64-apple-ios7.0", | ||
"max-atomic-width": 64, | ||
"os": "ios", | ||
"split-debuginfo": "packed", | ||
"stack-probes": { | ||
"kind": "call" | ||
}, | ||
"target-family": [ | ||
"unix" | ||
], | ||
"target-pointer-width": "64", | ||
"vendor": "apple" | ||
} |