blob: 088cbf07bcf585c713833e773b28387c71cd4065 [file] [log] [blame]
Josh Bleecher Snyder1c18ec92025-07-08 10:55:54 -07001# 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
7BUILD_TIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
8COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
9VERSION := $(shell git describe --tags --dirty --always 2>/dev/null || echo "dev")
10LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(BUILD_TIME) -X main.makefile=true
11
Josh Bleecher Snyder973413b2025-07-08 19:35:05 +000012# Support for cross-compilation, used by GoReleaser
13GOOS ?= $(shell go env GOOS)
14GOARCH ?= $(shell go env GOARCH)
15
Josh Bleecher Snyder1c18ec92025-07-08 10:55:54 -070016.PHONY: all clean help
17.PHONY: outie innie
18.PHONY: webui-assets
19
20all: outie
21
22outie: innie
Josh Bleecher Snyder973413b2025-07-08 19:35:05 +000023 # Note: This incantation is duplicated in .goreleaser.yml; please keep them in sync.
24 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags="$(LDFLAGS)" -tags=outie -o sketch ./cmd/sketch
Josh Bleecher Snyder1c18ec92025-07-08 10:55:54 -070025
26innie: webui-assets
Josh Bleecher Snyder5ae245b2025-07-08 22:00:24 +000027 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -tags=innie -o embedded/sketch-linux/sketch-linux-amd64 ./cmd/sketch
28 CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -tags=innie -o embedded/sketch-linux/sketch-linux-arm64 ./cmd/sketch
Josh Bleecher Snyder1c18ec92025-07-08 10:55:54 -070029
30webui-assets:
31 rm -rf embedded/webui-dist
Josh Bleecher Snyder973413b2025-07-08 19:35:05 +000032 unset GOOS GOARCH && go run ./cmd/genwebui -- embedded/webui-dist
Josh Bleecher Snyder1c18ec92025-07-08 10:55:54 -070033
34clean:
35 @echo "Cleaning build artifacts..."
36 rm -f sketch
37 rm -rf embedded/sketch-linux embedded/webui-dist
38 cd webui && rm -rf node_modules dist