Skip to content

feat: embed Windows application resources from a build script - #276

Merged
zackees merged 1 commit into
release/0.1.3from
feat/windows-app-resources
Sep 15, 2026
Merged

zackees merged 1 commit into
release/0.1.3from
feat/windows-app-resources

Conversation

@zackees

@zackees zackees commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

New opt-in feature windows-app-resources. It gives applications a build-script capability to embed a Windows executable's resources:

  • the Explorer icon,
  • version information,
  • a Common-Controls v6 manifest.

Why

These are PE resources linked into the executable. Cargo only links a build script's resources into the binaries of the package that runs the script, so a normal dependency cannot provide them.

Applications that moved off tauri-build lost them. The FastLED CLI's Tauri-era fastled.exe carried RT_ICON, RT_GROUP_ICON (id 32512), RT_VERSION and RT_MANIFEST; the kernal-api build carries no resources at all.

API

// build.rs, with kernal-api as a build-dependency using this feature
use kernal_api::windows_resources::{embed_windows_app_resources, WindowsAppResources};

let resources = WindowsAppResources::new("FastLED Viewer", "fastled", env!("CARGO_PKG_VERSION"))?
    .with_icon("icons/icon.ico");
embed_windows_app_resources(&resources)?;
  • Validation: text fields are 1–256 bytes, with no control characters or quotes. The version must start with numeric major.minor.patch, each at most 65535; pre-release and build suffixes stay in the version strings.
  • Output: renders the .rc script and manifest into OUT_DIR, and prints rerun-if-changed for the icon.
  • Backend: compiles and links through the private embed-resource backend, pinned =3.0.11: rc.exe on MSVC, llvm-rc when cross-compiling, and RC/RC_<target> override both. embed_resource joins the facade's forbidden re-exports.
  • Non-Windows targets: no-op.
  • Compatibility with Tauri-built executables: icon group id 32512 (IDI_APPLICATION), version block 040904B0, and the same Common-Controls manifest.

Changes

  • src/windows_resources.rs (new), gated in src/lib.rs
  • Cargo.toml: the feature (not in full) and the optional exact-pinned dependency
  • tests/facade_policy.rs: forbidden re-export, and the README feature list
  • README.md, COMPATIBILITY.md: feature and public-surface entries
  • .github/workflows/ci.yml: the feature in the each-feature matrix

Validation

  • cargo test --features windows-app-resources --lib windows_resources: 5 passed. Covers version parsing, text validation, script rendering with and without an icon, and the manifest.
  • cargo test --features windows-app-resources --test facade_policy: 15 passed.
  • cargo clippy --features windows-app-resources --lib -- --deny warnings: clean.
  • cargo clippy --locked --all-features --all-targets -- --deny warnings: clean.
  • End to end with the FastLED CLI: its build.rs calls this capability, and the CLI was built against this branch through a local patch:
    • a native Linux build (no-op) succeeds;
    • a soldr build --release --target x86_64-pc-windows-msvc cross-build from Linux, using llvm-rc as the resource compiler, produced a fastled.exe whose resources match the Tauri-era release exactly:
Resource Tauri-era fastled.exe Built with this capability
RT_ICON id 1, 1128 bytes id 1, 1128 bytes
RT_GROUP_ICON id 32512 id 32512
RT_VERSION CompanyName=fastled, ProductName=FastLED Viewer, 2.0.20 identical strings
RT_MANIFEST Common-Controls v6 Common-Controls v6

🤖 Generated with Claude Code

https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG

An executable's Explorer icon, version information and application
manifest are resources linked into the executable. Cargo only links a
build script's resources into the binaries of the package that runs the
script, so applications need a build-script capability. They lost that
when they moved off tauri-build.

The new `windows-app-resources` feature adds
`windows_resources::embed_windows_app_resources`, called from an
application's build.rs with kernal-api as a build-dependency. It
validates the product name, company, version and optional icon, renders
the .rc script and a Common-Controls v6 manifest into OUT_DIR, and
compiles and links them through the private embed-resource backend
(rc.exe on MSVC, llvm-rc when cross-compiling). It does nothing for
non-Windows targets. The icon group uses id 32512 and the version block
uses 0409/04B0, matching what Tauri-built executables carried.

The feature is opt-in and not part of `full`; `embed_resource` is added
to the facade's forbidden re-exports.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG
@zackees
zackees merged commit 41acb87 into release/0.1.3 Sep 15, 2026
54 checks passed
zackees added a commit that referenced this pull request Sep 15, 2026
Release on release/0.1.3 containing #276, which adds the opt-in
windows-app-resources build-script capability, on top of v0.1.5.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG
zackees added a commit to FastLED/cli that referenced this pull request Sep 15, 2026
The Tauri-era fastled.exe carried RT_ICON, RT_GROUP_ICON (32512),
RT_VERSION ("FastLED Viewer", "fastled", package version) and a
Common-Controls v6 RT_MANIFEST from tauri-build; the kernal-api build
carried no resources.

kernal-api v0.1.6 adds the windows-app-resources build-script capability
(forge-ci/kernal-api#276). crates/fastled-cli/build.rs declares the
product and icon and calls it; it does nothing on non-Windows targets.
The boundary test now allows exactly this one build script: kernal-api
is its only build dependency, from the same release, with only that
feature, and the script names no other crate.

A fastled.exe cross-built from Linux for x86_64-pc-windows-msvc embeds
the same four resources as the Tauri-era release. Linux: Rust workspace
tests, Python unit tests and bash lint pass.

Refs #242

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG
@zackees
zackees deleted the feat/windows-app-resources branch November 5, 2026 05:51
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