-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (64 loc) · 2.86 KB
/
Copy pathMakefile
File metadata and controls
76 lines (64 loc) · 2.86 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
.DEFAULT_GOAL := help
.PHONY: setup-dev upgrade pre-commit test render install uninstall reinstall clean help
# Identity derived from the cmd/<name> layout.
BINARY := $(notdir $(CURDIR))
PKG := ./cmd/$(BINARY)
VERSION := $(patsubst v%,%,$(shell git describe --tags --always --dirty 2>/dev/null || echo dev))
LDFLAGS := -s -w -X main.version=$(VERSION)
GOBIN := $(or $(shell go env GOBIN),$(shell go env GOPATH)/bin)
EXE := $(GOBIN)/$(BINARY)$(shell go env GOEXE)
# Where the macOS .pkg, plus the receipt it registers
PKGID := com.lucuma13.$(BINARY)
PKGEXE := /usr/local/bin/$(BINARY)
setup-dev: ## Install dev pre-requisites (Go, pre-commit)
ifeq ($(OS),Windows_NT)
powershell -NoProfile -ExecutionPolicy Bypass -Command "winget install -e --silent --accept-package-agreements --accept-source-agreements GoLang.Go astral-sh.uv; $$env:Path = [Environment]::GetEnvironmentVariable('Path','Machine') + ';' + [Environment]::GetEnvironmentVariable('Path','User'); uv tool install pre-commit; uv tool update-shell; uv tool run pre-commit install"
else ifeq ($(shell uname -s),Darwin)
brew install go pre-commit
pre-commit install
else
sudo apt-get install -y golang-go pre-commit
pre-commit install
endif
upgrade: ## Upgrade dependencies
go get -u ./...
go mod tidy
pre-commit: ## Run all pre-commit hooks
pre-commit run --all-files
test: ## Run the test suite
go test -coverprofile=coverage.out -covermode=atomic ./...
render: ## Regenerate the committed artwork (icons, banner, social preview, demo animation)
./scripts/render/icons.sh
./scripts/render/artwork.sh
swift ./scripts/render/demo_animation.swift
install: ## Install to $GOBIN and integrate the right-click action (macOS/Windows)
go install -trimpath -ldflags '$(LDFLAGS)' $(PKG)
@case "$$(uname -s)" in \
Darwin|MINGW*|MSYS*|CYGWIN*) "$(EXE)" integrate on ;; \
*) echo "integrate: skipped (only macOS and Windows are supported)" ;; \
esac
uninstall: ## Remove the installed binaries ($GOBIN and .pkg) and the right-click integration
@case "$$(uname -s)" in \
Darwin|MINGW*|MSYS*|CYGWIN*) \
for b in "$(EXE)" "$(PKGEXE)"; do \
if [ -x "$$b" ]; then "$$b" integrate off || true; break; fi; \
done ;; \
esac
rm -f "$(EXE)"
@case "$$(uname -s)" in \
Darwin) \
if [ -e "$(PKGEXE)" ] || pkgutil --pkg-info $(PKGID) >/dev/null 2>&1; then \
echo "Removing the .pkg-installed copy at $(PKGEXE) (needs sudo)."; \
sudo rm -f "$(PKGEXE)" "/usr/local/bin/._$(BINARY)"; \
sudo pkgutil --forget $(PKGID) >/dev/null 2>&1 || true; \
fi ;; \
esac
reinstall: ## Uninstall any previous copy, then install fresh
$(MAKE) uninstall
$(MAKE) install
clean: ## Remove build artifacts
rm -f $(BINARY) coverage.out
rm -rf dist
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-11s\033[0m %s\n", $$1, $$2}'