Add Swift module for libburrow

This commit also renames the app target to App.
This commit is contained in:
Conrad Kramer 2023-05-08 18:14:21 -04:00
parent 5e265632a3
commit eeb0130156
12 changed files with 57 additions and 36 deletions

View file

@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>$(INFOPLIST_KEY_CFBundleDisplayName)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>

View file

@ -1,8 +1,11 @@
#include "../Configuration/Extension.xcconfig"
PRODUCT_NAME = BurrowNetworkExtension
PRODUCT_BUNDLE_IDENTIFIER = $(APP_BUNDLE_IDENTIFIER).network
PRODUCT_BUNDLE_IDENTIFIER = $(NETWORK_EXTENSION_BUNDLE_IDENTIFIER)
INFOPLIST_FILE = NetworkExtension/Info.plist
CODE_SIGN_ENTITLEMENTS = NetworkExtension/NetworkExtension-iOS.entitlements
CODE_SIGN_ENTITLEMENTS[sdk=macos*] = NetworkExtension/NetworkExtension-macOS.entitlements
SWIFT_INCLUDE_PATHS = $(inherited) $(PROJECT_DIR)/NetworkExtension

View file

@ -0,0 +1,69 @@
#!/bin/bash
export PATH="${PATH}:${HOME}/.cargo/bin:/opt/homebrew/bin:/usr/local/bin:/etc/profiles/per-user/${USER}/bin"
if ! [[ -x "$(command -v cargo)" ]]; then
echo 'error: Unable to find cargo'
exit 127
fi
set -e
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"/../../../burrow
RUST_TARGETS=()
IFS=' ' read -a BURROW_ARCHS <<< "${ARCHS[@]}"
for ARCH in "${BURROW_ARCHS[@]}"; do
case $PLATFORM_NAME in
iphonesimulator)
case $ARCH in
arm64) RUST_TARGETS+=("aarch64-apple-ios-sim") ;;
x86_64) RUST_TARGETS+=("x86_64-apple-ios") ;;
*) echo "error: Unknown $PLATFORM_NAME arch, $ARCH"; exit 1 ;;
esac
;;
iphoneos)
case $ARCH in
arm64) RUST_TARGETS+=("aarch64-apple-ios") ;;
*) echo "error: Unknown $PLATFORM_NAME arch, $ARCH"; exit 1 ;;
esac
;;
macos*)
case $ARCH in
arm64) RUST_TARGETS+=("aarch64-apple-darwin") ;;
x86_64) RUST_TARGETS+=("x86_64-apple-darwin") ;;
*) echo "error: Unknown $PLATFORM_NAME arch, $ARCH"; exit 1 ;;
esac
;;
*) echo "error: Unsupported platform $PLATFORM_NAME"; exit 1 ;;
esac
done
CARGO_ARGS=()
for TARGET in "${RUST_TARGETS[@]}"; do
CARGO_ARGS+=("--target")
CARGO_ARGS+=("$TARGET")
done
CARGO_ARGS+=("--lib")
if [[ $SWIFT_ACTIVE_COMPILATION_CONDITIONS == *DEBUG* ]]; then
CARGO_DIR="debug"
else
CARGO_ARGS+=("--release")
CARGO_DIR="release"
fi
if [[ -x "$(command -v rustup)" ]]; then
CARGO_PATH="$(dirname $(rustup which cargo)):/usr/bin"
else
CARGO_PATH="$(dirname $(readlink -f $(which cargo))):/usr/bin"
fi
env -i PATH="$CARGO_PATH" cargo build "${CARGO_ARGS[@]}"
mkdir -p "${BUILT_PRODUCTS_DIR}"
/usr/bin/xcrun --sdk $PLATFORM_NAME lipo \
-create $(printf "${PROJECT_DIR}/../target/%q/${CARGO_DIR}/libburrow.a " "${RUST_TARGETS[@]}") \
-output "${BUILT_PRODUCTS_DIR}/libburrow.a"

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,4 @@
module libburrow {
header "libburrow.h"
export *
}