-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
181 lines (142 loc) · 5.31 KB
/
Copy pathMakefile
File metadata and controls
181 lines (142 loc) · 5.31 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
GO ?= go
NPM ?= npm
NODE ?= node
PYTHON ?= python3
BINARY := editpro
MODULE := github.com/startvibecoding/editpro
VERSION ?= $(or $(shell git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//'),0.1.0)
PRE_VERSION ?= $(VERSION)-next.0
GOFLAGS := -trimpath
LDFLAGS := -ldflags "-s -w -X main.version=$(VERSION)"
BIN_DIR := bin
DIST_DIR := dist
PYPI_VENV := $(CURDIR)/pypi/.venv-build
PYPI_PYTHON := $(PYPI_VENV)/bin/python
.PHONY: help all build install test race fuzz vet fmt check bench clean clean-all
.PHONY: build-all build-linux build-darwin build-windows build-freebsd build-openbsd build-netbsd
.PHONY: dist checksums
.PHONY: npm-version npm-packages npm-pack npm-publish npm-publish-pre
.PHONY: pypi-bootstrap pypi-version pypi-packages pypi-pack pypi-check pypi-publish pypi-publish-pre
help:
@echo "EditPro build and release targets"
@echo ""
@echo "Development:"
@echo " build Build for the current platform"
@echo " test Run unit tests"
@echo " race Run tests with the race detector"
@echo " fuzz Run replacement fuzzing (FUZZTIME=10s)"
@echo " check Format check, tests, and go vet"
@echo ""
@echo "Cross compilation:"
@echo " build-all Build every supported release target"
@echo " build-linux linux: amd64 arm64 loong64 ppc64le s390x riscv64"
@echo " build-darwin macOS: amd64 arm64"
@echo " build-windows Windows: amd64 arm64"
@echo " build-freebsd FreeBSD: amd64 arm64"
@echo " build-openbsd OpenBSD: amd64 arm64"
@echo " build-netbsd NetBSD: amd64"
@echo " dist Create tar.gz/zip archives and checksums"
@echo ""
@echo "npm:"
@echo " npm-pack Build and locally pack all npm packages"
@echo " npm-publish Publish VERSION with the latest tag"
@echo " npm-publish-pre Publish PRE_VERSION with the next tag"
@echo ""
@echo "PyPI:"
@echo " pypi-pack Build all supported platform wheels"
@echo " pypi-check Validate built wheels with twine"
@echo " pypi-publish Publish VERSION wheels"
@echo " pypi-publish-pre Publish PRE_VERSION wheels"
@echo ""
@echo "Set VERSION=x.y.z explicitly for a release. Current: $(VERSION)"
all: check build
build:
@mkdir -p $(BIN_DIR)
CGO_ENABLED=0 $(GO) build $(GOFLAGS) $(LDFLAGS) -o $(BIN_DIR)/$(BINARY) ./cmd/editpro
install:
CGO_ENABLED=0 $(GO) install $(GOFLAGS) $(LDFLAGS) ./cmd/editpro
test:
$(GO) test ./...
race:
$(GO) test -race ./...
FUZZTIME ?= 10s
fuzz:
$(GO) test -run '^$$' -fuzz FuzzReplaceMatchesStandardLibrary -fuzztime=$(FUZZTIME) .
vet:
$(GO) vet ./...
fmt:
gofmt -w $$(find . -name '*.go' -not -path './pypi/build/*')
check:
@test -z "$$(gofmt -l $$(find . -name '*.go' -not -path './pypi/build/*'))" || \
(echo "Go files need formatting; run make fmt" >&2; exit 1)
$(GO) test ./...
$(GO) vet ./...
bench:
$(GO) test -run '^$$' -bench . -benchmem ./...
define build_target
@mkdir -p $(BIN_DIR)
CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) $(GO) build $(GOFLAGS) $(LDFLAGS) -o $(BIN_DIR)/$(BINARY)-$(1)-$(2)$(3) ./cmd/editpro
endef
build-linux:
$(call build_target,linux,amd64,)
$(call build_target,linux,arm64,)
$(call build_target,linux,loong64,)
$(call build_target,linux,ppc64le,)
$(call build_target,linux,s390x,)
$(call build_target,linux,riscv64,)
build-darwin:
$(call build_target,darwin,amd64,)
$(call build_target,darwin,arm64,)
build-windows:
$(call build_target,windows,amd64,.exe)
$(call build_target,windows,arm64,.exe)
build-freebsd:
$(call build_target,freebsd,amd64,)
$(call build_target,freebsd,arm64,)
build-openbsd:
$(call build_target,openbsd,amd64,)
$(call build_target,openbsd,arm64,)
build-netbsd:
$(call build_target,netbsd,amd64,)
build-all: build-linux build-darwin build-windows build-freebsd build-openbsd build-netbsd
@echo "Built release binaries in $(BIN_DIR)/"
dist: build-all
./scripts/package-release.sh $(VERSION)
checksums:
./scripts/checksums.sh $(DIST_DIR)
npm-version:
$(NODE) ./scripts/sync-npm-version.js $(VERSION)
npm-packages: build-all npm-version
$(NODE) ./scripts/build-npm-packages.js
npm-pack: npm-packages
./scripts/npm-pack.sh
npm-publish: npm-packages
NPM=$(NPM) $(NODE) ./scripts/npm-publish.js latest
npm-publish-pre:
$(NODE) ./scripts/sync-npm-version.js $(PRE_VERSION)
$(MAKE) build-all VERSION=$(PRE_VERSION)
$(NODE) ./scripts/build-npm-packages.js
NPM=$(NPM) $(NODE) ./scripts/npm-publish.js next
$(PYPI_PYTHON):
$(PYTHON) -m venv $(PYPI_VENV)
$(PYPI_VENV)/bin/pip install --upgrade "setuptools>=77" build twine
pypi-bootstrap: $(PYPI_PYTHON)
pypi-version: $(PYPI_PYTHON)
PYTHON=$(PYPI_PYTHON) ./scripts/sync-pypi-version.sh $(VERSION)
pypi-packages: build-all pypi-version
PYTHON=$(PYPI_PYTHON) ./scripts/build-pypi-packages.sh
pypi-pack: pypi-packages
pypi-check: pypi-pack
$(PYPI_PYTHON) -m twine check pypi/dist/*.whl
pypi-publish: pypi-check
$(PYPI_PYTHON) -m twine upload pypi/dist/*.whl
pypi-publish-pre: $(PYPI_PYTHON)
PYTHON=$(PYPI_PYTHON) ./scripts/sync-pypi-version.sh $(PRE_VERSION)
$(MAKE) build-all VERSION=$(PRE_VERSION)
PYTHON=$(PYPI_PYTHON) ./scripts/build-pypi-packages.sh
$(PYPI_PYTHON) -m twine check pypi/dist/*.whl
$(PYPI_PYTHON) -m twine upload pypi/dist/*.whl
clean:
rm -rf $(BIN_DIR) $(DIST_DIR) npm/packages npm/*.tgz pypi/build pypi/dist
clean-all: clean
rm -rf $(PYPI_VENV)