-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ninja
76 lines (62 loc) · 3.16 KB
/
build.ninja
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
builddir = build
site = $builddir/site
tscdir = $builddir/tsc
wasmbindgendir = $builddir/wasm-bindgen
rule generate-version
description = Generate version info file
command = git rev-list --count --merges HEAD > $out
build $site/.version: generate-version .git/index
rule cp
description = Copy $in to build directory
command = cp $in $out
rule svg2png
description = Rendering $in to ${size}px
command = convert -background none -resize ${size}x${size} -define png:exclude-chunks=date,time $in $out
rule svg2ico
description = Render $in to .ico
command = convert -background none -define 'icon:auto-resize=16,24,32,64,128,256' $in $out
build $site/index.html: cp src/index.html
build $site/manifest.json: cp src/manifest.json
build $site/css/style.css: cp src/css/style.css
build $site/icons/logo.svg: cp src/images/logo.svg
build $site/icons/512px.png: svg2png src/images/logo.svg
size = 512
build $site/icons/256px.png: svg2png src/images/logo.svg
size = 256
build $site/icons/128px.png: svg2png src/images/logo.svg
size = 128
build $site/icons/64px.png: svg2png src/images/logo.svg
size = 64
build $site/favicon.ico: svg2ico src/images/logo.svg
build $site/images/warning.svg: cp src/images/warning.svg
rule tsc
description = Compile TypeScript to JavaScript
command = tsc --build --force src/scripts/main
restat = true
rule support-no-bundler
description = Support running $in in browser
command = sed -e "s@import \(.*\) from [\"']\(.*\)[\"']@import \1 from './\2.js'@" $in > $out
build build $builddir/tsc/main/main.js $builddir/tsc/main/tsconfig.tsbuildinfo $builddir/tsc/service-worker/worker.js $builddir/tsc/service-worker/tsconfig.tsbuildinfo: tsc src/scripts/main/main.ts src/scripts/service-worker/worker.ts | src/scripts/general-tsconfig.json src/scripts/main/tsconfig.json src/scripts/service-worker/tsconfig.json $wasmbindgendir/app.d.ts
build $site/scripts/main.js: support-no-bundler $builddir/tsc/main/main.js
rule process-worker
# Workers cannot be modules and need a different version on every commit. We
# use the content of the `.version`-file generated beforehand (an implicit
# rule is required to enforce this).
description = Pre-processing service worker source
command = sed -e '/^export default/d' -e "s/\$$version/$$(cat $site/.version)/" $in > $out
build $site/worker.js: process-worker $builddir/tsc/service-worker/worker.js | $site/.version
rule cargo
description = Compile crate $crate to WASM
command = cargo build --release -p $crate --color=always --quiet
depfile = $builddir/wasm32-unknown-unknown/release/$crate.d
deps = gcc
restat = true
rule wasm-bindgen
description = Generate WASM bindings
command = wasm-bindgen --target $target --out-dir $wasmbindgendir $in
build $builddir/wasm32-unknown-unknown/release/app.wasm: cargo Cargo.toml
crate = app
build $wasmbindgendir/app_bg.wasm $wasmbindgendir/app_bg.wasm.d.ts $wasmbindgendir/app.d.ts $wasmbindgendir/app.js: wasm-bindgen $builddir/wasm32-unknown-unknown/release/app.wasm
target = web
build $site/scripts/app_bg.wasm: cp $wasmbindgendir/app_bg.wasm
build $site/scripts/app.js: cp $wasmbindgendir/app.js