MCPcopy Create free account
hub / github.com/FastLED/FastLED / build

Function build

ci/wasm_build.py:1727–1844  ·  view source on GitHub ↗

Core build function — callable directly without argparse overhead.

(
    example: str,
    output: str,
    mode: str = "quick",
    verbose: bool = False,
    force: bool = False,
)

Source from the content-addressed store, hash-verified

1725
1726
1727def build(
1728 example: str,
1729 output: str,
1730 mode: str = "quick",
1731 verbose: bool = False,
1732 force: bool = False,
1733) -> int:
1734 """Core build function — callable directly without argparse overhead."""
1735 try:
1736 start_time = time.time()
1737 build_dir = get_build_dir(mode)
1738 sketch_cache_dir = get_sketch_cache_dir(example)
1739 output_js = Path(output)
1740 # Auto-fix: if output looks like a directory (no .js suffix), append fastled.js
1741 if output_js.suffix != ".js":
1742 output_js = output_js / "fastled.js"
1743 output_dir = output_js.parent
1744
1745 print(f"[WASM] Building {example} (mode: {mode})")
1746
1747 # Step 1: Configure meson
1748 if not ensure_meson_configured(build_dir, mode, force):
1749 return 1
1750
1751 # Step 2: Build library via ninja (skipped if source fingerprint matches)
1752 lib_start = time.time()
1753 lib_ok, lib_was_rebuilt = build_library(build_dir, verbose)
1754 if not lib_ok:
1755 return 1
1756
1757 # Step 2b: Build sketch-specific PCH (invalidated when library sources change)
1758 sketch_pch = build_sketch_pch(
1759 build_dir, mode, lib_was_rebuilt=lib_was_rebuilt, verbose=verbose
1760 )
1761 if sketch_pch is None:
1762 print("[WASM] WARNING: Sketch PCH build failed, continuing without PCH")
1763 lib_time = time.time() - lib_start
1764
1765 # Step 3: Create wrapper and compile sketch (per-sketch cache)
1766 sketch_start = time.time()
1767 wrapper = create_wrapper(example, sketch_cache_dir)
1768 sketch_obj = compile_sketch(wrapper, build_dir, sketch_cache_dir, mode, verbose)
1769 if sketch_obj is None:
1770 return 1
1771 sketch_time = time.time() - sketch_start
1772
1773 # Step 4: Link (per-sketch cache, copy to output)
1774 link_start = time.time()
1775 output_dir.mkdir(parents=True, exist_ok=True)
1776 if not link_wasm(
1777 sketch_obj, build_dir, sketch_cache_dir, output_js, mode, verbose
1778 ):
1779 # Self-healing: link failures from signature mismatches or
1780 # undefined symbols usually mean stale object files. Nuke
1781 # caches and retry the full build pipeline once.
1782 print("[WASM] Link failed, attempting self-healing rebuild...")
1783 if _recover_stale_wasm_build(build_dir):
1784 # Also invalidate sketch cache so it gets recompiled

Callers 1

mainFunction · 0.85

Calls 15

get_build_dirFunction · 0.85
get_sketch_cache_dirFunction · 0.85
ensure_meson_configuredFunction · 0.85
build_sketch_pchFunction · 0.85
create_wrapperFunction · 0.85
compile_sketchFunction · 0.85
link_wasmFunction · 0.85
copy_templatesFunction · 0.85
generate_manifestFunction · 0.85
generate_asset_manifestFunction · 0.85
timeMethod · 0.80

Tested by

no test coverage detected