| Josh Bleecher Snyder | 1c18ec9 | 2025-07-08 10:55:54 -0700 | [diff] [blame] | 1 | # Makefile for building sketch with embedded assets |
| 2 | # |
| 3 | # Two-layer architecture: |
| 4 | # 1. Linux binary ("innie") - runs in container, embeds webui assets |
| 5 | # 2. Native binary ("outie") - runs on user's machine, embeds innie |
| 6 | |
| 7 | BUILD_TIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") |
| 8 | COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo "unknown") |
| 9 | VERSION := $(shell git describe --tags --dirty --always 2>/dev/null || echo "dev") |
| 10 | LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(BUILD_TIME) -X main.makefile=true |
| 11 | |
| 12 | .PHONY: all clean help |
| 13 | .PHONY: outie innie |
| 14 | .PHONY: webui-assets |
| 15 | |
| 16 | all: outie |
| 17 | |
| 18 | outie: innie |
| 19 | go build -ldflags="$(LDFLAGS)" -tags=outie -o sketch ./cmd/sketch |
| 20 | |
| 21 | innie: webui-assets |
| Josh Bleecher Snyder | 5ae245b | 2025-07-08 22:00:24 +0000 | [diff] [blame^] | 22 | CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -tags=innie -o embedded/sketch-linux/sketch-linux-amd64 ./cmd/sketch |
| 23 | CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -tags=innie -o embedded/sketch-linux/sketch-linux-arm64 ./cmd/sketch |
| Josh Bleecher Snyder | 1c18ec9 | 2025-07-08 10:55:54 -0700 | [diff] [blame] | 24 | |
| 25 | webui-assets: |
| 26 | rm -rf embedded/webui-dist |
| 27 | go run ./cmd/genwebui -- embedded/webui-dist |
| 28 | |
| 29 | clean: |
| 30 | @echo "Cleaning build artifacts..." |
| 31 | rm -f sketch |
| 32 | rm -rf embedded/sketch-linux embedded/webui-dist |
| 33 | cd webui && rm -rf node_modules dist |