1set positional-arguments := true
2set shell := ["bash", "-c"]
3
4version := `git describe --tags --dirty --always`
5export GOOS := env("GOOS", "linux")
6export GOARCH := env("GOARCH", "amd64")
7
8_help:
9 @just -l
10
11# Generate README.md from lexer definitions
12readme:
13 #!/usr/bin/env bash
14 GOOS= GOARCH= ./table.py
15
16# Generate tokentype_string.go
17tokentype-string:
18 go generate
19
20# Format JavaScript files
21format-js:
22 biome format --write cmd/chromad/static/index.js cmd/chromad/static/chroma.js
23
24# Build chromad binary
25chromad: wasm-exec chroma-wasm
26 #!/usr/bin/env bash
27 rm -rf build
28 mk cmd/chromad/static/index.min.js : cmd/chromad/static/{index,chroma}.js -- \
29 esbuild --platform=browser --format=esm --bundle cmd/chromad/static/index.js --minify --external:./wasm_exec.js --outfile=cmd/chromad/static/index.min.js
30 mk cmd/chromad/static/index.min.css : cmd/chromad/static/index.css -- \
31 esbuild --bundle cmd/chromad/static/index.css --minify --outfile=cmd/chromad/static/index.min.css
32 cd cmd/chromad && CGOENABLED=0 go build -ldflags="-X 'main.version={{ version }}'" -o ../../build/chromad .
33
34# Copy wasm_exec.js from TinyGo
35wasm-exec:
36 #!/usr/bin/env bash
37 tinygoroot=$(tinygo env TINYGOROOT)
38 mk cmd/chromad/static/wasm_exec.js : "$tinygoroot/targets/wasm_exec.js" -- \
39 install -m644 "$tinygoroot/targets/wasm_exec.js" cmd/chromad/static/wasm_exec.js
40
41# Build WASM binary
42chroma-wasm:
43 #!/usr/bin/env bash
44 if type tinygo > /dev/null 2>&1; then
45 mk cmd/chromad/static/chroma.wasm : cmd/libchromawasm/main.go -- \
46 tinygo build -no-debug -target wasm -o cmd/chromad/static/chroma.wasm cmd/libchromawasm/main.go
47 else
48 mk cmd/chromad/static/chroma.wasm : cmd/libchromawasm/main.go -- \
49 GOOS=js GOARCH=wasm go build -o cmd/chromad/static/chroma.wasm cmd/libchromawasm/main.go
50 fi
51
52# Upload chromad to server
53upload: chromad
54 scp build/chromad root@swapoff.org:
55 ssh root@swapoff.org 'install -m755 ./chromad /srv/http/swapoff.org/bin && service chromad restart'