-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (46 loc) · 1.81 KB
/
Copy pathMakefile
File metadata and controls
60 lines (46 loc) · 1.81 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
# m-cli — the cross-engine M toolchain (the `m` busybox). Inherits the shared
# go-cli-template conventions: static (CGO_ENABLED=0), -trimpath, version
# stamped via -ldflags, cross-compile matrix, lint, test, schema.
BIN ?= m
PKG := github.com/vista-cloud-dev/m-cli
LDPKG := $(PKG)/clikit
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-%d)
LDFLAGS := -s -w -X $(LDPKG).Version=$(VERSION) -X $(LDPKG).Commit=$(COMMIT) -X $(LDPKG).Date=$(DATE)
# Static, no-libc, reproducible (spec §10).
GOFLAGS := -trimpath
export CGO_ENABLED := 0
PLATFORMS := linux/amd64 linux/arm64 darwin/arm64 windows/amd64
.PHONY: all build run lint test tidy schema dist clean arch
all: lint test build arch
build:
go build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o dist/$(BIN) .
# m/v waterline G1 gate (dependency-direction). This repo is layer m
# (repo.meta.json); the gate fails the build on any m → v dependency.
arch: build
./dist/$(BIN) arch check .
run: build
./dist/$(BIN) $(ARGS)
lint:
golangci-lint run ./...
# The race detector needs CGO; the rest of the build is CGO-free (the wazero
# parse substrate is pure Go). Override the file-level CGO_ENABLED=0 just here.
test:
CGO_ENABLED=1 go test $(GOFLAGS) -race -cover ./...
tidy:
go mod tidy
# Emit the machine schema (the §5.5 contract) — also a CI conformance artifact.
schema: build
./dist/$(BIN) schema
# Cross-compile the pinned matrix into dist/.
dist:
@mkdir -p dist
@for p in $(PLATFORMS); do \
os=$${p%/*}; arch=$${p#*/}; ext=""; [ "$$os" = "windows" ] && ext=".exe"; \
echo " $$os/$$arch"; \
GOOS=$$os GOARCH=$$arch go build $(GOFLAGS) -ldflags "$(LDFLAGS)" \
-o dist/$(BIN)-$$os-$$arch$$ext . ; \
done
clean:
rm -rf dist