2019-11-28 11:25:49 +11:00
|
|
|
.PHONY: chromad upload all
|
|
|
|
|
|
2021-04-25 08:25:30 +10:00
|
|
|
VERSION ?= $(shell git describe --tags --dirty --always)
|
2023-01-11 14:43:47 -05:00
|
|
|
export GOOS ?= linux
|
|
|
|
|
export GOARCH ?= amd64
|
2021-04-25 08:25:30 +10:00
|
|
|
|
2019-11-28 11:25:49 +11:00
|
|
|
all: README.md tokentype_string.go
|
|
|
|
|
|
2025-07-28 11:24:55 +10:00
|
|
|
README.md: lexers/*.go lexers/embedded/*.xml
|
|
|
|
|
GOOS= GOARCH= ./table.py
|
2019-11-28 11:25:49 +11:00
|
|
|
|
|
|
|
|
tokentype_string.go: types.go
|
|
|
|
|
go generate
|
|
|
|
|
|
2025-07-01 10:16:32 +10:00
|
|
|
.PHONY: format-js
|
|
|
|
|
format-js:
|
|
|
|
|
biome format --write cmd/chromad/static/{index.js,chroma.js}
|
|
|
|
|
|
2025-04-03 20:47:45 +11:00
|
|
|
.PHONY: chromad
|
|
|
|
|
chromad: build/chromad
|
|
|
|
|
|
2025-06-30 15:31:55 +10:00
|
|
|
build/chromad: $(shell find cmd/chromad -name '*.go' -o -name '*.html' -o -name '*.css' -o -name '*.js') \
|
|
|
|
|
cmd/chromad/static/wasm_exec.js \
|
|
|
|
|
cmd/chromad/static/chroma.wasm
|
2023-09-09 13:07:35 +10:00
|
|
|
rm -rf build
|
2025-06-30 15:31:55 +10:00
|
|
|
esbuild --platform=node --bundle cmd/chromad/static/index.js --minify --outfile=cmd/chromad/static/index.min.js
|
2023-01-11 14:43:47 -05:00
|
|
|
esbuild --bundle cmd/chromad/static/index.css --minify --outfile=cmd/chromad/static/index.min.css
|
2025-04-03 20:47:45 +11:00
|
|
|
(export CGOENABLED=0 ; go build -C cmd/chromad -ldflags="-X 'main.version=$(VERSION)'" -o ../../build/chromad .)
|
2019-11-28 11:25:49 +11:00
|
|
|
|
2025-06-30 15:31:55 +10:00
|
|
|
cmd/chromad/static/wasm_exec.js: $(shell tinygo env TINYGOROOT)/targets/wasm_exec.js
|
|
|
|
|
install -m644 $< $@
|
|
|
|
|
|
2025-07-28 11:24:55 +10:00
|
|
|
cmd/chromad/static/chroma.wasm: $(shell git ls-files | grep '\.go|\.xml')
|
|
|
|
|
if type tinygo > /dev/null; then \
|
|
|
|
|
tinygo build -no-debug -target wasm -o $@ cmd/libchromawasm/main.go; \
|
|
|
|
|
else \
|
|
|
|
|
GOOS=js GOARCH=wasm go build -o $@ cmd/libchromawasm/main.go; \
|
|
|
|
|
fi
|
2025-06-30 15:31:55 +10:00
|
|
|
|
2023-09-09 13:07:35 +10:00
|
|
|
upload: build/chromad
|
|
|
|
|
scp build/chromad root@swapoff.org: && \
|
2019-11-28 11:25:49 +11:00
|
|
|
ssh root@swapoff.org 'install -m755 ./chromad /srv/http/swapoff.org/bin && service chromad restart'
|