Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (85 loc) · 4.08 KB
/
Copy pathMakefile
File metadata and controls
111 lines (85 loc) · 4.08 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
VERSION ?= dev
BINARY := neo
IMAGE ?= vxero/neo
GO_IMAGE ?= golang:1.24-alpine
DEV_LICENSE_BYPASS ?= false
# Staging base URL — every endpoint derives from this single value.
# Override via env: make build-staging STAGING_BASE_URL=https://your-host
STAGING_BASE_URL ?= https://neo-staging.vxero.dev
# Auto-detect staging: if VERSION contains "-staging", bake in the staging base URL.
ifneq (,$(findstring -staging,$(VERSION)))
LDFLAGS := -s -w -X main.version=$(VERSION) \
-X github.com/vxero/neo/internal/config.DefaultBaseURL=$(STAGING_BASE_URL)
else
LDFLAGS := -s -w -X main.version=$(VERSION) \
-X github.com/vxero/neo/internal/license.DevLicenseBypass=$(DEV_LICENSE_BYPASS)
endif
HOSTOS ?= $(shell uname -s | sed -e 's/Darwin/darwin/' -e 's/Linux/linux/' -e 's/MINGW.*/windows/' -e 's/MSYS.*/windows/' -e 's/CYGWIN.*/windows/')
HOSTARCH ?= $(shell uname -m | sed -e 's/x86_64/amd64/' -e 's/amd64/amd64/' -e 's/arm64/arm64/' -e 's/aarch64/arm64/')
.PHONY: build build-dev build-staging build-all release-local build-neotest build-sandbox-test install clean test fmt docker-build docker-run image-build sandbox
DOCKER_GO = docker run --rm -v "$(CURDIR):/src" -w /src $(GO_IMAGE)
GO_BIN = /usr/local/go/bin/go
build:
@mkdir -p bin
$(DOCKER_GO) sh -c '$(GO_BIN) mod download && CGO_ENABLED=0 GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO_BIN) build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/neo'
build-dev:
$(MAKE) build VERSION=dev-local DEV_LICENSE_BYPASS=true
build-staging:
$(MAKE) build VERSION=$(VERSION)-staging BINARY=$(BINARY)-staging
build-all:
@mkdir -p dist
$(DOCKER_GO) sh -c '$(GO_BIN) mod download && \
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GO_BIN) build -ldflags "$(LDFLAGS)" -o dist/$(BINARY)-darwin-arm64 ./cmd/neo && \
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO_BIN) build -ldflags "$(LDFLAGS)" -o dist/$(BINARY)-darwin-amd64 ./cmd/neo && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO_BIN) build -ldflags "$(LDFLAGS)" -o dist/$(BINARY)-linux-amd64 ./cmd/neo && \
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO_BIN) build -ldflags "$(LDFLAGS)" -o dist/$(BINARY)-linux-arm64 ./cmd/neo && \
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GO_BIN) build -ldflags "$(LDFLAGS)" -o dist/$(BINARY)-windows-amd64.exe ./cmd/neo'
# Mirror the release CI (build neo-builder image → test → build all platforms →
# verify) locally, so failures are caught before pushing a version tag.
release-local:
scripts/release-local.sh $(VERSION)
clean:
rm -rf bin dist
test:
go test ./...
# Race detector. The dashboard reads the server cache on the main goroutine
# while background goroutines refresh it, so run this before touching either.
test-race:
go test -race ./...
fmt:
gofmt -w .
docker-build: image-build
image-build:
docker build -f Dockerfile.runtime --build-arg VERSION=$(VERSION) -t $(IMAGE):$(VERSION) -t $(IMAGE):latest .
install: build
sudo cp bin/$(BINARY) /usr/local/bin/$(BINARY)
@echo " Installed neo to /usr/local/bin/neo"
build-neotest:
@mkdir -p bin
$(DOCKER_GO) sh -c '$(GO_BIN) mod download && CGO_ENABLED=0 GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO_BIN) build -ldflags "$(LDFLAGS)" -o bin/neotest ./cmd/neotest'
build-sandbox-test:
@mkdir -p bin
$(DOCKER_GO) sh -c '$(GO_BIN) mod download && CGO_ENABLED=0 GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO_BIN) build -ldflags "$(LDFLAGS)" -o bin/neo-sandbox-test ./cmd/neosandbox'
sandbox: build build-sandbox-test
./test/sandbox/run-tests.sh
sandbox-supported: build build-sandbox-test
./test/sandbox/run-tests.sh --supported
sandbox-unsupported: build build-sandbox-test
./test/sandbox/run-tests.sh --unsupported
sandbox-distro: build build-sandbox-test
@test -n "$(DISTRO)" || (echo "Usage: make sandbox-distro DISTRO=ubuntu-24.04" && exit 1)
./test/sandbox/run-tests.sh --distro $(DISTRO)
sandbox-keep: build build-sandbox-test
./test/sandbox/run-tests.sh --keep
sandbox-down:
./test/sandbox/run-tests.sh --down
sandbox-list:
@./test/sandbox/run-tests.sh --list
docker-run:
mkdir -p $$HOME/.neo
docker run --rm -it \
-v $$HOME/.ssh:/root/.ssh:ro \
-v $$HOME/.neo:/root/.neo \
-v $$PWD:/workspace \
-w /workspace \
$(IMAGE):latest