Repository navigation
refactor!: amalgamate kernal-api-build into kernal-api as build-resources - #341
Conversation
…urces`
kernal-api is one package (ARCHITECTURE.md, "Source and package
organization"). The build-script companion `kernal-api-build` was never
published -- every release's publish step failed because crates.io trusted
publishing cannot create a new crate -- and nothing outside this repository
depends on it. Its code becomes the feature-gated module
`kernal_api::build_resources` behind `build-resources = ["dep:embed-resource"]`,
with embed-resource an optional, exact-pinned dependency. Public API is
unchanged apart from the path.
The companion existed because a `kernal-api/<feature>` entry in an
application's feature table applies to every dependency named `kernal-api`,
build-dependencies included. Renaming the build-dependency does not work:
Cargo 1.95 rejects one package depending on another under two names
("depends on crate ... multiple times with different names"), regardless of
dependency kind. The documented shape is therefore a second, same-name
build-dependency. Features set in `[dependencies]` stay out of the build
script (edition-2021 resolver); forwarded `kernal-api/<feature>` entries do
reach it, with an application-owned library crate as the workaround. The
build script also compiles kernal-api's mandatory dependencies for the host.
- tests/build-resources-consumer: external fixture; CI compiles it and
ci/check_compilation_boundary_dependencies.py asserts its resolved
features (runtime: window-icon only; build script: build-resources only;
forwarded feature reaches the build script, pinning the documented rule).
- embed-resource RED/GREEN case; feature in CI isolation list and docs.rs.
- Public-API tests moved to tests/process/windows_app_resources.rs; the
private resource-script rendering tests stay inline.
- Removed: crates/kernal-api-build, the workspace member, the companion
package/publish steps in ci.yml, release.yml and auto-release.yml,
crate_release.py's --package/Spec plumbing and its companion tests, and
the companion-version source-policy test (replaced by a build-resources
policy test).
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The Windows `Build` lanes failed to link kernal-api's own test binaries: `lld-link: error: undefined symbol: vswhom_find_visual_studio_and_windows_sdk`. `build-resources` pulls embed-resource, which depends on vswhom-sys for Windows; that crate's C++ archive is produced only on a Windows host, so a Linux-hosted cross link for `*-pc-windows-msvc` cannot resolve its symbols. Before the amalgamation embed-resource was only ever compiled for a build script's host, and `--all-features` in the per-target matrix put it in a target graph for the first time. `build-resources` is a host-only build-script facility, so a graph linked for another target must not include it. ci/target_features.py derives the target graph from Cargo.toml's `[features]` -- everything but `default` and the host-only set -- so new features are still covered; the `build` job exports it as KERNAL_TARGET_FEATURES for its clippy, `cargo test --no-run`, `nextest archive` and webview smoke steps, and ci/native_proof.py's `all` graph reads the same variable so it still shares the archive's graph (`--all-features` in `linux`, where host == target). Coverage for `build-resources` is unchanged in substance and now runs it the way applications do: the per-feature isolation check, the native tests/build-resources-consumer check in `linux`, and a new step in each Windows lane that runs that fixture's build script for the Windows target -- which is what actually proves resource compilation cross-compiles. Linux-hosted `--all-features` jobs are unaffected and stay as they were: `linux` (clippy, nextest), `dylints`, release.yml's `soldr cargo test --locked --all-features`, and ci/crate_release.py packaging. ci/test_target_features.py is new (and added to the CI guards step): the list equals `--all-features` minus the host-only set, every optional dependency is named by a `dep:` entry so there are no implicit features, and the `build` job uses the variable in all four places instead of `--all-features`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Follow-up: the per-target build graph excludes host-only featuresThe first CI run failed in the Windows while linking
Unaffected, all Linux-hosted and left as they were: New |
The new Windows-lane step failed with `embed-resource: compilation not attempted: missing compiler: llvm-rc`. embed-resource invokes `llvm-rc` by plain name for an MSVC target, and the Linux cross builder carries only versioned LLVM binaries. Resolve one -- PATH, then `/usr/lib/llvm-*/bin/llvm-rc` or `llvm-rc-*`, then `apt-get install llvm` -- and pass it through embed-resource's documented `RC_<target>` override. A host with no llvm-rc at all is an error, not a skip: compiling resources for the target is the point of the step. Verified locally for both aarch64- and x86_64-pc-windows-msvc, including that the override is what selects the compiler (a bogus RC_<target> fails naming that path) and that the build script produces kernal-api-app.lib. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
First release with the amalgamated single crate (#341): the Windows executable-resources helper ships as `kernal_api::build_resources` behind the `build-resources` feature, and kernal-api-build is gone. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Summary
This PR merges
kernal-api-buildintokernal-api, following the one-package design in ARCHITECTURE.md ("Source and package organization").kernal-api-buildwas never published: every release's publish step failed, because crates.io trusted publishing can't create a new crate. Nothing outside this repo depends on it.build-resources = ["dep:embed-resource"].embed-resourceis now optional and pinned to=3.0.11. The feature is outsidefulland is added to docs.rs.kernal_api::build_resources, gated by#[cfg(feature = "build-resources")]. The API is the same as before, only the path changed:embed_windows_app_resources,WindowsAppResources(new,with_file_description,with_icon) andWindowsResourceError.CARGO_CFG_TARGET_OS,RC/RC_<target>,rc.exe/llvm-rc. There's no hostcfg.Consumer shape (and why the rename does not work)
The plan was a renamed build-dependency (
kernal-api-build = { package = "kernal-api", ... }). Cargo 1.95 rejects that:the crate X depends on crate kernal-api multiple times with different names. Cargo checks every declared edge between two packages, whatever the dependency kind. I reproduced this with a two-crate example outside this repo. That leaves the same-name build-dependency above:[dependencies]entry don't reach the build script, because the edition-2021 resolver keeps build-dependency features separate. The reverse holds too:build-resourcesnever reaches the executable.kernal-api/<feature>entry in the application's own[features]table does reach the build script, because Cargo applies it to every dependency with that name. This is the problem the separate crate was created to avoid, and a single package can't avoid it. The workaround, which I checked with a repro: forward through a library crate the application owns (viewer = ["dep:app-viewer"]), so the binary's feature table never nameskernal-api/....The module docs, README, COMPATIBILITY and the Cargo.toml feature comment all describe this.
Tests
tests/build-resources-consumer/: an external fixture with its own[workspace], like the daemon-registration consumers. CI's "Check the external facade consumers" step compiles it.ci/check_compilation_boundary_dependencies.pychecks its resolved features: the runtimekernal-apihaswindow-iconand notbuild-resources; the build-script one has exactly{build-resources}.--features forwarded, the build dependency does gettext-similarity. This pins Cargo's current behaviour so the docs can't quietly go stale.window-icon.embed-resourcestays out of the dependency graph unlessbuild-resourcesis on.tests/process/windows_app_resources.rs. The tests for the private resource-script rendering stay inline in the module.tests/source_policy/facade_policy.rs: the companion-version test is replaced bybuild_resources_is_an_opt_in_feature_of_the_one_package.Removed
crates/kernal-api-build/and the root[workspace] membersentry.ci.yml, the package step inrelease.yml, and the publish step inauto-release.yml.--package/Speccode inci/crate_release.py(back to single-package) and theBuildCompanionTestsinci/test_crate_release.py.kernal-api-buildentry inCargo.lock.The version is not bumped.
Validation (Linux x86-64, exit codes)
soldr cargo fmt --all --check(and the fixture)clippy --all-targets --all-features -D warningsclippy --lib --test process --test source_policy --no-default-features --features build-resources--target x86_64-pc-windows-msvcclippy --lib --no-default-featurescargo check --lockednative /--target x86_64-pc-windows-msvc(the build script really ran llvm-rc:kernal-api-app.libproduced)cargo test --features build-resources: lib unit,process::windows_app_resources,source_policy, doctestscargo test --all-features --test source_policy(32 passed)ci/check_compilation_boundary_dependencies.pyci/test_crate_release.py,test_auto_release.py,test_release_package_features.py, unittest guards (native_proof, native_proof_jobs, macos_x64_guest, nextest_config, deny_warnings)soldr cargo dylint --all --workspace -- --all-features --all-targetsclippy --all-targets --no-default-featuresfails in thewasmtest target, which can't findwasmparser. It fails the same way with no features at all, so it isn't caused by this PR. CI's per-feature isolation runscargo checkon the lib, not--all-targets.🤖 Generated with Claude Code