From 1cf51bfd0aebad722e79e2d29636e96bdcf3668e Mon Sep 17 00:00:00 2001 From: zackees Date: Tue, 12 May 2026 21:14:39 -0700 Subject: [PATCH 1/5] fix(cli): install emscripten + esbuild before --just-compile delegation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #68's deploy job (`build_site.py`) now reaches the Rust binary via PATH, but the next call — `fastled --just-compile` — falls into the Python delegation branch of `lib.rs` WITHOUT calling `install::ensure_emscripten_installed()`. Python's emscripten lookup returns None on a fresh CI runner and compile fails with: Native compilation failed: Emscripten SDK not found. `compile_and_serve` (the non-just-compile path) does install the toolchain. Promote the same pre-step to also cover the just-compile delegation: whenever the CLI is about to invoke `python -m fastled.app` with a sketch directory (and we're not in `--init` / `--install` mode), ensure emscripten + esbuild are installed and export FASTLED_EMSCRIPTEN_DIR / FASTLED_ESBUILD_PATH for the subprocess. Local: bash lint clean, 119 unit tests pass. --- crates/fastled-cli/src/lib.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/crates/fastled-cli/src/lib.rs b/crates/fastled-cli/src/lib.rs index 5995a334..95d683c1 100644 --- a/crates/fastled-cli/src/lib.rs +++ b/crates/fastled-cli/src/lib.rs @@ -683,6 +683,33 @@ pub fn run() -> ExitCode { } } + // If we're about to delegate a compile to Python (`--just-compile `) + // ensure the emscripten + esbuild toolchains are installed first and + // export the paths through env vars — matches what compile_and_serve() + // does for the non-just-compile path. Without this, Python's emscripten + // toolchain lookup falls through to "not found" on a fresh CI runner. + let needs_compile_toolchain = cli.directory.is_some() && cli.init.is_none() && !cli.install; + if needs_compile_toolchain { + match install::ensure_emscripten_installed() { + Ok(install_dir) => { + std::env::set_var("FASTLED_EMSCRIPTEN_DIR", &install_dir); + } + Err(e) => { + eprintln!("fastled: emscripten toolchain install failed: {e:#}"); + return ExitCode::FAILURE; + } + } + match install::ensure_esbuild_installed() { + Ok(esbuild_path) => { + std::env::set_var("FASTLED_ESBUILD_PATH", &esbuild_path); + } + Err(e) => { + eprintln!("fastled: esbuild install failed: {e:#}"); + return ExitCode::FAILURE; + } + } + } + // --- Delegate to Python for everything else ------------------------------ // (--just-compile, --init, --install, etc.) From c6642bf16f0440fbdcda5106e50f14d02c51eeee Mon Sep 17 00:00:00 2001 From: zackees Date: Tue, 12 May 2026 21:32:25 -0700 Subject: [PATCH 2/5] fix(rust): parse both manifest layouts (nested + inline versions) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous deploy failure after PR #69 was a manifest-parse error: parse manifest JSON from .../linux/x86_64/manifest.json: bad version entry 'versions': missing field `href` The clang-tool-chain-bins emscripten manifest is served in two shapes: * Linux / macOS — nested: {"latest": "4.0.21", "versions": {"4.0.21": {...}}} * Windows — inline: {"latest": "4.0.19", "4.0.19": {...}} The published `ctcb-manifest` crate's custom deserializer only handles the inline shape; it fails on Linux. Drop the dep, define local PartRef/VersionInfo/PlatformManifest types in `install.rs`, and write a custom Deserialize for PlatformManifest that accepts both shapes (prefer nested `versions` when present, fall back to inline keys). Verified locally by running `target/release/fastled --just-compile` against the live Windows manifest — install proceeds past the parse and the only remaining error is a missing-sketch failure, unrelated to the toolchain bring-up. CI Linux deploy will now exercise the nested path. --- Cargo.lock | 25 --------- Cargo.toml | 1 - crates/fastled-cli/Cargo.toml | 1 - crates/fastled-cli/src/install.rs | 84 ++++++++++++++++++++++++++++++- 4 files changed, 83 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b099cf7..22510de6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -716,30 +716,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "ctcb-core" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d666d682b69add1b1bea317cb3184018f21a0ff95f3a9d1b44887bd5b01961" -dependencies = [ - "anyhow", - "serde", - "serde_json", - "thiserror 2.0.18", -] - -[[package]] -name = "ctcb-manifest" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97c47fc9cd2017787aad53c7a11fb8529291cadb369dc15ad041eb81fbc06221" -dependencies = [ - "anyhow", - "ctcb-core", - "serde", - "serde_json", -] - [[package]] name = "ctor" version = "0.2.9" @@ -1059,7 +1035,6 @@ dependencies = [ "axum", "clap", "crossterm", - "ctcb-manifest", "dirs 5.0.1", "flate2", "notify", diff --git a/Cargo.toml b/Cargo.toml index 1be7bf9d..b8d61ff4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,6 @@ flate2 = "1" serde = { version = "1", features = ["derive"] } serde_json = "1" anyhow = "1" -ctcb-manifest = "0.4.1" dirs = "5" strsim = "0.11" crossterm = "0.28" diff --git a/crates/fastled-cli/Cargo.toml b/crates/fastled-cli/Cargo.toml index f3211d5d..17fdf79f 100644 --- a/crates/fastled-cli/Cargo.toml +++ b/crates/fastled-cli/Cargo.toml @@ -34,7 +34,6 @@ tokio = { workspace = true } axum = { workspace = true } tower-http = { workspace = true } tokio-stream = { workspace = true } -ctcb-manifest = { workspace = true } dirs = { workspace = true } tempfile = "3" diff --git a/crates/fastled-cli/src/install.rs b/crates/fastled-cli/src/install.rs index 92048b78..ff890cd2 100644 --- a/crates/fastled-cli/src/install.rs +++ b/crates/fastled-cli/src/install.rs @@ -10,10 +10,92 @@ use std::io::{BufReader, BufWriter, Write}; use std::path::{Path, PathBuf}; use anyhow::{bail, Context, Result}; -use ctcb_manifest::{PartRef, PlatformManifest}; +use serde::Deserialize; +use std::collections::BTreeMap; use crate::archive; +// --------------------------------------------------------------------------- +// Manifest schema +// --------------------------------------------------------------------------- +// +// The clang-tool-chain-bins emscripten manifest is served in two different +// shapes depending on platform. Linux/macOS nests version entries under a +// `versions` key: +// +// { "latest": "4.0.21", +// "versions": { "4.0.21": { "href": "...", "sha256": "...", "parts": [...] }, ... } } +// +// Windows inlines version entries at the top level alongside `latest`: +// +// { "latest": "4.0.19", +// "4.0.19": { "href": "...", "sha256": "...", "parts": [...] } } +// +// Our `PlatformManifest` accepts both via a custom Deserialize. + +#[derive(Debug, Deserialize)] +struct PartRef { + href: String, + sha256: String, +} + +#[derive(Debug, Deserialize)] +struct VersionInfo { + href: String, + sha256: String, + parts: Option>, +} + +#[derive(Debug)] +struct PlatformManifest { + latest: String, + versions: BTreeMap, +} + +impl<'de> Deserialize<'de> for PlatformManifest { + fn deserialize>(deserializer: D) -> Result { + let raw: serde_json::Value = Deserialize::deserialize(deserializer)?; + let obj = raw + .as_object() + .ok_or_else(|| serde::de::Error::custom("expected JSON object at manifest root"))?; + + let latest = obj + .get("latest") + .and_then(|v| v.as_str()) + .ok_or_else(|| serde::de::Error::custom("missing 'latest' key"))? + .to_string(); + + let mut versions = BTreeMap::new(); + + // Prefer the nested-`versions` shape (Linux / macOS manifests) when + // present. Fall back to top-level inline entries (Windows). + if let Some(serde_json::Value::Object(versions_obj)) = obj.get("versions") { + for (key, value) in versions_obj { + let info: VersionInfo = serde_json::from_value(value.clone()).map_err(|e| { + serde::de::Error::custom(format!( + "bad version entry '{key}' (nested versions): {e}" + )) + })?; + versions.insert(key.clone(), info); + } + } else { + for (key, value) in obj { + if key == "latest" { + continue; + } + let info: VersionInfo = serde_json::from_value(value.clone()).map_err(|e| { + serde::de::Error::custom(format!( + "bad version entry '{key}' (inline versions): {e}" + )) + })?; + versions.insert(key.clone(), info); + } + } + + Ok(PlatformManifest { latest, versions }) + } +} + const EMSCRIPTEN_MANIFEST_BASE_URL: &str = "https://raw.githubusercontent.com/zackees/clang-tool-chain-bins/main/assets/emscripten"; From 18057db3137530ea6e034ba5870dfb142b536533 Mon Sep 17 00:00:00 2001 From: zackees Date: Tue, 12 May 2026 21:45:13 -0700 Subject: [PATCH 3/5] fix(deps): add meson + ninja to runtime deps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After PR #69's earlier commits got the toolchain pre-step working, the deploy job advances further into the compile flow before failing: [WASM] Build failed: [Errno 2] No such file or directory: 'meson' File ".../internal_wasm_build.py", line 600, in ensure_meson_configured The FastLED C++ → WASM build invokes `meson` via subprocess (and meson runs `ninja` as its backend), but neither was declared as a dependency of the fastled package. CI runners don't have them on PATH; pip-install of fastled didn't provide them either. Both ship standalone executables when pip-installed (via `meson` and `ninja` PyPI packages), so adding them to `[project.dependencies]` puts them in `.venv/Scripts/` and on PATH for the subprocess. Net runtime deps go from 1 → 3 (`meson`, `ninja`, `zcmds_win32; Windows`), but all three are load-bearing for the compile critical path. --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 9f90a6d1..a13bc56c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,12 @@ keywords = ["template-python-cmd"] license = { text = "BSD 3-Clause License" } classifiers = ["Programming Language :: Python :: 3"] dependencies = [ + # Build-system dependencies for the FastLED C++ → WASM compile. + # `meson` configures the build; `ninja` is meson's backend. Both ship + # standalone executables when pip-installed, which the toolchain + # invokes via subprocess from `src/fastled/toolchain/internal_wasm_build.py`. + "meson>=1.4", + "ninja>=1.11", "zcmds_win32; sys_platform == 'win32'", ] From 524dac434e0a642f34efd458f8ee5cae2d9fc094 Mon Sep 17 00:00:00 2001 From: zackees Date: Tue, 12 May 2026 21:59:18 -0700 Subject: [PATCH 4/5] fix(deps): re-add clang-tool-chain for the meson wasm cross-file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After meson + ninja landed, the deploy job's compile now reaches meson's configure step and fails with: meson.build:1:0: ERROR: Unknown compiler(s): [['clang-tool-chain-emcc']] Running `clang-tool-chain-emcc --version` gave "[Errno 2] No such file or directory: 'clang-tool-chain-emcc'" FastLED's `ci/meson/wasm_cross_file.ini` names `clang-tool-chain-emcc` / `clang-tool-chain-em++` / `clang-tool-chain-emar` as the wasm compiler/linker/archiver. Those are wrapper scripts shipped by the `clang-tool-chain` PyPI package; earlier I dropped that dep when porting the *install* logic to Rust, but the *wrappers* are still needed at compile time. Two changes: * `pyproject.toml`: re-add `clang-tool-chain>=1.2.6` to runtime deps so the wrapper scripts land in `.venv/Scripts/bin`. Comment explains why it stays after the earlier dep purge. * `crates/fastled-cli/src/lib.rs`: after Rust installs emscripten, also export `CLANG_TOOL_CHAIN_DOWNLOAD_PATH` pointed at the toolchains root (`~/.fastled/toolchains/`). The wrappers honor this env var and will find the Rust-installed emscripten under `/emscripten///` rather than the default `~/.clang-tool-chain/` layout. Net runtime deps: 3 → 4 (`meson`, `ninja`, `clang-tool-chain`, `zcmds_win32; Windows`). The architectural goal "Rust owns install" is preserved — clang-tool-chain provides only the meson-compatible compiler wrappers; the actual emscripten download still happens in Rust. --- crates/fastled-cli/src/lib.rs | 14 ++++++++++++++ pyproject.toml | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/crates/fastled-cli/src/lib.rs b/crates/fastled-cli/src/lib.rs index 95d683c1..ba039bdc 100644 --- a/crates/fastled-cli/src/lib.rs +++ b/crates/fastled-cli/src/lib.rs @@ -171,6 +171,20 @@ fn compile_and_serve(dir: &str, cli: &Cli, mode: ViewerMode) -> ExitCode { match install::ensure_emscripten_installed() { Ok(install_dir) => { std::env::set_var("FASTLED_EMSCRIPTEN_DIR", &install_dir); + // FastLED's meson cross-file calls `clang-tool-chain-emcc` / + // `-em++` / `-emar`. Those wrappers (from the `clang-tool-chain` + // PyPI package) look up emscripten under + // `$CLANG_TOOL_CHAIN_DOWNLOAD_PATH/emscripten///`. + // install_dir here is `/emscripten///`, + // so walk four parents up to the toolchains root and export it. + if let Some(root) = install_dir + .parent() + .and_then(|p| p.parent()) + .and_then(|p| p.parent()) + .and_then(|p| p.parent()) + { + std::env::set_var("CLANG_TOOL_CHAIN_DOWNLOAD_PATH", root); + } } Err(e) => { eprintln!("fastled: emscripten toolchain install failed: {e:#}"); diff --git a/pyproject.toml b/pyproject.toml index a13bc56c..d1f07432 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,14 @@ dependencies = [ # invokes via subprocess from `src/fastled/toolchain/internal_wasm_build.py`. "meson>=1.4", "ninja>=1.11", + # FastLED's meson cross-file at `ci/meson/wasm_cross_file.ini` invokes + # `clang-tool-chain-emcc` / `clang-tool-chain-em++` / `clang-tool-chain-emar` + # as the wasm compiler/linker/archiver. Those wrapper scripts are shipped + # by the `clang-tool-chain` PyPI package. The Rust CLI installs the + # underlying emscripten toolchain itself (see install.rs); the wrappers + # find it via the CLANG_TOOL_CHAIN_DOWNLOAD_PATH env var that the Rust + # binary exports before delegating to Python. + "clang-tool-chain>=1.2.6", "zcmds_win32; sys_platform == 'win32'", ] From 16aa59833ba2c52de8af6e7bb6cd2847c501f5a2 Mon Sep 17 00:00:00 2001 From: zackees Date: Tue, 12 May 2026 22:11:51 -0700 Subject: [PATCH 5/5] fix(rust): restore +x on emscripten binaries after tar extract MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After commit 524dac4 (clang-tool-chain dep), the deploy job advances all the way through meson configuration — the wrappers find emscripten 4.0.21 via CLANG_TOOL_CHAIN_DOWNLOAD_PATH — and then fails the very first compile invocation with: PermissionError: [Errno 13] Permission denied File ".../emscripten/.../bin/clang" Some tar extractors apply the umask during unpack and drop the +x bit from shipped binaries (clang, wasm-ld, node, etc.) under bin/, emscripten/, libexec/. The previous Python implementation (`emscripten_archive.py::_extract_archive`) had a belt-and-suspenders chmod loop for exactly this; the Rust port (install.rs) dropped it. Restore it: walk staging/{bin,emscripten,libexec} recursively after `archive::extract_tar_zst` and add 0o111 to every file's mode. Gated on `#[cfg(unix)]` — no-op on Windows where the umask issue doesn't apply. --- crates/fastled-cli/src/install.rs | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/crates/fastled-cli/src/install.rs b/crates/fastled-cli/src/install.rs index ff890cd2..4c55764b 100644 --- a/crates/fastled-cli/src/install.rs +++ b/crates/fastled-cli/src/install.rs @@ -254,6 +254,21 @@ pub fn ensure_emscripten_installed() -> Result { fs::create_dir_all(&staging)?; archive::extract_tar_zst(&archive_path, &staging)?; + // Restore execute bits on Unix — some tar implementations (and the + // umask of the extracting process) strip the +x bit from binaries + // under bin/, emscripten/, and libexec/. emcc.py then hits + // PermissionError when it tries to exec clang. Mirror the + // belt-and-suspenders chmod from the previous Python implementation. + #[cfg(unix)] + { + for subdir in ["bin", "emscripten", "libexec"] { + let dir = staging.join(subdir); + if dir.is_dir() { + add_executable_bits_recursive(&dir)?; + } + } + } + fs::write(staging.join("done.txt"), "ok\n")?; if install_dir.exists() { @@ -266,6 +281,29 @@ pub fn ensure_emscripten_installed() -> Result { Ok(install_dir) } +/// Recursively chmod every file under `dir` to include +x for user / group / +/// other (no-op on Windows). Used right after emscripten extraction so the +/// shipped binaries (clang, wasm-ld, etc.) are actually executable. +#[cfg(unix)] +fn add_executable_bits_recursive(dir: &Path) -> Result<()> { + use std::os::unix::fs::PermissionsExt; + for entry in fs::read_dir(dir).with_context(|| format!("read_dir {}", dir.display()))? { + let entry = entry?; + let path = entry.path(); + let file_type = entry.file_type()?; + if file_type.is_dir() { + add_executable_bits_recursive(&path)?; + } else if file_type.is_file() { + let mode = entry.metadata()?.permissions().mode(); + let new_mode = mode | 0o111; + if new_mode != mode { + fs::set_permissions(&path, fs::Permissions::from_mode(new_mode))?; + } + } + } + Ok(()) +} + // --------------------------------------------------------------------------- // esbuild // ---------------------------------------------------------------------------