carlos / todomvc-bakeoff Public

Clone
git clone https://amadan.net/carlos/todomvc-bakeoff

Plain git — no account needed to clone.

Download

Download this file

1# todo-zig. Zig comes from the repo's scripts/env.sh; every Zig cache is
2# kept under .cache/ so clean-deps can remove compiled artifacts without
3# touching anything outside this directory.
4
5SHELL := bash
6ZIG ?= zig
7VERSION ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo dev)
8
9export ZIG_GLOBAL_CACHE_DIR := $(CURDIR)/.cache/zig
10export ZIG_LOCAL_CACHE_DIR := $(CURDIR)/.cache/zig-local
11export ZIG_LOCAL_PKG_DIR := $(CURDIR)/.cache/pkg
12
13BUILD = $(ZIG) build -Doptimize=ReleaseSafe -Dversion=$(VERSION)
14SRC = build.zig build.zig.zon $(wildcard src/*.zig static/*) ../../shared/base.css ../../shared/index.css
15
16.PHONY: build build-arm64 test clean clean-deps bump unbump deploy
17
18build: $(SRC)
19 $(BUILD) -Dtarget=native-linux-musl --prefix .cache/out-native
20 install -D .cache/out-native/bin/app dist/app
21
22build-arm64: $(SRC)
23 $(BUILD) -Dtarget=aarch64-linux-musl --prefix .cache/out-arm64
24 install -D .cache/out-arm64/bin/app dist/app-linux-arm64
25
26test:
27 $(ZIG) build test -Dtarget=native-linux-musl --summary all
28
29clean:
30 rm -rf dist .cache/out-native .cache/out-arm64
31
32# Keeps the downloaded SQLite sources (.cache/zig/p and .cache/pkg) and
33# drops everything compiled from them.
34clean-deps: clean
35 rm -rf .cache/zig-local .cache/zig/o .cache/zig/h .cache/zig/z .cache/zig/b .cache/zig/tmp
36
37bump:
38 sed -i 's/^const health_body = "ok";$$/const health_body = "ok (bumped)";/' src/app.zig
39
40unbump:
41 sed -i 's/^const health_body = "ok (bumped)";$$/const health_body = "ok";/' src/app.zig
42
43deploy:
44 carlos deploy --account bfj --app todo-zig --target linux-arm64 --version $(VERSION) \
45 --message "$${MESSAGE:-todo-zig $(VERSION)}" dist/app-linux-arm64
46