Module: Lilac::Wasm::Bin
- Defined in:
- lib/lilac/wasm/bin.rb,
lib/lilac/wasm/bin/version.rb
Overview
Path resolution for the bundled wasm runtimes + JS bridge.
Released gem layout:
lilac-wasm-bin-X.Y.Z/
├── lib/lilac/wasm/bin.rb ← this file
└── data/
├── lilac-full.wasm
├── lilac-compiled.wasm
├── mrbc-host.wasm (compiler-only wasm, driven via wasmtime-rb)
└── mruby-wasm-js/
├── index.js
├── wasi-preview1.js
└── ...
Monorepo dev layout (via gem "lilac-wasm-bin", path: "../wasm-bin"):
data/ may be empty or partially populated. As a fallback the
resolver walks up to the lilac monorepo root and reads from
build/ (lilac-full,compiled.wasm) / mrbgem/mruby-wasm-js/
(bridge), so contributors don't have to rake build:assets
before every tweak. The fallback prefers the RELEASE wasm
(build/<name>.release.wasm, what the released gem ships) over the
dev build, so a path: checkout vendors the same small artifact as
production; the dev build is the last resort (debugging).
Constant Summary collapse
- DATA_DIR =
Absolute path to this gem's
data/directory — the canonical location for the bundled wasm + bridge in a released gem. File.("../../../data", __dir__).freeze
- VERSION =
"0.2.0"
Class Method Summary collapse
-
.lilac_compiled_wasm ⇒ Object
Path to lilac-compiled.wasm.
-
.lilac_full_wasm ⇒ Object
Path to lilac-full.wasm.
-
.mrbc_host_wasm ⇒ Object
Path to mrbc-host.wasm — a compiler-only wasm reactor that
lilac-cli's WasmMrbcDriver drives via wasmtime-rb to replace the externalmrbcbinary forlilac build --target compiled. -
.mruby_wasm_js_dir ⇒ Object
Path to the JS bridge directory (
@takahashim/mruby-wasm-jssource).
Class Method Details
.lilac_compiled_wasm ⇒ Object
Path to lilac-compiled.wasm. Same discovery pattern.
44 45 46 |
# File 'lib/lilac/wasm/bin.rb', line 44 def lilac_compiled_wasm first_existing(*monorepo_candidates("lilac-compiled")) end |
.lilac_full_wasm ⇒ Object
Path to lilac-full.wasm. Prefers the gem's data/; falls back
to <monorepo>/build/lilac-full.wasm for in-repo development.
Returns nil if neither exists.
39 40 41 |
# File 'lib/lilac/wasm/bin.rb', line 39 def lilac_full_wasm first_existing(*monorepo_candidates("lilac-full")) end |
.mrbc_host_wasm ⇒ Object
Path to mrbc-host.wasm — a compiler-only wasm reactor that
lilac-cli's WasmMrbcDriver drives via wasmtime-rb to replace
the external mrbc binary for lilac build --target compiled.
Same gem-vs-monorepo discovery as the other variants.
52 53 54 |
# File 'lib/lilac/wasm/bin.rb', line 52 def mrbc_host_wasm first_existing(*monorepo_candidates("mrbc-host")) end |
.mruby_wasm_js_dir ⇒ Object
Path to the JS bridge directory (@takahashim/mruby-wasm-js
source). The runtime wasms can't load without index.js +
wasi-preview1.js etc. siblings — the lilac-cli builder
auto-vendors the whole directory into dist/vendor/.../.
60 61 62 63 64 65 |
# File 'lib/lilac/wasm/bin.rb', line 60 def mruby_wasm_js_dir first_directory( File.join(DATA_DIR, "mruby-wasm-js"), File.join(monorepo_root, "mrbgem", "mruby-wasm-js", "js"), ) end |