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

Function _fast_link

ci/wasm_build.py:1358–1444  ·  view source on GitHub ↗

Fast link using cached wasm-ld args + cached JS glue. Bypasses emcc entirely (~0.2s vs ~1.1s). Returns True on success, False to fall back to full emcc link.

(
    sketch_object: Path,
    cached_wasm: Path,
    build_dir: Path,
    mode: str,
    library_archive: Path | None = None,
    verbose: bool = False,
)

Source from the content-addressed store, hash-verified

1356
1357
1358def _fast_link(
1359 sketch_object: Path,
1360 cached_wasm: Path,
1361 build_dir: Path,
1362 mode: str,
1363 library_archive: Path | None = None,
1364 verbose: bool = False,
1365) -> bool:
1366 """Fast link using cached wasm-ld args + cached JS glue.
1367
1368 Bypasses emcc entirely (~0.2s vs ~1.1s).
1369 Returns True on success, False to fall back to full emcc link.
1370 """
1371 cached_js_glue = build_dir / "fastled_glue.js"
1372 if not cached_js_glue.exists():
1373 return False
1374
1375 cache_file = build_dir / "wasm_ld_args.json"
1376 if not cache_file.exists():
1377 return False
1378
1379 # Check that the js_symbols stub exists
1380 cached_stub = build_dir / "libemscripten_js_symbols.so"
1381 if not cached_stub.exists():
1382 return False
1383
1384 if not _js_glue_fingerprint_matches(build_dir):
1385 print("[WASM] JS glue inputs changed - invalidating linker cache")
1386 _clear_link_cache(build_dir)
1387 return False
1388
1389 if not _link_environment_fingerprint_matches(build_dir, mode):
1390 print("[WASM] Link environment changed - invalidating linker cache")
1391 _clear_link_cache(build_dir)
1392 return False
1393
1394 # Invalidate cache if the library archive changed since last capture
1395 cache_key_file = build_dir / "wasm_ld_args.key"
1396 if library_archive is not None and library_archive.exists():
1397 current_key = _link_cache_key(library_archive)
1398 if cache_key_file.exists():
1399 stored_key = cache_key_file.read_text(encoding="utf-8").strip()
1400 if stored_key != current_key:
1401 print("[WASM] Library changed — invalidating linker cache")
1402 _clear_link_cache(build_dir)
1403 return False
1404 else:
1405 # No key file — can't verify, invalidate to be safe
1406 _clear_link_cache(build_dir)
1407 return False
1408
1409 try:
1410 template_args: list[str] = json.loads(cache_file.read_text(encoding="utf-8"))
1411 except (json.JSONDecodeError, OSError):
1412 return False
1413
1414 # Substitute placeholders and upgrade --strip-debug → --strip-all
1415 # (safe because all needed symbols use explicit --export flags)

Callers 1

link_wasmFunction · 0.85

Calls 8

_clear_link_cacheFunction · 0.85
_link_cache_keyFunction · 0.85
printFunction · 0.50
appendMethod · 0.45
runMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected