diff --git a/.cargo/config.toml b/.cargo/config.toml index 87bbd9a4a45..ffbb565144a 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,6 +4,15 @@ # would work, but that list is what scopes `just check` and `cargo semver-checks`. [alias] moq = ["run", "--bin", "moq", "--"] +# `cargo build-ffi` is the one definition of moq-ffi's default build, which every +# binding loads from the shared target directory: `openh264`, as releases ship +# it. Append a profile, `--target`, or `--lib`, never features. A cdylib's file +# name carries no feature hash, so a build with other features replaces +# `libmoq_ffi.so` under everyone reading it; such a build takes a target +# directory of its own (py, `sh/size/collect.sh`, `build.sh --no-default-features`) +# or a `--target` triple no default build uses (dart's `testing` build). +# Aliases resolve from the working directory, so run it inside the checkout. +build-ffi = ["build", "--locked", "--package", "moq-ffi", "--features", "openh264"] # Browser/WASM (moq-wasm). getrandom needs its wasm_js backend, and web-sys's # WebTransport bindings are behind the unstable cfg. diff --git a/.github/workflows/release-gate.yml b/.github/workflows/release-gate.yml index f8d91b7ef38..3e494948f33 100644 --- a/.github/workflows/release-gate.yml +++ b/.github/workflows/release-gate.yml @@ -88,6 +88,7 @@ jobs: # since a bumped dependency can change a re-exported type. api-diff: - "rs/**" + - ".cargo/config.toml" - "js/**" - "Cargo.toml" - "Cargo.lock" @@ -112,6 +113,7 @@ jobs: c: - "c/**" - "rs/moq-ffi/**" + - ".cargo/config.toml" - "sh/c/**" - "rs/moq-c/native-libs/**" - "cpp/moq/cmake/moq-ffi.cmake" @@ -121,6 +123,7 @@ jobs: - "cpp/moq/**" - "cpp/justfile" - "rs/moq-ffi/**" + - ".cargo/config.toml" - "sh/cpp/**" - "rs/moq-c/native-libs/**" - "doc/lib/cpp/**" @@ -146,6 +149,7 @@ jobs: # The Go client builds against the modules this script stages. - "sh/go/**" - "cpp/moq/**" + - ".cargo/config.toml" - ".github/workflows/interop.yml" moq-sh: - "infra/moq-sh/**" @@ -155,6 +159,7 @@ jobs: - "cpp/moq/**" - "sh/obs/**" - "rs/moq-ffi/**" + - ".cargo/config.toml" - "rs/moq-c/**" - "doc/lib/c/**" - "doc/lib/samples.sh" @@ -185,6 +190,7 @@ jobs: - "dart/moq_ffi/**" - "sh/dart/**" - "rs/moq-ffi/build.sh" + - ".cargo/config.toml" release-go-ffi: - ".github/workflows/release-go-ffi.yml" - ".github/workflows/release-ffi.yml" @@ -195,6 +201,7 @@ jobs: - "sh/go/package-ffi.sh" - "sh/go/publish-ffi.sh" - "rs/moq-ffi/build.sh" + - ".cargo/config.toml" release-js: - "js/**" - ".github/workflows/release-js.yml" @@ -206,6 +213,7 @@ jobs: - ".github/workflows/release-kt-lib.yml" - "sh/gh/release.sh" - "rs/moq-ffi/build.sh" + - ".cargo/config.toml" release-swift-lib: - "swift/VERSION" - "swift/Package.swift.template" diff --git a/cpp/moq/cmake/moq-ffi.cmake b/cpp/moq/cmake/moq-ffi.cmake index 3395e806ad1..f4e476d6d98 100644 --- a/cpp/moq/cmake/moq-ffi.cmake +++ b/cpp/moq/cmake/moq-ffi.cmake @@ -7,8 +7,8 @@ # cargo setting (target-dir, build.target) can move them from where the packages look. if(CMAKE_SCRIPT_MODE_FILE) - set(_args build --locked --package moq-ffi --features openh264 - --message-format=json-render-diagnostics) + # The shared default build (.cargo/config.toml), which the prebuilt input matches. + set(_args build-ffi --message-format=json-render-diagnostics) if(RELEASE) list(APPEND _args --release) endif() diff --git a/dart/moq_ffi/hook/build.dart b/dart/moq_ffi/hook/build.dart index 24262d1533a..16de949eef6 100644 --- a/dart/moq_ffi/hook/build.dart +++ b/dart/moq_ffi/hook/build.dart @@ -88,18 +88,11 @@ Future<_Resolved> _resolveLibrary( /// another recipe with different features. Cargo's own timestamp check makes /// the no-op case cheap. Future<_Resolved> _build(Uri workspace, String target, String library) async { - final cargoArgs = [ - 'build', - '--locked', - '--package', - 'moq-ffi', - // The software H.264 fallback is opt-in in Rust; the published library ships it. - // A checkout build is a test build, carrying the hooks leak_test.dart reads. - '--features', - 'openh264,testing', - '--manifest-path', - workspace.resolve('Cargo.toml').toFilePath(), - ]; + // The shared default build, an alias .cargo/config.toml defines for Cargo + // runs in the workspace; it ships the software H.264 fallback. A checkout build is a test build, carrying the hooks + // leak_test.dart reads; `--target` keeps it out of the default build's + // directory, since a cdylib's file name carries no feature hash. + final cargoArgs = ['build-ffi', '--features', 'testing']; // Android needs the NDK's linker and sysroot, which only cargo-ndk sets up. // This mirrors rs/moq-ffi/build.sh. @@ -112,6 +105,7 @@ Future<_Resolved> _build(Uri workspace, String target, String library) async { final result = await Process.run( 'cargo', args, + workingDirectory: workspace.toFilePath(), environment: target.contains('-apple-ios') ? const {'IPHONEOS_DEPLOYMENT_TARGET': '16.0'} : null, diff --git a/quest/m1/README.md b/quest/m1/README.md index 31aea286032..fc62c93f04d 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -174,7 +174,6 @@ removed). - [Next Object on a cold Rust copy](/quest/m1/next-object-cold-copy.md) - a join after an upstream group report starts at the first frame received, never skipping - [Container consumers buffer by backpressure](/quest/m1/container-backpressure.md) - Rust and JS container consumers decode ahead only a byte budget, so a hostile publisher cannot grow them - [An HLS viewer starts capture](/quest/m1/hls-record-demand.md) - a record-track subscriber counts as demand for its rendition's media -- [One moq-ffi build definition](/quest/m1/ffi-build-flags.md) - every binding takes moq-ffi's default features from one place - [gofmt-clean Go wrapper](/quest/m1/go-gofmt.md) - `just go check` fails on unformatted Go - [moqsrc max-delay](/quest/m1/gst-max-delay.md) - GStreamer's `moqsrc` takes a `max-delay` property instead of a hard-coded 1 s budget - [JS SETUP rejection ownership](/quest/m1/js-setup-rejection.md) - reproduce an unhandled version-refusal rejection without weakening the refusal diff --git a/quest/m1/ffi-build-flags.md b/quest/m1/ffi-build-flags.md deleted file mode 100644 index 19cbb364be8..00000000000 --- a/quest/m1/ffi-build-flags.md +++ /dev/null @@ -1,18 +0,0 @@ -# [S] One definition of moq-ffi's default build flags - -## Goal - -Every binding that builds moq-ffi into the shared target directory takes its -features from one place, so a binding whose features drift cannot silently -overwrite `libmoq_ffi.so` for the others again. - -## Plan - -[moq-dev/moq#6716](https://github.com/moq-dev/moq/pull/6716) found that a -cdylib's file name carries no feature hash, so builds with different features -overwrite each other. Today the flags are repeated: `sh/kt/generate.sh`, -`sh/swift/check.sh`, `sh/go/stage.sh`, `sh/dart/generate.sh`, and -`cpp/moq/CMakeLists.txt` each pass `--features openh264`. Define them once, -and make a build that differs use its own target directory or fail loudly. - -Public API: none. Wire: none. diff --git a/rs/justfile b/rs/justfile index 437114da920..80361ee7c45 100644 --- a/rs/justfile +++ b/rs/justfile @@ -190,7 +190,7 @@ x11-bench-ci: [positional-arguments] android *args: bash sh/local.sh cargo ndk -t arm64-v8a --platform 26 check --locked -p moq-video --all-targets "$@" - bash sh/local.sh cargo ndk -t arm64-v8a --platform 26 -o target/android-jni build --locked -p moq-ffi --features openh264 "$@" + bash sh/local.sh cargo ndk -t arm64-v8a --platform 26 -o target/android-jni build-ffi "$@" nm -D --undefined-only target/android-jni/arm64-v8a/libmoq_ffi.so | grep -q __android_log_ # moq-wasm's crate root is `#![cfg(target_arch = "wasm32")]`, so only a wasm32 diff --git a/rs/moq-ffi/Cargo.toml b/rs/moq-ffi/Cargo.toml index af8e9c0d83f..47c4cf1eb48 100644 --- a/rs/moq-ffi/Cargo.toml +++ b/rs/moq-ffi/Cargo.toml @@ -29,9 +29,9 @@ default = ["audio", "video"] audio = ["dep:moq-audio"] video = ["dep:moq-video", "dep:pollster"] # The OpenH264 software H.264 fallback (vendored C++) for `video`. Off for -# development and linting; `build.sh`, maturin, and CI's tests turn it on. It is -# the only encoder on API-24 Android and the Apple simulators, so every release -# build needs it. +# development and linting; `cargo build-ffi` (.cargo/config.toml), maturin, and +# CI's tests turn it on. It is the only encoder on API-24 Android and the Apple +# simulators, so every release build needs it. openh264 = ["moq-video?/openh264"] # qlog trace capture (`MoqQuicConfig::qlog`). Off by default: it compiles the qlog # machinery in and is only wanted for debugging; `moq_qlog_supported` reports it. diff --git a/rs/moq-ffi/build.sh b/rs/moq-ffi/build.sh index 7c4d015fe81..20cb9c75dc0 100755 --- a/rs/moq-ffi/build.sh +++ b/rs/moq-ffi/build.sh @@ -79,6 +79,12 @@ if [[ -n "$LIBRARY" ]]; then fi fi +# A cdylib's file name carries no feature hash, so the minimal library gets a +# target directory of its own rather than replacing the default build's. +if [[ "$NO_DEFAULT_FEATURES" == true ]]; then + TARGET_BASE_DIR="$TARGET_BASE_DIR/minimal" +fi + # Get version from Cargo.toml if not specified if [[ -z "$VERSION" ]]; then VERSION=$(grep '^version' "$SCRIPT_DIR/Cargo.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/') @@ -113,9 +119,10 @@ can_run_on_host() { # Build the library for a single target build_target() { local target="$1" - # Releases carry the OpenH264 software fallback, the only encoder on API-24 - # Android and the Apple simulators; a no-op under --no-default-features. - local cargo_args=(build --locked --release --package moq-ffi --features openh264) + # The shared default build (.cargo/config.toml): releases carry the OpenH264 + # software fallback, the only encoder on API-24 Android and the Apple + # simulators. It is a no-op under --no-default-features. + local cargo_args=(build-ffi --release --target-dir "$TARGET_BASE_DIR" --manifest-path "$WORKSPACE_DIR/Cargo.toml") if [[ "$NO_DEFAULT_FEATURES" == true ]]; then cargo_args+=(--no-default-features) fi @@ -131,15 +138,14 @@ build_target() { if is_android "$target"; then # Android targets use cargo-ndk - cargo ndk --target "$target" --platform 24 -- \ - "${cargo_args[@]}" --manifest-path "$WORKSPACE_DIR/Cargo.toml" + (cd "$WORKSPACE_DIR" && cargo ndk --target "$target" --platform 24 -- "${cargo_args[@]}") else # Set up cross-compilation for Linux ARM64 if [[ "$target" == "aarch64-unknown-linux-gnu" ]]; then export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc fi - cargo "${cargo_args[@]}" --target "$target" --manifest-path "$WORKSPACE_DIR/Cargo.toml" + (cd "$WORKSPACE_DIR" && cargo "${cargo_args[@]}" --target "$target") fi } diff --git a/rs/moq-ffi/examples/server_smoke.py b/rs/moq-ffi/examples/server_smoke.py index 40edc4f7798..3b852aeb4a6 100644 --- a/rs/moq-ffi/examples/server_smoke.py +++ b/rs/moq-ffi/examples/server_smoke.py @@ -6,7 +6,7 @@ Usage: # Build the cdylib and generate the Python bindings. - cargo build --release --package moq-ffi + cargo build-ffi --release cargo run --package uniffi-bindgen --features cli -- generate \ --library target/release/libmoq_ffi.so \ --language python --out-dir target/py-bindings diff --git a/sh/api-diff/ffi.sh b/sh/api-diff/ffi.sh index ba96d493e78..c39531d7ee0 100755 --- a/sh/api-diff/ffi.sh +++ b/sh/api-diff/ffi.sh @@ -58,7 +58,7 @@ strip c "$c_out/include/moq.h" "$out/current/moq.h" # uniffi-bindgen-cpp reads the metadata from a library for any target, so the # x86_64 release library works on any host. gh release download "$ffi_tag" --repo moq-dev/moq --pattern '*-x86_64-unknown-linux-gnu-libmoq_ffi.so' --output "$work/libmoq_ffi.so" -lib=$(cargo build --locked -p moq-ffi --lib --message-format=json | +lib=$(cargo build-ffi --lib --message-format=json | jq -r 'select(.reason == "compiler-artifact" and .target.name == "moq_ffi") | .filenames[] | select(test("\\.(so|dylib)$"))' | tail -1) if [[ -z "$lib" ]]; then echo "cargo build -p moq-ffi produced no shared library" >&2 diff --git a/sh/dart/build.test.py b/sh/dart/build.test.py index 659e7e7769e..38d219babdf 100644 --- a/sh/dart/build.test.py +++ b/sh/dart/build.test.py @@ -13,8 +13,8 @@ class BuildTest(unittest.TestCase): def test_generator_profiles(self): # Only the dev build carries the test hooks, which would skew a benchmark. - for profile, release, features in (("debug", False, "openh264,testing"), - ("release", True, "openh264")): + for profile, release, features in (("debug", False, ["--features", "testing"]), + ("release", True, [])): with self.subTest(profile=profile), tempfile.TemporaryDirectory() as directory: scratch = Path(directory) calls = scratch / "calls" @@ -35,8 +35,9 @@ def test_generator_profiles(self): cwd=ROOT, env=env, text=True, capture_output=True) self.assertEqual(result.returncode, 0, result.stderr) args = calls.read_text().split() + self.assertEqual(args[0], "build-ffi") self.assertEqual("--release" in args, release) - self.assertEqual(args[args.index("--features") + 1], features) + self.assertEqual(args[1:args.index("--target")], [*features, *(["--release"] if release else [])]) def test_failed_benchmark_restores_manifest(self): with tempfile.TemporaryDirectory() as directory: diff --git a/sh/dart/check.sh b/sh/dart/check.sh index 175918d6076..290787ab15f 100755 --- a/sh/dart/check.sh +++ b/sh/dart/check.sh @@ -68,7 +68,7 @@ record_cargo() { local phase=$1 flags=$2 cat >"$generated/bin/cargo" <"$generated/$phase.env" set -- "\$@" $flags fi diff --git a/sh/dart/generate.sh b/sh/dart/generate.sh index 159ddc84664..a7c9a62a9ef 100755 --- a/sh/dart/generate.sh +++ b/sh/dart/generate.sh @@ -37,25 +37,18 @@ shopt -u nocasematch host=$(rustc -vV | sed -n 's/^host: //p') # Checkouts use a dev build; benchmark and release staging opt into release. profile=${MOQ_FFI_PROFILE:-debug} -# The debug features match the hook's checkout build, test hooks included; the release -# build is benchmarked, so it leaves out the counting allocator. +# The shared default build (.cargo/config.toml). The debug one adds the hook's test +# hooks, which is safe only because `--target` gives it a directory no default build +# writes; the release build is benchmarked, so it leaves out the counting allocator. case "$profile" in - debug) - profile_args=() - features=openh264,testing - ;; - release) - profile_args=(--release) - features=openh264 - ;; + debug) profile_args=(--features testing) ;; + release) profile_args=(--release) ;; *) echo "error: unsupported MOQ_FFI_PROFILE: $profile" >&2 exit 1 ;; esac -env -i "${hook_env[@]}" cargo build --locked ${profile_args[@]+"${profile_args[@]}"} --package moq-ffi --features "$features" \ - --target "$host" \ - --manifest-path "$WORKSPACE_DIR/Cargo.toml" +(cd "$WORKSPACE_DIR" && env -i "${hook_env[@]}" cargo build-ffi "${profile_args[@]}" --target "$host") case "$host" in *-apple-*) library="$WORKSPACE_DIR/target/$host/$profile/libmoq_ffi.dylib" ;; diff --git a/sh/dispatch.sh b/sh/dispatch.sh index f71c815df4f..b3f9f1c2dec 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -77,20 +77,21 @@ declare -A scope=( # they target. Only nightly runs the drills; this catches a stale patch. [drill]='^(rs/|test/drill/)' # maturin bundles rs/moq-ffi into the moq-ffi wheel, and the other - # bindings generate from it. Each check also compiles its doc samples. + # bindings generate from it, built by the `cargo build-ffi` alias in + # .cargo/config.toml. Each check also compiles its doc samples. [py]='^(py/|sh/py/|pyproject\.toml$|uv\.lock$|rs/moq-ffi/|doc/lib/py/|doc/lib/samples\.sh$)' - [kt]='^(kt/|sh/kt/|rs/moq-ffi/|doc/lib/kt/|doc/lib/samples\.sh$)' - [swift]='^(swift/|sh/swift/|rs/moq-ffi/|doc/lib/swift/|doc/lib/samples\.sh$)' - [go]='^(go/|sh/go/|rs/moq-ffi/|doc/lib/go/|doc/lib/samples\.sh$)' - [dart]='^(dart/|sh/dart/|rs/moq-ffi/|doc/lib/dart/|doc/lib/samples\.sh$)' + [kt]='^(\.cargo/config\.toml$|kt/|sh/kt/|rs/moq-ffi/|doc/lib/kt/|doc/lib/samples\.sh$)' + [swift]='^(\.cargo/config\.toml$|swift/|sh/swift/|rs/moq-ffi/|doc/lib/swift/|doc/lib/samples\.sh$)' + [go]='^(\.cargo/config\.toml$|go/|sh/go/|rs/moq-ffi/|doc/lib/go/|doc/lib/samples\.sh$)' + [dart]='^(\.cargo/config\.toml$|dart/|sh/dart/|rs/moq-ffi/|doc/lib/dart/|doc/lib/samples\.sh$)' # The C package links moq-c's native-libs lists, and the C++ package's FFI pin. - [c]='^(c/|sh/c/|rs/moq-ffi/|rs/moq-c/native-libs/|cpp/moq/FFI_VERSION$|cpp/moq/cmake/moq-ffi\.cmake$)' + [c]='^(\.cargo/config\.toml$|c/|sh/c/|rs/moq-ffi/|rs/moq-c/native-libs/|cpp/moq/FFI_VERSION$|cpp/moq/cmake/moq-ffi\.cmake$)' # The package links moq-c's native-libs lists, and compiles its doc samples. - [cpp]='^(cpp/moq/|cpp/justfile$|sh/cpp/|rs/moq-ffi/|rs/moq-c/native-libs/|doc/lib/cpp/|doc/lib/samples\.sh$)' + [cpp]='^(\.cargo/config\.toml$|cpp/moq/|cpp/justfile$|sh/cpp/|rs/moq-ffi/|rs/moq-c/native-libs/|doc/lib/cpp/|doc/lib/samples\.sh$)' # The plugin and its tests call through the bindings generated from cpp/moq # and moq-ffi and link through moq-c's native-libs lists, and flake.nix owns # the libobs headers it compiles against. - [obs_compile]='^(cpp/obs/|cpp/moq/|sh/obs/|rs/moq-ffi/|rs/moq-c/native-libs/|flake\.nix$)' + [obs_compile]='^(\.cargo/config\.toml$|cpp/obs/|cpp/moq/|sh/obs/|rs/moq-ffi/|rs/moq-c/native-libs/|flake\.nix$)' # `obs check` compares the OBS pinned in buildspec.json, flake.nix, and # nixpkgs, and the last moves on a flake.lock bump alone. [obs]='^(cpp/obs/|sh/obs/|flake\.(nix|lock)$)' diff --git a/sh/go/stage.sh b/sh/go/stage.sh index f00f3339913..f409f33112a 100755 --- a/sh/go/stage.sh +++ b/sh/go/stage.sh @@ -75,9 +75,11 @@ CARGO_PROFILE=() [[ "$PROFILE" == "release" ]] && CARGO_PROFILE=(--release) echo "go stage: building moq-ffi for $HOST_TARGET..." >&2 -# `openh264`, as release builds ship it: the software encoder the tests rely on. -cargo build --locked ${CARGO_PROFILE[@]+"${CARGO_PROFILE[@]}"} --package moq-ffi --features openh264 \ - --manifest-path "$WORKSPACE_DIR/Cargo.toml" >&2 +# The shared default build (.cargo/config.toml), whose `openh264` the tests rely on. +# Cargo resolves the alias, and a relative CARGO_TARGET_DIR, from the working +# directory, so the build and the metadata below both run in the workspace. +cd "$WORKSPACE_DIR" +cargo build-ffi ${CARGO_PROFILE[@]+"${CARGO_PROFILE[@]}"} >&2 TARGET_BASE=$(cargo metadata --format-version 1 --manifest-path "$WORKSPACE_DIR/Cargo.toml" --no-deps | sed -n 's/.*"target_directory":"\([^"]*\)".*/\1/p') diff --git a/sh/kt/generate.sh b/sh/kt/generate.sh index cd033f2784a..22d1607d075 100755 --- a/sh/kt/generate.sh +++ b/sh/kt/generate.sh @@ -36,9 +36,11 @@ CARGO_PROFILE=() [[ "$PROFILE" == "release" ]] && CARGO_PROFILE=(--release) echo "kt generate: building moq-ffi for $HOST_TARGET..." -# `openh264`, as release builds ship it: the software encoder the tests rely on. -cargo build --locked ${CARGO_PROFILE[@]+"${CARGO_PROFILE[@]}"} --package moq-ffi --features openh264 \ - --manifest-path "$WORKSPACE_DIR/Cargo.toml" +# The shared default build (.cargo/config.toml), whose `openh264` the tests rely on. +# Cargo resolves the alias, and a relative CARGO_TARGET_DIR, from the working +# directory, so the build and the metadata below both run in the workspace. +cd "$WORKSPACE_DIR" +cargo build-ffi ${CARGO_PROFILE[@]+"${CARGO_PROFILE[@]}"} TARGET_BASE=$(cargo metadata --format-version 1 --manifest-path "$WORKSPACE_DIR/Cargo.toml" --no-deps | sed -n 's/.*"target_directory":"\([^"]*\)".*/\1/p') diff --git a/sh/size/collect.sh b/sh/size/collect.sh index 42ddc433494..ebe54660b4d 100755 --- a/sh/size/collect.sh +++ b/sh/size/collect.sh @@ -11,9 +11,10 @@ case $(uname -s) in Linux) dylib=so ;; Darwin) dylib=dylib ;; *) ;; esac # Release jobs ship default features only; this shows what the feature gates save. -cargo build --locked --release -p moq-ffi --no-default-features -cp "$target/release/libmoq_ffi.$dylib" "$out/native/libmoq_ffi-minimal.$dylib" -cp "$target/release/libmoq_ffi.a" "$out/native/libmoq_ffi-minimal.a" +# Its own target directory, since the cdylib would replace the default build's. +cargo build --locked --release -p moq-ffi --no-default-features --target-dir "$target/minimal" +cp "$target/minimal/release/libmoq_ffi.$dylib" "$out/native/libmoq_ffi-minimal.$dylib" +cp "$target/minimal/release/libmoq_ffi.a" "$out/native/libmoq_ffi-minimal.a" bun install --frozen-lockfile just js build bun sh/size/bundles.ts "$out/js" diff --git a/sh/swift/check.sh b/sh/swift/check.sh index 0cf045c2829..8d10e7cc24f 100755 --- a/sh/swift/check.sh +++ b/sh/swift/check.sh @@ -57,9 +57,11 @@ CARGO_PROFILE=() [[ "$PROFILE" == "release" ]] && CARGO_PROFILE=(--release) echo "swift check: building moq-ffi for $HOST_TARGET..." -# `openh264`, as release builds ship it: the software encoder the tests rely on. -cargo build --locked ${CARGO_PROFILE[@]+"${CARGO_PROFILE[@]}"} --package moq-ffi --features openh264 \ - --manifest-path "$WORKSPACE_DIR/Cargo.toml" +# The shared default build (.cargo/config.toml), whose `openh264` the tests rely on. +# Cargo resolves the alias, and a relative CARGO_TARGET_DIR, from the working +# directory, so the build and the metadata below both run in the workspace. +cd "$WORKSPACE_DIR" +cargo build-ffi ${CARGO_PROFILE[@]+"${CARGO_PROFILE[@]}"} TARGET_BASE=$(cargo metadata --format-version 1 --manifest-path "$WORKSPACE_DIR/Cargo.toml" --no-deps | sed -n 's/.*"target_directory":"\([^"]*\)".*/\1/p')