| 1 | VERSION := $(shell git describe --tags --always 2>/dev/null || echo dev) |
| 2 | BUILD_TIME_UTC := $(shell date -u +%Y-%m-%dT%H:%M:%SZ) |
| 3 | GIT_COMMIT := $(shell git rev-parse --short=12 HEAD 2>/dev/null || echo unknown) |
| 4 | LDFLAGS := -s -w \ |
| 5 | -X main.version=$(VERSION) \ |
| 6 | -X main.gitCommit=$(GIT_COMMIT) \ |
| 7 | -X main.buildTimeUTC=$(BUILD_TIME_UTC) |
| 8 | GOEXE := $(shell go env GOEXE) |
| 9 | |
| 10 | .PHONY: build vet fmt test desktop-test desktop-test-short desktop-test-times sdk-test sdk-test-race hooks cross clean |
| 11 | |
| 12 | build: |
| 13 | CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o bin/reasonix$(GOEXE) ./cmd/reasonix |
| 14 | CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o bin/reasonix-plugin-example$(GOEXE) ./cmd/reasonix-plugin-example |
| 15 | |
| 16 | vet: |
| 17 | go vet ./... |
| 18 | |
| 19 | fmt: |
| 20 | gofmt -w . |
| 21 | |
| 22 | test: |
| 23 | go test ./... |
| 24 | |
| 25 | desktop-test: |
| 26 | cd desktop && go test . |
| 27 | |
| 28 | desktop-test-short: |
| 29 | cd desktop && go test -short . |
| 30 | |
| 31 | desktop-test-times: |
| 32 | cd desktop && go test -count=1 -json . | python3 ../scripts/desktop-test-times.py |
| 33 | |
| 34 | sdk-test: |
| 35 | cd sdk/go && go test ./... |
| 36 | |
| 37 | sdk-test-race: |
| 38 | cd sdk/go && go test -race ./... |
| 39 | |
| 40 | hooks: |
| 41 | @git config core.hooksPath .githooks |
| 42 | @echo "installed: core.hooksPath -> .githooks (pre-push runs go vet)" |
| 43 | |
| 44 | cross: |
| 45 | @mkdir -p dist |
| 46 | @for p in darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64 windows/arm64; do \ |
| 47 | os=$${p%/*}; arch=$${p#*/}; ext=; [ $$os = windows ] && ext=.exe; \ |
| 48 | echo "build $$os/$$arch"; \ |
| 49 | CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -ldflags "$(LDFLAGS)" -o dist/reasonix-$$os-$$arch$$ext ./cmd/reasonix; \ |
| 50 | done |
| 51 | |
| 52 | clean: |
| 53 | rm -rf bin dist |
| 54 |