feat(voice): add iOS VAD runtime support
This commit is contained in:
@@ -40,7 +40,7 @@ Pod::Spec.new do |s|
|
||||
s.license = { :type => 'Apache-2.0 OR MIT', :text => 'See LICENSE-APACHE / LICENSE-MIT at the repo root' }
|
||||
s.author = { 'EdisonJwa' => 'me@edison.network' }
|
||||
s.source = { :path => '.' }
|
||||
s.platform = :ios, '13.0'
|
||||
s.platform = :ios, '15.1'
|
||||
|
||||
# Build the Rust bridge on `pod install`. The script runs under
|
||||
# bash; we use `set -e` so any failure (cargo missing, target not
|
||||
@@ -51,15 +51,59 @@ Pod::Spec.new do |s|
|
||||
s.prepare_command = <<-SCRIPT
|
||||
set -e
|
||||
REPO_ROOT="$(cd ../../.. && pwd)"
|
||||
USER_NAME="$(id -un)"
|
||||
USER_HOME="$(dscl . -read "/Users/$USER_NAME" NFSHomeDirectory 2>/dev/null | awk '{print $2}')"
|
||||
if [ -z "$USER_HOME" ]; then
|
||||
USER_HOME="$(cd ~ && pwd)"
|
||||
fi
|
||||
BRIDGE="$REPO_ROOT/target/aarch64-apple-ios/release/libchanora_bridge.dylib"
|
||||
find_cargo() {
|
||||
for candidate in \
|
||||
"$USER_HOME/.cargo/bin/cargo" \
|
||||
"/opt/homebrew/opt/rustup/bin/cargo" \
|
||||
"/usr/local/opt/rustup/bin/cargo"
|
||||
do
|
||||
if [ -x "$candidate" ]; then
|
||||
echo "$candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
command -v cargo
|
||||
}
|
||||
find_rustc() {
|
||||
for candidate in \
|
||||
"$USER_HOME/.cargo/bin/rustc" \
|
||||
"/opt/homebrew/opt/rustup/bin/rustc" \
|
||||
"/usr/local/opt/rustup/bin/rustc"
|
||||
do
|
||||
if [ -x "$candidate" ]; then
|
||||
echo "$candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
command -v rustc
|
||||
}
|
||||
CARGO_BIN="$(find_cargo)"
|
||||
RUSTC_BIN="$(find_rustc)"
|
||||
ORT_FRAMEWORK="$REPO_ROOT/apps/chanora_flutter/ios/Pods/onnxruntime-c/onnxruntime.xcframework/ios-arm64/onnxruntime.framework"
|
||||
ORT_LINK_DIR="$REPO_ROOT/target/onnxruntime-ios-device"
|
||||
if [ -f "$ORT_FRAMEWORK/onnxruntime" ]; then
|
||||
mkdir -p "$ORT_LINK_DIR"
|
||||
lipo "$ORT_FRAMEWORK/onnxruntime" -thin arm64 -output "$ORT_LINK_DIR/libonnxruntime.a"
|
||||
fi
|
||||
|
||||
echo "[chanora_bridge.podspec] cargo build aarch64-apple-ios"
|
||||
cd "$REPO_ROOT"
|
||||
PATH="$HOME/.cargo/bin:$PATH" \\
|
||||
IPHONEOS_DEPLOYMENT_TARGET=13.0 \\
|
||||
HOME="$USER_HOME" \\
|
||||
CARGO_HOME="$USER_HOME/.cargo" \\
|
||||
RUSTUP_HOME="$USER_HOME/.rustup" \\
|
||||
RUSTUP_TOOLCHAIN="stable-aarch64-apple-darwin" \\
|
||||
RUSTC="$RUSTC_BIN" \\
|
||||
ORT_LIB_LOCATION="$ORT_LINK_DIR" \\
|
||||
IPHONEOS_DEPLOYMENT_TARGET=15.1 \\
|
||||
CMAKE_POLICY_VERSION_MINIMUM=3.5 \\
|
||||
CMAKE_OSX_DEPLOYMENT_TARGET=13.0 \\
|
||||
cargo build --release --target aarch64-apple-ios -p chanora_bridge
|
||||
CMAKE_OSX_DEPLOYMENT_TARGET=15.1 \\
|
||||
"$CARGO_BIN" build --release --target aarch64-apple-ios -p chanora_bridge
|
||||
|
||||
if [ ! -f "$BRIDGE" ]; then
|
||||
echo "ERROR: bridge dylib not found at $BRIDGE" >&2
|
||||
@@ -86,7 +130,7 @@ Pod::Spec.new do |s|
|
||||
<key>CFBundleShortVersionString</key><string>1.0.0</string>
|
||||
<key>CFBundleVersion</key><string>1</string>
|
||||
<key>CFBundleSupportedPlatforms</key><array><string>iPhoneOS</string></array>
|
||||
<key>MinimumOSVersion</key><string>13.0</string>
|
||||
<key>MinimumOSVersion</key><string>15.1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
@@ -116,15 +160,70 @@ PLIST
|
||||
:script => <<-SCRIPT,
|
||||
set -e
|
||||
REPO_ROOT="$(cd "${PODS_TARGET_SRCROOT}/../../.." && pwd)"
|
||||
BRIDGE="$REPO_ROOT/target/aarch64-apple-ios/release/libchanora_bridge.dylib"
|
||||
USER_NAME="$(id -un)"
|
||||
USER_HOME="$(dscl . -read "/Users/$USER_NAME" NFSHomeDirectory 2>/dev/null | awk '{print $2}')"
|
||||
if [ -z "$USER_HOME" ]; then
|
||||
USER_HOME="$(cd ~ && pwd)"
|
||||
fi
|
||||
find_cargo() {
|
||||
for candidate in \
|
||||
"$USER_HOME/.cargo/bin/cargo" \
|
||||
"/opt/homebrew/opt/rustup/bin/cargo" \
|
||||
"/usr/local/opt/rustup/bin/cargo"
|
||||
do
|
||||
if [ -x "$candidate" ]; then
|
||||
echo "$candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
command -v cargo
|
||||
}
|
||||
find_rustc() {
|
||||
for candidate in \
|
||||
"$USER_HOME/.cargo/bin/rustc" \
|
||||
"/opt/homebrew/opt/rustup/bin/rustc" \
|
||||
"/usr/local/opt/rustup/bin/rustc"
|
||||
do
|
||||
if [ -x "$candidate" ]; then
|
||||
echo "$candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
command -v rustc
|
||||
}
|
||||
CARGO_BIN="$(find_cargo)"
|
||||
RUSTC_BIN="$(find_rustc)"
|
||||
if [ "${PLATFORM_NAME:-iphoneos}" = "iphonesimulator" ]; then
|
||||
RUST_TARGET="aarch64-apple-ios-sim"
|
||||
SUPPORTED_PLATFORM="iPhoneSimulator"
|
||||
ORT_SLICE="ios-arm64_x86_64-simulator"
|
||||
else
|
||||
RUST_TARGET="aarch64-apple-ios"
|
||||
SUPPORTED_PLATFORM="iPhoneOS"
|
||||
ORT_SLICE="ios-arm64"
|
||||
fi
|
||||
BRIDGE="$REPO_ROOT/target/$RUST_TARGET/release/libchanora_bridge.dylib"
|
||||
ORT_FRAMEWORK="$REPO_ROOT/apps/chanora_flutter/ios/Pods/onnxruntime-c/onnxruntime.xcframework/$ORT_SLICE/onnxruntime.framework"
|
||||
ORT_LINK_DIR="$REPO_ROOT/target/onnxruntime-$RUST_TARGET"
|
||||
if [ ! -f "$ORT_FRAMEWORK/onnxruntime" ]; then
|
||||
echo "ERROR: ONNX Runtime framework not found at $ORT_FRAMEWORK" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$ORT_LINK_DIR"
|
||||
lipo "$ORT_FRAMEWORK/onnxruntime" -thin arm64 -output "$ORT_LINK_DIR/libonnxruntime.a"
|
||||
|
||||
echo "[chanora_bridge script_phase] cargo build aarch64-apple-ios"
|
||||
echo "[chanora_bridge script_phase] cargo build $RUST_TARGET"
|
||||
cd "$REPO_ROOT"
|
||||
PATH="$HOME/.cargo/bin:$PATH" \\
|
||||
IPHONEOS_DEPLOYMENT_TARGET=13.0 \\
|
||||
HOME="$USER_HOME" \\
|
||||
CARGO_HOME="$USER_HOME/.cargo" \\
|
||||
RUSTUP_HOME="$USER_HOME/.rustup" \\
|
||||
RUSTUP_TOOLCHAIN="stable-aarch64-apple-darwin" \\
|
||||
RUSTC="$RUSTC_BIN" \\
|
||||
ORT_LIB_LOCATION="$ORT_LINK_DIR" \\
|
||||
IPHONEOS_DEPLOYMENT_TARGET=15.1 \\
|
||||
CMAKE_POLICY_VERSION_MINIMUM=3.5 \\
|
||||
CMAKE_OSX_DEPLOYMENT_TARGET=13.0 \\
|
||||
cargo build --release --target aarch64-apple-ios -p chanora_bridge
|
||||
CMAKE_OSX_DEPLOYMENT_TARGET=15.1 \\
|
||||
"$CARGO_BIN" build --release --target "$RUST_TARGET" -p chanora_bridge
|
||||
|
||||
cd "$REPO_ROOT/apps/chanora_flutter/ios"
|
||||
FW=Frameworks/chanora_bridge.framework
|
||||
@@ -139,6 +238,22 @@ PLIST
|
||||
|
||||
mkdir -p "$FW"
|
||||
cp "$BRIDGE" "$FW/chanora_bridge"
|
||||
cat > "$FW/Info.plist" <<PLIST
|
||||
<?xml version="1.0" encoding="UTF-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>CFBundleExecutable</key><string>chanora_bridge</string>
|
||||
<key>CFBundleIdentifier</key><string>app.chanora.bridge</string>
|
||||
<key>CFBundleName</key><string>chanora_bridge</string>
|
||||
<key>CFBundlePackageType</key><string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key><string>1.0.0</string>
|
||||
<key>CFBundleVersion</key><string>1</string>
|
||||
<key>CFBundleSupportedPlatforms</key><array><string>$SUPPORTED_PLATFORM</string></array>
|
||||
<key>MinimumOSVersion</key><string>15.1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
install_name_tool -id "@rpath/chanora_bridge.framework/chanora_bridge" \\
|
||||
"$FW/chanora_bridge"
|
||||
echo "[chanora_bridge script_phase] framework refreshed"
|
||||
|
||||
Reference in New Issue
Block a user