-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (71 loc) · 2.14 KB
/
Copy pathMakefile
File metadata and controls
86 lines (71 loc) · 2.14 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
80
81
82
83
84
85
86
INSTALL_PATH ?= ~/bin
GIT_SHA := $(shell git log -1 --pretty=format:"%H")
LD_FLAGS := "-X github.com/massdriver-cloud/mass/internal/version.version=dev -X github.com/massdriver-cloud/mass/internal/version.gitSHA=local-dev-${GIT_SHA}"
MAKEFLAGS += --no-print-directory
.DEFAULT_GOAL := install
.PHONY: check
check: test lint ## Run tests and linter locally
.PHONY: clean
clean:
rm -rf bin/
.PHONY: docs
docs: build
@OS="$$(uname -s)"; \
if [ "$$OS" = "Darwin" ]; then \
./bin/mass-darwin-arm64 docs; \
elif [ "$$OS" = "Linux" ]; then \
./bin/mass-linux-amd64 docs; \
elif echo "$$OS" | grep -q -E "^(MINGW|MSYS|Windows)"; then \
./bin/mass-windows-amd64.exe docs; \
else \
echo "Unsupported OS: $$OS"; \
exit 1; \
fi
@echo "docs generated"
.PHONY: test
test:
go test ./... -cover
.PHONY: lint
lint:
golangci-lint run
bin:
mkdir bin
.PHONY: build
build:
@if [ "$$(uname -s)" = "Darwin" ]; then \
$(MAKE) build.macos; \
elif [ "$$(uname -s)" = "Linux" ]; then \
$(MAKE) build.linux; \
elif echo "$$(uname -s)" | grep -q -E "^(MINGW|MSYS|Windows)"; then \
$(MAKE) build.windows; \
else \
echo "Error: Unsupported operating system. Please use 'make build.macos', 'make build.linux', or 'make build.windows' directly."; \
exit 1; \
fi
.PHONY: build.macos
build.macos: bin
@CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/mass-darwin-arm64 -ldflags=${LD_FLAGS}
.PHONY: build.linux
build.linux: bin
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/mass-linux-amd64 -ldflags=${LD_FLAGS}
.PHONY: build.windows
build.windows: bin
@CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/mass-windows-amd64.exe -ldflags=${LD_FLAGS}
.PHONY: install.macos
install.macos: build.macos
rm -f ${INSTALL_PATH}/mass
cp bin/mass-darwin-arm64 ${INSTALL_PATH}/mass
.PHONY: install.linux
install.linux: build.linux
cp -f bin/mass-linux-amd64 ${INSTALL_PATH}/mass
.PHONY: install
install: ## Install mass CLI (auto-detects macOS or Linux)
@OS="$$(uname -s)"; \
if [ "$$OS" = "Darwin" ]; then \
$(MAKE) install.macos; \
elif [ "$$OS" = "Linux" ]; then \
$(MAKE) install.linux; \
else \
echo "Unsupported OS: $$OS"; \
exit 1; \
fi