oficina / meet Public

Clone
git clone https://amadan.net/oficina/meet

Plain git — no account needed to clone.

Download

Download this file

1#!/bin/sh
2# Builds native/build/DeepFilter.xcframework and copies the DeepFilterNet 3
3# model beside it: Rikorose/DeepFilterNet's libDF (MIT or Apache-2.0) with
4# its C API, as a static library for Mac, iPhone and the iPhone simulator
5# (Apple silicon).
6#
7# Built rather than committed, as CallsBridge and RNNoise are. Needs rustup
8# (https://rustup.rs); the toolchain, its targets and cbindgen are pinned
9# and installed on first run.
10set -eu
11cd "$(dirname "$0")/.."
12
13commit=d375b2d8309e0935d165700c91da9de862a99c31
14toolchain=1.92.0
15cbindgen_version=0.29.2
16out=build/DeepFilter.xcframework
17model=build/DeepFilterNet3_onnx.tar.gz
18stamp="$out/.built-$commit-$toolchain"
19if [ -f "$stamp" ] && [ -f "$model" ]; then exit 0; fi
20
21PATH="$HOME/.cargo/bin:$PATH"
22command -v rustup >/dev/null || {
23 echo "build-deepfilter: rustup is required (https://rustup.rs)" >&2
24 exit 1
25}
26targets="aarch64-apple-darwin aarch64-apple-ios aarch64-apple-ios-sim"
27# shellcheck disable=SC2086
28rustup toolchain install "$toolchain" --profile minimal $(printf ' -t %s' $targets) >/dev/null
29if [ "$(cbindgen --version 2>/dev/null)" != "cbindgen $cbindgen_version" ]; then
30 cargo "+$toolchain" install cbindgen --version "$cbindgen_version" --locked
31fi
32
33work=build/deepfilter
34mkdir -p "$work"
35if [ ! -d "$work/src/.git" ]; then
36 rm -rf "$work/src"
37 git clone --quiet https://github.com/Rikorose/DeepFilterNet.git "$work/src"
38fi
39git -C "$work/src" -c advice.detachedHead=false checkout --quiet --force "$commit"
40
41# Deployment targets matching the apps, so the linker does not warn that
42# the library was built for newer systems than they run on.
43export MACOSX_DEPLOYMENT_TARGET=14.0 IPHONEOS_DEPLOYMENT_TARGET=17.0
44for target in $targets; do
45 cargo "+$toolchain" build --manifest-path "$work/src/Cargo.toml" -p deep_filter --lib \
46 --release --features capi --target "$target" --target-dir "$work/target"
47done
48
49headers="$work/headers"
50rm -rf "$headers"
51mkdir -p "$headers/DeepFilter"
52cbindgen --config "$work/src/cbindgen.toml" --crate deep_filter \
53 --output "$headers/DeepFilter/deep_filter.h" "$work/src/libDF"
54cat >"$headers/DeepFilter/module.modulemap" <<'EOF'
55module DeepFilter {
56 header "deep_filter.h"
57 link "df"
58 export *
59}
60EOF
61
62rm -rf "$out"
63xcodebuild -create-xcframework \
64 -library "$work/target/aarch64-apple-darwin/release/libdf.a" -headers "$headers" \
65 -library "$work/target/aarch64-apple-ios/release/libdf.a" -headers "$headers" \
66 -library "$work/target/aarch64-apple-ios-sim/release/libdf.a" -headers "$headers" \
67 -output "$out" >/dev/null
68cp "$work/src/models/DeepFilterNet3_onnx.tar.gz" "$model"
69cp "$work/src/LICENSE-MIT" "$out/LICENSE-MIT"
70touch "$stamp"
71printf 'Built %s/%s\n' "$PWD" "$out"
72