-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (66 loc) · 2.83 KB
/
Copy pathMakefile
File metadata and controls
79 lines (66 loc) · 2.83 KB
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
77
78
79
# Build, test, and tooling targets for Wave.
# Front-end / Tailwind regen workflow is documented in docs/build.md.
BINARY := wave
PKG := ./cmd/wave
PREFIX ?= $(HOME)/.local
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
# Tailwind standalone CLI (pinned). The compiled CSS is committed under
# internal/webui/static/tailwind.css so plain `go build` works without Node
# or this binary; `make tailwind` regenerates, `make tailwind-check` enforces
# sync in CI. See docs/build.md.
TAILWIND_VERSION := v3.4.17
TAILWIND_OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
TAILWIND_ARCH := $(shell uname -m)
ifeq ($(TAILWIND_ARCH),x86_64)
TAILWIND_ARCH := x64
endif
ifeq ($(TAILWIND_ARCH),aarch64)
TAILWIND_ARCH := arm64
endif
TAILWIND_BIN := tools/tailwindcss-$(TAILWIND_VERSION)-$(TAILWIND_OS)-$(TAILWIND_ARCH)
TAILWIND_URL := https://github.com/tailwindlabs/tailwindcss/releases/download/$(TAILWIND_VERSION)/tailwindcss-$(TAILWIND_OS)-$(TAILWIND_ARCH)
TAILWIND_INPUT := internal/webui/tailwind.input.css
TAILWIND_OUTPUT := internal/webui/static/tailwind.css
TAILWIND_CONFIG := internal/webui/tailwind.config.js
.PHONY: build install test coverage lint clean tailwind tailwind-check
# NOTE: Running `go build ./cmd/wave` directly will produce a binary that
# reports version as "dev". Always use `make build` or pass ldflags manually:
# go build -ldflags "-X main.version=... -X main.commit=... -X main.date=..." ./cmd/wave
build:
go build -ldflags "$(LDFLAGS)" -o $(BINARY) $(PKG)
install: build
install -d $(PREFIX)/bin
cp -f $(BINARY) $(PREFIX)/bin/$(BINARY)
chmod 755 $(PREFIX)/bin/$(BINARY)
test:
go test -race ./...
coverage:
go test -race -coverprofile=coverage.out ./...
go tool cover -func=coverage.out | tail -n 1
lint:
golangci-lint run ./...
clean:
rm -f $(BINARY)
# Download the pinned standalone Tailwind CLI binary into tools/ if missing.
$(TAILWIND_BIN):
@mkdir -p tools
@echo "Downloading Tailwind CLI $(TAILWIND_VERSION) for $(TAILWIND_OS)-$(TAILWIND_ARCH)..."
@curl -fsSL -o $(TAILWIND_BIN) $(TAILWIND_URL)
@chmod +x $(TAILWIND_BIN)
# Compile internal/webui/static/tailwind.css from the templates content scan.
# The output is committed; CI runs `tailwind-check` to enforce sync.
tailwind: $(TAILWIND_BIN)
cd internal/webui && ../../$(TAILWIND_BIN) \
--config tailwind.config.js \
--input tailwind.input.css \
--output static/tailwind.css \
--minify
# Regenerate and fail if the committed CSS drifts from templates.
tailwind-check: tailwind
@git diff --exit-code -- $(TAILWIND_OUTPUT) || { \
echo "ERROR: $(TAILWIND_OUTPUT) is out of sync. Run 'make tailwind' and commit."; \
exit 1; \
}