Skip to content

bug(ci): WASM build cannot resolve nested examples (all of examples/Fx/*) #3975

Closed

Description

@zackees

Summary

bash compile wasm --examples <Name> fails for any example not sitting directly under examples/. All examples nested one level deep (the entire examples/Fx/ family, ~10 sketches) are affected.

Reproduce

$ bash compile wasm --examples FxCylon
[WASM] Build failed: Sketch not found: .../examples/FxCylon/FxCylon.ino
FileNotFoundError: Sketch not found: .../examples/FxCylon/FxCylon.ino

The sketch actually lives at examples/Fx/FxCylon/FxCylon.ino.

Root cause

Several call sites build the sketch path by assuming a flat layout:

ino_file = PROJECT_ROOT / "examples" / example_name / f"{example_name}.ino"

On current origin/master (ci/wasm_build.py) this pattern appears at lines 58, 824, 1138, 1648, 1714, plus the output-directory construction in ci/ci-compile.py and ci/wasm_compile.py:

output_dir = Path("examples") / example / "fastled_js"

Note the compiler's own discovery uses examples_dir.rglob("*.ino") (ci/compiler/board_example_utils.py:84), so nested examples are discovered — the WASM path helpers are the only place that assumes flat.

Fix

Add one resolver and route every site through it:

def resolve_example_dir(example_name: str) -> Path:
    """Resolve an example name to its directory.

    Examples live either directly under examples/ (e.g. examples/Blink/) or
    nested one or more levels deep (e.g. examples/Fx/FxCylon/). Accepts a bare
    name ("FxCylon") or a relative path ("Fx/FxCylon").
    """
    examples_root = PROJECT_ROOT / "examples"
    name = Path(example_name).name

    direct = examples_root / example_name
    if (direct / f"{name}.ino").exists():
        return direct

    for ino in examples_root.rglob(f"{name}.ino"):
        if ino.parent.name == name:
            return ino.parent

    raise FileNotFoundError(f"Sketch not found: {examples_root / example_name}")

Keeping the direct-path check first preserves existing behavior for flat examples and avoids an rglob on the common path.

Verification

Applied against a local checkout, bash compile wasm --examples FxCylon progressed from immediate FileNotFoundError to successfully producing:

examples/Fx/FxCylon/fastled_js/fastled.js    42,424 bytes
examples/Fx/FxCylon/fastled_js/fastled.wasm 173,642 bytes

— i.e. compiled and linked into the correct nested output directory.

Caveat: that verification was on a checkout ~1,236 commits behind origin/master, where this file has since diverged (5 flat sites upstream vs 4 locally). The patch below therefore needs re-application against current master rather than direct use. The build then stopped at an unrelated esbuild failure, which reproduces identically for the flat example Blink and is a separate matter.

Patch (against the stale base — for reference, not direct application)

diff
diff --git a/ci/ci-compile.py b/ci/ci-compile.py
index 36e1aa21f..ff8c7589e 100644
--- a/ci/ci-compile.py
+++ b/ci/ci-compile.py
@@ -251,7 +251,9 @@ def _wasm_fast_path() -> int | None:
     # skipping both wasm_compile and argparse (~47ms saved)
     from pathlib import Path
 
-    output_dir = Path("examples") / example / "fastled_js"
+    from ci.wasm_build import resolve_example_dir
+
+    output_dir = resolve_example_dir(example) / "fastled_js"
     output_dir.mkdir(parents=True, exist_ok=True)
     output_js = output_dir / "fastled.js"
 
diff --git a/ci/wasm_build.py b/ci/wasm_build.py
index af81631dd..09f06879e 100644
--- a/ci/wasm_build.py
+++ b/ci/wasm_build.py
@@ -53,11 +53,30 @@ def get_build_dir(mode: str) -> Path:
     return BUILD_DIR_PREFIX / f"meson-wasm-{mode}"
 
 
+def resolve_example_dir(example_name: str) -> Path:
+    """Resolve an example name to its directory.
+
+    Examples live either directly under examples/ (e.g. examples/Blink/) or
+    nested one or more levels deep (e.g. examples/Fx/FxCylon/). Accepts a bare
+    name ("FxCylon") or a relative path ("Fx/FxCylon").
+    """
+    examples_root = PROJECT_ROOT / "examples"
+    name = Path(example_name).name
+
+    direct = examples_root / example_name
+    if (direct / f"{name}.ino").exists():
+        return direct
+
+    for ino in examples_root.rglob(f"{name}.ino"):
+        if ino.parent.name == name:
+            return ino.parent
+
+    raise FileNotFoundError(f"Sketch not found: {examples_root / example_name}")
+
+
 def get_sketch_cache_dir(example_name: str) -> Path:
     """Get per-sketch cache directory next to the .ino file: <sketch_dir>/.build/wasm/."""
-    ino_file = PROJECT_ROOT / "examples" / example_name / f"{example_name}.ino"
-    if not ino_file.exists():
-        raise FileNotFoundError(f"Sketch not found: {ino_file}")
+    ino_file = resolve_example_dir(example_name) / f"{Path(example_name).name}.ino"
     d = ino_file.parent / ".build" / "wasm"
     d.mkdir(parents=True, exist_ok=True)
     return d
@@ -592,11 +611,8 @@ def create_wrapper(example_name: str, sketch_cache_dir: Path) -> Path:
 
     Returns path to the wrapper file.
     """
-    example_dir = PROJECT_ROOT / "examples" / example_name
-    ino_file = example_dir / f"{example_name}.ino"
-
-    if not ino_file.exists():
-        raise FileNotFoundError(f"Example not found: {ino_file}")
+    example_dir = resolve_example_dir(example_name)
+    ino_file = example_dir / f"{Path(example_name).name}.ino"
 
     # Discover additional .cpp files in the example directory tree (sorted for determinism)
     extra_cpps = sorted(
@@ -904,8 +920,8 @@ def compile_sketch(
     library_archive = build_dir / "ci" / "meson" / "wasm" / "libfastled.a"
     # Find the .ino file that the wrapper #includes
     example_name = wrapper_path.stem.replace("_wrapper", "")
-    example_dir = PROJECT_ROOT / "examples" / example_name
-    ino_file = example_dir / f"{example_name}.ino"
+    example_dir = resolve_example_dir(example_name)
+    ino_file = example_dir / f"{Path(example_name).name}.ino"
     if object_path.exists():
         object_mtime = object_path.stat().st_mtime
         wrapper_mtime = wrapper_path.stat().st_mtime
@@ -1414,7 +1430,7 @@ def copy_templates(output_dir: Path) -> None:
 
 def generate_manifest(example_name: str, output_dir: Path) -> None:
     """Generate files.json manifest for data files."""
-    example_dir = PROJECT_ROOT / "examples" / example_name
+    example_dir = resolve_example_dir(example_name)
     data_extensions = frozenset(
         (".json", ".csv", ".txt", ".cfg", ".bin", ".dat", ".mp3", ".wav")
     )
diff --git a/ci/wasm_compile.py b/ci/wasm_compile.py
index 7d4660b79..46eb3595e 100644
--- a/ci/wasm_compile.py
+++ b/ci/wasm_compile.py
@@ -94,7 +94,9 @@ def main() -> int:
     # Output to examples/<name>/fastled_js/fastled.js to match expected location
     from pathlib import Path
 
-    output_dir = Path("examples") / example_name / "fastled_js"
+    from ci.wasm_build import resolve_example_dir
+
+    output_dir = resolve_example_dir(example_name) / "fastled_js"
     output_dir.mkdir(parents=True, exist_ok=True)
 
     output_js = output_dir / "fastled.js"

Activity

  1. zackees commented on Aug 22, 2026

    @zackees
    MemberAuthor

    Tracked in the meta issue: #3986 — remote assets: hosting, build-time resolution, and on-device filesystem deployment.

  2. moved this from Triage to Done in FastLED Trackeron Aug 23, 2026
  3. added a commit that references this issue on Aug 23, 2026
    e7cb022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions