Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ rather than in the crate.
```bash
just ffi test # export the fixtures, build them, and drive api from C, C++, Kotlin, Python, Swift, Go, and Dart
just ffi moq # export moq's crates at the pinned revision, build them, and run moq/moq.c, moq/moq.cpp, moq/moq.kt, moq/moq.py, moq/moq.swift, moq/moq.go, and moq/moq.dart
just ffi moq-c # the same export, built in debug, running only moq/moq.c: `just ci`'s check on moq
just ffi moq-cpp # the same export, running only moq/moq.cpp
just ffi moq-swift # the same export, running only moq/moq.swift
just ffi census # census each into target/census
Expand Down
23 changes: 21 additions & 2 deletions ffi/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,32 @@ dart-program dir main:
"$sdk/bin/dartaotruntime" "$sdk/bin/snapshots/gen_kernel_aot.dart.snapshot" --platform "$sdk/lib/_internal/vm_platform_strong.dill" \
--packages "$dir/.dart_tool/package_config.json" --native-assets "$dir/native_assets.yaml" -o "$dir/main.dill" "$dir/main.dart"

# Export moq's crates' C ABI as `just ffi moq` does, build it in debug, and run only moq/moq.c against it: `just ci`'s check that the export still serves moq, from the pinned moq revision or a checkout.
moq-c checkout="": (moq-write checkout)
#!/usr/bin/env bash
set -euo pipefail
out=target/export/moq
# The lint moq-export denies, and the native libraries; only the static library, which
# the C program links, with the glue of every language but Python's, whose symbols
# would leave the link undefined.
export RUSTFLAGS="-D recursion_depth_exceeding_limit --print=native-static-libs"
cargo rustc --locked --quiet --manifest-path "$out/Cargo.toml" --lib --crate-type staticlib --features kotlin,dart 2>&1 | tee target/moq-c-build.log
sed -n 's/^note: native-static-libs: //p' target/moq-c-build.log > target/moq-c-native
read -ra native < target/moq-c-native
cc -std=c11 -pedantic -Wall -Wextra -Werror -I "$out/include" moq/moq.c "$out/target/debug/libmoq.a" "${native[@]}" -o target/moq-c-test
target/moq-c-test

# Export moq's crates' C ABI into target/export/moq, unbuilt.
[private]
moq-write checkout="": (standin checkout)
cargo run --locked --quiet -- --config moq/ffi.toml --manifest-path target/moq-ffi/Cargo.toml --out target/export/moq

# Export moq's crates' C ABI into target/export/moq and build it, with the libraries a program linking it needs besides in target/moq-native.
[private]
moq-export checkout="": (standin checkout)
moq-export checkout="": (moq-write checkout)
#!/usr/bin/env bash
set -euo pipefail
out=target/export/moq
cargo run --locked --quiet -- --config moq/ffi.toml --manifest-path target/moq-ffi/Cargo.toml --out "$out"
# A later nightly makes this future-compat lint a hard error; fail on it in moq's crates
# and the glue now, while the pin can still move. rustc prints the native libraries.
export RUSTFLAGS="-D recursion_depth_exceeding_limit --print=native-static-libs"
Expand Down
24 changes: 0 additions & 24 deletions quest/m0/ffi-moq-gate.md

This file was deleted.

5 changes: 4 additions & 1 deletion quest/m0/ffi-test-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ Expect to merge in `fixtures.rs` and the test programs with
the same cases. A content key includes their edits to the test sources, so neither makes
a cached program stale.

`just ci`'s `just ffi moq-c` (moq's export, built in debug, and `moq/moq.c` run against
it) should take the same skip: on a warm gate it spends 7-44s rebuilding the glue the
export rewrites and about 10s linking it.

Out of scope: warming the queue's or a land fixer's `target`, which kixel-ai/dotfiles
owns; a cold run, which builds everything once as today.

Public API: none; the exporter may stop rewriting unchanged files.

## Related

- [The moq export gates exporter merges](/quest/m0/ffi-moq-gate.md) - adds moq's export and C test to the gate, which the same skip should cover
- [Failed checks raise](/quest/m1/ffi-export/checks-raise.md) - rewrites the same test programs and fixture cases
6 changes: 5 additions & 1 deletion sh/dispatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ test_lint() { python3 -I .github/crabx/test_pipeline.py; }
test_sh() { python3 -I sh/dispatch.test.py; }
test_crabx() { just crabx test; }
test_driver() { just driver test; }
test_ffi() { just ffi test; }
# moq's export at the pin, cut down to C, before the slower test build.
test_ffi() {
just ffi moq-c
just ffi test
}
test_go() { just go test; }
# moq-net's translation at the pin, its first consumer, before the slower test build.
test_ts() {
Expand Down