Repository navigation
Move the bundle-staging build helpers into a nodespace-app-build crate - #3386
Merged
Merged
Conversation
drop_unstaged_bundle_entries and sync_stale_sidecar move out of the app crate's build.rs and build_support.rs into packages/desktop-app/app-build, so any app crate built on core's library can call them from its build.rs. The crate has no tauri dependency and runs in the ordinary workspace test run. nodespace-app-test-support takes it as a dependency instead of a #[path] include. drop_unstaged_bundle_entries no longer hard-codes core's skill path: it drops any string resources entry whose base directory (the whole path components before the first glob character) is missing or empty. The decision is a pure function over injected file-system predicates, and a test pins that core's config with nothing staged yields the same patch and the same list of missing paths as before. build.rs keeps sync_external_bin_staging, whose sidecar list is core's own, and calls both helpers before tauri_build::build(). gate-scope, the vite watch ignore list and the app-units script comments follow the new crate. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… directory once base_dir rebuilt its result from Path components, which re-joins with the platform separator: on Windows the warning would print `resources\skill` next to `binaries/...`, where the old code printed the entry's own separators, and the two text assertions in the tests would not match. It now cuts the entry at the last separator before the first glob character and trims trailing separators on the string, so the entry's separators reach the warning unchanged on every platform. A path of separators only stays the root. Two resources that draw from the same missing directory listed it twice in the warning and in the rerun-if-changed output. It is listed once. The drop_unstaged_bundle_entries doc now says what the rule leaves alone: a config whose externalBin or resources is missing or not a list, a glob on part of a file name (judged by its directory), a glob at the crate root (never empty), and a non-empty directory that matches nothing. Co-Authored-By: Claude Sonnet 5 <[email protected]>
mstomar125
force-pushed
the
issue-3305-app-build-helpers
branch
from
September 30, 2026 11:25
3e65dea to
6c170f2
Compare
7 tasks
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.
Closes #3305
Part of #3298 (Pro/core boundary) and #3322 (Tauri extension points): the two build-script helpers move into a
nodespace-app-buildcrate, so any app crate built on core's library can call them from itsbuild.rs.What changed
packages/desktop-app/app-build(nodespace-app-build, libnodespace_app_build). Its only dependency isserde_json; it has notauridependency, so it runs in the ordinary workspace nextest run on every platform (rust:test:workspaceexcludes only the three app crates).sidecar_staging.rsisbuild_support.rsmoved withgit mv. Only the module doc changed: the "why not a crate" paragraph is gone and the rest is written for "an app crate", not for core's binaries.bundle_entries.rsholdsdrop_unstaged_bundle_entries()and a pureplan(conf, target_triple, exe_suffix, file_exists, dir_has_entries) -> Option<Plan>. The wrapper reads the environment, callsplan, setsTAURI_CONFIG, prints the warning and emitsrerun-if-changed.resourcesentry is kept when its base directory exists and is non-empty; otherwise it is dropped and listed as missing.build.rsdropsmod build_support;,SKILL_RESOURCESanddrop_unstaged_bundle_entries, and calls the crate for both helpers.sync_external_bin_stagingandEXTERNAL_BIN_NAMESstay (they are core's own list).build_support.rsis deleted.serde_jsonis no longer a build dependency of the app crate.nodespace-app-test-supporttakes the crate as a dependency and re-exportssync_stale_sidecarwithpub use, replacing the#[path]include.Cargo.tomlmember,gate-scope.tsRUST_DIRS(+ agate-scope.test.tscase), the vite watch ignore list, comments intest-app-units.ts/build-skill.ts/sidecar_staging_sync_test.rs, and theCLAUDE.mdstructure tree.test-app-units.tslogic is unchanged.Parity with the old build script
The release bundle must stage exactly what it staged before. I compared the old and new build script three ways, with no full release/LTO build:
cargo build -p nodespace-app(debug), same three scenarios before and after, each after resettingtarget/debug's staged copies. Nothing staged, sidecars + skill staged but the skill installer missing, and everything staged. In all three, whattauri_buildcopied intotarget/debug(file list and sizes) and the contents ofbinaries/andresources/are identical before and after. The build-script output differs only in the hint wording and in one absolute path containing the build-script hash directory; thecargo:warninglist of missing paths and everycargo:rerun-if-changedline are identical.not staged, left out of this debug build's bundle: binaries/nodespaced-aarch64-apple-darwin, binaries/nodespace-aarch64-apple-darwin, binaries/nodespace-skill-installer-aarch64-apple-darwin, resources/skillplan, over the core config for all 8 sidecar subsets x skill staged/unstaged, plus the Windows.exesuffix. Patch value, serialised patch string and missing-path list all matched.PROFILE: release with nothing staged exits 1 withresource path `binaries/nodespaced-aarch64-apple-darwin` doesn't exist; debug with nothing staged exits 0; release and debug with everything staged both exit 0.An end-to-end mutation of the wrapper (drop the
env::set_var("TAURI_CONFIG", ...)call) makes the real debug build fail with that sameresource path ... doesn't existerror, so the wrapper is covered beyond the pure-function tests.Deviations from the issue text (the code and a correct reading won)
*,?or[". Read literally,binaries/tool-*would be judged bybinaries/tool-, which is never a directory, so the entry would be dropped even when the files exist. The base directory here is the run of whole components before the first glob character (binaries/tool-*->binaries). For every entry in core's config the result is the issue's (resources/skill/**/*->resources/skill,resources/models/**/*->resources/models). Pinned bya_partial_filename_glob_is_judged_by_its_directoryandbase_dir_is_the_whole_components_before_the_first_glob_character.a_glob_free_resource_is_kept_when_it_is_a_staged_file).plan:applies(profile, tauri_config_is_set)(debug only, never over an explicitTAURI_CONFIG) andnearest_existing_ancestor(thererun-if-changedtarget). Both were inline before; splitting them made the "release stays strict" and "don't rerun every build" rules testable.serde_jsonwithoutpreserve_orderserialisesexternalBinbeforeresources; the issue writes them the other way round. It is a JSON merge patch, so the order is irrelevant. The test compares JSON values, and the differential test above showed the serialised string is byte-identical to the old code's.resources/modelsentry with a warning, where before it failed withGlobPathNotFound. A checkout always has the tracked.gitkeep, so nothing changes for core today, andtest-app-units.tsstill requires the path up front as before.dev:tauristages and how the Tauri-seam tests find the daemon are now a comment at the call site in core'sbuild.rs; the crate's docs are generic.Tests
New in
app-build/src/bundle_entries.rs(14 tests in the crate; all six from the issue plus the extras above):keeps_everything_when_everything_is_staged,drops_an_unstaged_sidecar,drops_a_resource_whose_base_directory_is_empty_or_missing,keeps_a_resource_whose_base_directory_has_a_file,leaves_non_string_entries_as_declared,core_config_with_nothing_staged_matches_todays_patch(readstauri.conf.jsonviainclude_str!, pins the patch value and the printed list of missing paths),looks_for_the_executable_suffix_of_the_target_platform,a_partial_filename_glob_is_judged_by_its_directory,a_glob_free_resource_is_kept_when_it_is_a_staged_file,a_resources_map_leaves_the_config_alone,a_config_without_a_sidecar_list_is_left_alone,base_dir_is_the_whole_components_before_the_first_glob_character,only_a_debug_build_without_an_explicit_config_drops_entries,watches_the_nearest_existing_ancestor_of_a_dropped_path.Mutation check: 20 breaks, each applied to the source, the crate's tests run, and the intended test confirmed failing before restoring (source restored byte-identical afterwards). All 20 were caught by the test meant to catch them, for example:
plannever returningNone, an unstaged sidecar never dropped, the.exesuffix ignored, unstaged resources never dropped, every resource dropped, a partial-name glob judged by its literal prefix, a staged file not counting as content, non-string sidecar or resource entries dropped, a resources map or a missing sidecar list treated as empty, missing paths reversed,externalBinomitted from the patch, a trailing separator kept on the base directory, only*starting a glob, an empty base not becoming.,appliestrue for non-debug profiles or over an explicit config, and the ancestor watch returning the path itself or the empty path.gate-scope.test.tsgainspackages/desktop-app/app-build/src/bundle_entries.rsin its "counts as a Rust input" table; without theRUST_DIRSentry that path would classify as frontend-only.Verification run
cargo test -p nodespace-app-build(14 pass);cargo fmt;cargo clippy -p nodespace-app-build -p nodespace-app -p nodespace-app-test-support --all-targets -- -D warnings -D clippy::unused-asynccleanNODESPACE_PRO_SUPABASE_URL=https://example.invalid NODESPACE_PRO_ANON_KEY=dummy cargo check -p nodespace-apppassesbun test scripts/gate-scope.test.ts(26 pass);bun run quality:scripts:fix;bun run --cwd packages/desktop-app quality:fixbun run test:changed(every tier: the gate's own scripts changed)Ratchet
bun run scripts/check-pro-boundary.tspasses with no count above its baseline. This change removes no Pro markers (I counted markers in the old and new text of every changed file: none in either), soBASELINESare untouched and no count rises.cloudSyncHooksreads 0 against a baseline of 4 from earlier merged work, not from this PR; I left it for whoever tightens next rather than add a conflicting edit toBASELINEShere.🤖 Generated with Claude Code