Skip to content

feat(cross): vendor cargo modules and prefetch pub for offline builds#100

Merged
jwinarske merged 4 commits into
mainfrom
jw/cargo-vendor
Jul 4, 2026
Merged

feat(cross): vendor cargo modules and prefetch pub for offline builds#100
jwinarske merged 4 commits into
mainfrom
jw/cargo-vendor

Conversation

@jwinarske

Copy link
Copy Markdown
Contributor

Extends the acquisition step so cargo and pub inputs are materialized too — an offline module build now has every crate and package on disk. Builds on the offline fence from #98.

What

  • Cargo vendoring. emb fetch (and emb cross --fetch-only) vendor each build: cargo module into the shared store with cargo vendor --locked, content-addressed by the module's Cargo.lock. The lock is found by walking up to the enclosing repository (stopping at .git), so a crate that locks at a Cargo workspace root is not mistaken for unpinned.
  • Offline consumption. The offline build points CARGO_HOME at the vendored config, so cargo --offline resolves crates from the on-disk vendor dir instead of the registry.
  • Pub prefetch. emb fetch --app <dir> runs flutter pub get --enforce-lockfile to populate PUB_CACHE and the app's .dart_tool for the offline build.
  • Native targets. emb fetch now serves local/host too — no toolchain to resolve, but it still vendors crates and prefetches pub.

Structure

  • New lib/src/cross/cargo_vendor.dart: cargoLockDir (repo-boundary walk-up), vendorConfig (absolute-path rewrite), the CargoVendor class (vendor/locate), and vendorTargetCargo/hasCargoModules shared by emb fetch and emb cross --fetch-only.

Test

  • dart analyze lib test clean; dart format --set-exit-if-changed clean.
  • New cargo_vendor_test.dart (walk-up incl. the .git boundary, config rewrite, vendor with a fake runner, locate); extended fetch_command_test.dart (--app guard, native path).
  • Full suite: 498 pass, 1 skip, and the same 2 pre-existing real dpkg-deb/real debugfs tests (fail on main too).

Docs

README updated in this PR: the emb fetch section (new --app row, vendoring/prefetch prose) and the Offline builds subsection.

Follow-ups

  • Store-rooted PUB_CACHE (this prefetches into the ambient cache the build inherits) and pub prefetch parity on emb cross --fetch-only.
  • The netns enforcement ladder + --offline=strict (denies emb's own egress today; does not yet sandbox a subprocess).

jwinarske added 4 commits July 3, 2026 21:43
Make cargo and pub inputs part of the acquisition step so an offline
module build has every crate and package on disk.

- emb fetch (and emb cross --fetch-only) now vendor each build: cargo
  module into the shared store with `cargo vendor --locked`, keyed by
  the module's Cargo.lock. The lock is found by walking up to the
  enclosing repo (stopping at .git), so a crate that locks at a Cargo
  workspace root is not mistaken for unpinned.
- The offline build points CARGO_HOME at the vendored config so
  `cargo --offline` resolves crates from the on-disk vendor dir.
- emb fetch --app <dir> runs `flutter pub get --enforce-lockfile` to
  populate PUB_CACHE and the app's .dart_tool for the offline build.
- emb fetch now also serves native targets (cargo/pub prefetch with no
  toolchain to resolve).

Signed-off-by: Joel Winarske <joel.winarske@linux.com>
Update the emb fetch section and the Offline builds subsection to cover
the crate vendoring and the --app pub prefetch, and note that the
offline build resolves cargo modules from the vendored crates.

Signed-off-by: Joel Winarske <joel.winarske@linux.com>
The README additions use crates, lockfile, prefetch(es), and
vendor(ed)(s); add them so the spell-check passes.

Signed-off-by: Joel Winarske <joel.winarske@linux.com>
Signed-off-by: Joel Winarske <joel.winarske@linux.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant