Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Try iphonesimulator build in CI (#8)
Browse files Browse the repository at this point in the history
* Try iphonesimulator build in CI

* Finally figure out include, library, and framework search paths

* Add debugging

* Fix typo

* Add sim target

* Add it to the right target
  • Loading branch information
jamilbk committed Apr 21, 2023
1 parent b5234ab commit c573e2e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ jobs:
rustup update --no-self-update ${{ matrix.rust }} \
&& rustup default ${{ matrix.rust }} \
&& rustup component add clippy \
&& rustup target add aarch64-apple-ios aarch64-apple-darwin x86_64-apple-ios x86_64-apple-darwin \
&& rustup target add aarch64-apple-ios-sim aarch64-apple-ios aarch64-apple-darwin x86_64-apple-ios x86_64-apple-darwin \
&& cargo install cargo-lipo
- uses: actions/cache@v3
Expand Down
3 changes: 1 addition & 2 deletions apple/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 26 additions & 15 deletions apple/build-rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,53 @@
# We call this from an Xcode run script.
##################################################

set -e
set -ex

if [[ -z "$PROJECT_DIR" ]]; then
echo "Must provide PROJECT_DIR environment variable set to the Xcode project directory." 1>&2
exit 1
echo "Must provide PROJECT_DIR environment variable set to the Xcode project directory." 1>&2
exit 1
fi

cd $PROJECT_DIR

# Default PLATFORM_NAME to macosx if not set.
: "${PLATFORM_NAME:=macosx}"


export PATH="$HOME/.cargo/bin:$PATH"

# Without this we can't compile on MacOS Big Sur
# https://github.com/TimNN/cargo-lipo/issues/41#issuecomment-774793892
if [[ -n "${DEVELOPER_SDK_DIR:-}" ]]; then
export LIBRARY_PATH="${DEVELOPER_SDK_DIR}/MacOSX.sdk/usr/lib:${LIBRARY_PATH:-}"
fi
base_dir=$(xcrun --sdk $PLATFORM_NAME --show-sdk-path)

# See https://github.com/briansmith/ring/issues/1332
export LIBRARY_PATH="${base_dir}/usr/lib"
export INCLUDE_PATH="${base_dir}/usr/include"
export CFLAGS="-L ${LIBRARY_PATH} -I ${INCLUDE_PATH}"
export RUSTFLAGS="-C link-arg=-F$base_dir/System/Library/Frameworks"

TARGETS=""
if [[ "$PLATFORM_NAME" = "iphonesimulator" ]]; then
TARGETS="aarch64-apple-ios-sim,x86_64-apple-ios-sim"
if [[ "$PLATFORM_NAME" = "macosx" ]]; then
TARGETS="aarch64-apple-darwin,x86_64-apple-darwin"
else
if [[ "$PLATFORM_NAME" = "iphoneos" ]]; then
TARGETS="aarch64-apple-ios"
if [[ "$PLATFORM_NAME" = "iphonesimulator" ]]; then
TARGETS="aarch64-apple-ios-sim,x86_64-apple-ios"
else
TARGETS="aarch64-apple-darwin,x86_64-apple-darwin"
if [[ "$PLATFORM_NAME" = "iphoneos" ]]; then
TARGETS="aarch64-apple-ios"
else
echo "Unsupported platform: $PLATFORM_NAME"
exit 1
fi
fi
fi

# if [ $ENABLE_PREVIEWS == "NO" ]; then

if [[ $CONFIGURATION == "Release" ]]; then
echo "BUIlDING FOR RELEASE ($TARGETS)"
echo "BUILDING FOR RELEASE ($TARGETS)"

cargo lipo --release --manifest-path ./Cargo.toml --targets $TARGETS
else
echo "BUIlDING FOR DEBUG ($TARGETS)"
echo "BUILDING FOR DEBUG ($TARGETS)"

cargo lipo --manifest-path ./Cargo.toml --targets $TARGETS
fi
Expand Down
4 changes: 3 additions & 1 deletion apple/build-xcframework.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -ex

for sdk in iphoneos macosx; do
for sdk in macosx iphoneos iphonesimulator; do
echo "Building for $sdk"

xcodebuild archive \
Expand All @@ -15,11 +15,13 @@ done

xcodebuild -create-xcframework \
-framework ./connlib-iphoneos.xcarchive/Products/Library/Frameworks/connlib.framework \
-framework ./connlib-iphonesimulator.xcarchive/Products/Library/Frameworks/connlib.framework \
-framework ./connlib-macosx.xcarchive/Products/Library/Frameworks/connlib.framework \
-output ./Connlib.xcframework

echo "Build successful. Removing temporary archives"
rm -rf ./connlib-iphoneos.xcarchive
rm -rf ./connlib-iphonesimulator.xcarchive
rm -rf ./connlib-macosx.xcarchive

echo "Computing checksum"
Expand Down

0 comments on commit c573e2e

Please sign in to comment.