Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (45 loc) · 1.99 KB
/
Copy pathMakefile
File metadata and controls
55 lines (45 loc) · 1.99 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
BINARY := mbr
MODULE := github.com/anuragsarkar97/mbr
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -s -w \
-X $(MODULE)/internal/version.Version=$(VERSION) \
-X $(MODULE)/internal/version.Commit=$(COMMIT) \
-X $(MODULE)/internal/version.Date=$(BUILD_DATE)
GOPATH_BIN := $(shell go env GOPATH)/bin
.PHONY: build run test lint clean cross install help
## build: Compile for the current OS/arch → bin/mbr
build:
CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/mbr
## run: Build and launch the TUI
run: build
./bin/$(BINARY)
## test: Run all unit tests with race detector
test:
go test -race -count=1 ./...
## lint: Run golangci-lint (install: brew install golangci-lint)
lint:
golangci-lint run ./...
## cross: Cross-compile for all supported platforms → dist/
cross:
@mkdir -p dist
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o dist/$(BINARY)_linux_amd64 ./cmd/mbr
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o dist/$(BINARY)_linux_arm64 ./cmd/mbr
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o dist/$(BINARY)_darwin_amd64 ./cmd/mbr
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o dist/$(BINARY)_darwin_arm64 ./cmd/mbr
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o dist/$(BINARY)_windows_amd64.exe ./cmd/mbr
@echo "Built binaries:"
@ls -lh dist/
## install: Install to GOPATH/bin
install:
CGO_ENABLED=0 go install -ldflags "$(LDFLAGS)" ./cmd/mbr
## release: Run GoReleaser (requires GITHUB_TOKEN env var)
release:
goreleaser release --clean
## clean: Remove build artifacts
clean:
rm -rf bin/ dist/
## help: Print this help message
help:
@grep -E '^## ' Makefile | sed 's/^## / /'