feat(cross): vendor cargo modules and prefetch pub for offline builds#100
Merged
Conversation
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>
This was referenced Jul 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
emb fetch(andemb cross --fetch-only) vendor eachbuild: cargomodule into the shared store withcargo vendor --locked, content-addressed by the module'sCargo.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.CARGO_HOMEat the vendored config, socargo --offlineresolves crates from the on-disk vendor dir instead of the registry.emb fetch --app <dir>runsflutter pub get --enforce-lockfileto populatePUB_CACHEand the app's.dart_toolfor the offline build.emb fetchnow serveslocal/hosttoo — no toolchain to resolve, but it still vendors crates and prefetches pub.Structure
lib/src/cross/cargo_vendor.dart:cargoLockDir(repo-boundary walk-up),vendorConfig(absolute-path rewrite), theCargoVendorclass (vendor/locate), andvendorTargetCargo/hasCargoModulesshared byemb fetchandemb cross --fetch-only.Test
dart analyze lib testclean;dart format --set-exit-if-changedclean.cargo_vendor_test.dart(walk-up incl. the.gitboundary, config rewrite, vendor with a fake runner,locate); extendedfetch_command_test.dart(--appguard, native path).real dpkg-deb/real debugfstests (fail onmaintoo).Docs
README updated in this PR: the
emb fetchsection (new--approw, vendoring/prefetch prose) and the Offline builds subsection.Follow-ups
PUB_CACHE(this prefetches into the ambient cache the build inherits) and pub prefetch parity onemb cross --fetch-only.--offline=strict(denies emb's own egress today; does not yet sandbox a subprocess).