nandi/vflutter_ffipublic Fork 0
4506a586d7400b00d732dcb97167be75ab41cab1
Commits
Clone
git clone https://git.rickub.com/nandi/vflutter_ffi.git
git clone ssh://git@rickub.com/nandi/vflutter_ffi.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Render in parallel on web, via a pool of Web Workers 4506a58 · on 4506a586d7400b00d732dcb97167be75ab41cab1 · nandithebull · 21h ago
justfile · 98 lines · 3.5 KBMakefile Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# nimflutter_ffi — Nim logic, Flutter front end.
#
# Flutter is not assumed to be on PATH: set FLUTTER_BIN if yours lives
# somewhere other than ~/flutter/bin.

flutter_bin := env_var_or_default("FLUTTER_BIN", env_var("HOME") / "flutter/bin")
nim_bin     := env_var_or_default("NIM_BIN", env_var("HOME") / "nim/bin")
flutter     := flutter_bin / "flutter"
lib_path    := justfile_directory() / "build"

# Port for `just web`. Override with WEB_PORT=9000 just web
web_port    := env_var_or_default("WEB_PORT", "8080")

_default:
    @just --list

# Run the Mandelbrot explorer.
mandelbrot: build
    cd example && PATH="{{nim_bin}}:{{flutter_bin}}:$PATH" {{flutter}} run -d linux

# Alias: the example app is the Mandelbrot explorer.
run: mandelbrot

# Build the host Nim library into build/ (--mm:arc -d:danger) and check exports.
build:
    PATH="{{nim_bin}}:$PATH" ./tool/build.sh

# Compile the Nim source to C for iOS/macOS. Run after editing src/nimflutter.nim.
gen-ios:
    PATH="{{nim_bin}}:$PATH" ./tool/gen_ios_sources.sh

# emcc is not installed: tool/bin/emcc is a DotSlash file that fetches a
# content-pinned emscripten on first run and caches it in ~/.cache/dotslash.
# Only `dotslash` itself needs to be on PATH.
#
# Compile the Nim source to WebAssembly for the web build.
wasm:
    PATH="{{nim_bin}}:$PATH" ./tool/build_wasm.sh

# Headless check of the wasm module — no browser, no Flutter.
test-wasm: wasm
    node tool/test_wasm.mjs

# Does the web build really render in parallel, and still get the same pixels?
check-pool: wasm
    ./tool/check_pool.sh

# Same frame from the wasm and native kernels, compared byte for byte.
parity: build wasm
    ./tool/check_parity.sh

# Prints a URL and waits; no browser is launched. Hot restart still works
# (press R). Override the port with WEB_PORT=9000 just web
#
# Serve the Mandelbrot explorer, with Nim running as wasm.
web: wasm
    cd example && PATH="{{flutter_bin}}:$PATH" {{flutter}} run -d web-server --web-port={{web_port}}

# Release web build of the example. Output: example/build/web/
build-web: wasm
    cd example && PATH="{{flutter_bin}}:$PATH" {{flutter}} build web --release

# Load the built web app in headless Chrome and assert Nim drew a real frame.
check-web: build-web
    ./tool/check_web.sh

# Analyze and test the example. Needs the host library for the FFI calls.
test: build
    cd example && PATH="{{flutter_bin}}:$PATH" {{flutter}} analyze
    cd example && LD_LIBRARY_PATH="{{lib_path}}" PATH="{{flutter_bin}}:$PATH" {{flutter}} test

# Nim vs Dart timings for the same frame (AOT, so it matches a release app).
bench: build
    dart compile exe example/lib/fractal_bench.dart -o /tmp/nimflutter_bench
    LD_LIBRARY_PATH="{{lib_path}}" /tmp/nimflutter_bench

# Sweep the isolate count to find the best band split for this machine.
sweep: build
    dart compile exe example/lib/tile_sweep.dart -o /tmp/nimflutter_sweep
    LD_LIBRARY_PATH="{{lib_path}}" /tmp/nimflutter_sweep

# String round-trip and isolate dispatch. No Flutter SDK required.
smoke: build
    LD_LIBRARY_PATH="{{lib_path}}" dart example/lib/main_test.dart

# RSS regression guard for the shared-heap ownership rule. No Flutter SDK needed.
memcheck: build
    LD_LIBRARY_PATH="{{lib_path}}" dart example/lib/memory_check.dart

# Release build of the example.
release: build
    cd example && PATH="{{nim_bin}}:{{flutter_bin}}:$PATH" {{flutter}} build linux --release

# Everything CI would run.
ci: build smoke memcheck test bench test-wasm parity check-pool check-web

clean:
    rm -rf build example/build example/web/nimflutter.js example/web/nimflutter.wasm