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-go: the CARLOS bakeoff's TodoMVC in Go. See README.md.
2
3VERSION ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo dev)
4LDFLAGS := -s -w -X main.version=$(VERSION)
5# make build-arm64 COLD=1 rebuilds every package, dependencies included,
6# without touching the shared GOCACHE.
7GOFLAGS_COLD := $(if $(COLD),-a,)
8
9.PHONY: build build-arm64 test clean clean-deps bump unbump deploy css-check
10
11build: dist/app
12build-arm64: dist/app-linux-arm64
13
14# Both binaries are always handed to `go build`, which decides from its own
15# cache what needs compiling, so a new VERSION or COLD=1 always takes effect.
16dist/app: FORCE
17 CGO_ENABLED=0 go build $(GOFLAGS_COLD) -trimpath -ldflags '$(LDFLAGS)' -o $@ .
18
19dist/app-linux-arm64: FORCE
20 CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(GOFLAGS_COLD) -trimpath -ldflags '$(LDFLAGS)' -o $@ .
21
22FORCE:
23
24test: css-check
25 go vet ./...
26 CGO_ENABLED=0 go test ./...
27
28# The served stylesheets must stay byte-for-byte copies of shared/.
29css-check:
30 cmp ../../shared/base.css web/static/base.css
31 cmp ../../shared/index.css web/static/index.css
32
33clean:
34 rm -rf dist
35
36# Go keeps compiled packages in the shared GOCACHE, which this repo never
37# changes or clears. Downloaded sources stay in the module cache; use
38# `make build-arm64 COLD=1` to force every package to recompile.
39clean-deps: clean
40
41bump:
42 sed -i 's/^const bumpMarker = "steady"$$/const bumpMarker = "bumped"/' web/web.go
43 grep -q '^const bumpMarker = "bumped"$$' web/web.go
44
45unbump:
46 sed -i 's/^const bumpMarker = "bumped"$$/const bumpMarker = "steady"/' web/web.go
47 grep -q '^const bumpMarker = "steady"$$' web/web.go
48
49# Ships the binary `make build-arm64` made; it doesn't rebuild.
50deploy:
51 test -f dist/app-linux-arm64 || { echo 'run make build-arm64 first' >&2; exit 1; }
52 carlos deploy --account bfj --app todo-go --target linux-arm64 --no-prompt \
53 --version $(VERSION) --message "$(or $(MESSAGE),Deploy todo-go $(VERSION))" dist/app-linux-arm64
54