| 📦 Turbo Golo d710c1b k33g 11h ago | 1 | BINARY := turbo-golo |
| 2 | BUILD_DIR := bin |
| 3 | |
| 4 | # The version the binary reports is stamped in by the linker, so that a release |
| 5 | # cannot ship an About box still naming the previous one. git describe gives |
| 6 | # the last tag, how far past it this is, and the commit; a checkout with no |
| 7 | # tags, or no git at all, falls back to "devel". |
| 8 | VERSION_PKG := rickub.com/turbo-editors/turbo-core/version |
| 9 | VERSION := $(shell git describe --tags --dirty 2>/dev/null || echo devel) |
| 10 | COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null) |
| 11 | BUILT := $(shell date -u +%Y-%m-%dT%H:%M:%SZ) |
| 12 | LDFLAGS := -X '$(VERSION_PKG).stamp=$(VERSION)' \ |
| 13 | -X '$(VERSION_PKG).commit=$(COMMIT)' \ |
| 14 | -X '$(VERSION_PKG).built=$(BUILT)' |
| 15 | |
| 16 | .DEFAULT_GOAL := help |
| 17 | |
| 18 | ## help: list the available targets |
| 19 | help: |
| 20 | @grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## //' |
| 21 | |
| 22 | ## test: run the whole test suite |
| 23 | test: |
| 24 | go test ./... |
| 25 | |
| 26 | ## test-verbose: run the whole test suite, naming every test |
| 27 | test-verbose: |
| 28 | go test -v ./... |
| 29 | |
| 30 | ## cover: run the tests and report statement coverage per package |
| 31 | cover: |
| 32 | go test -cover ./... |
| 33 | |
| 34 | ## build: compile the editor into bin/turbo-golo, then check it reports its version |
| 35 | build: |
| 36 | go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY) . |
| 37 | @scripts/check-version.sh $(BUILD_DIR)/$(BINARY) "$(VERSION)" "$(COMMIT)" |
| 38 | |
| 39 | ## version: print the version this checkout would build |
| 40 | version: |
| 41 | @echo "$(VERSION) ($(COMMIT))" |
| 42 | |
| 43 | ## ldflags: print the linker flags a stamped build uses |
| 44 | ## (03-build-releases.sh reads this, so the stamp is defined once) |
| 45 | ldflags: |
| 46 | @printf '%s\n' "$(LDFLAGS)" |
| 47 | |
| 48 | ## install: build and install turbo-golo where your shell can find it |
| 49 | install: |
| 50 | @scripts/install.sh |
| 51 | |
| 52 | ## uninstall: remove an installed turbo-golo |
| 53 | uninstall: |
| 54 | @scripts/install.sh --uninstall |
| 55 | |
| 56 | ## run: build and start the editor (make run FILE=main.golo) |
| 57 | run: build |
| 58 | ./$(BUILD_DIR)/$(BINARY) $(FILE) |
| 59 | |
| 60 | ## fmt: format every Go file in place |
| 61 | fmt: |
| 62 | go fmt ./... |
| 63 | |
| 64 | ## vet: run the standard Go static checks |
| 65 | vet: |
| 66 | go vet ./... |
| 67 | |
| 68 | ## check: format, vet and test — what to run before committing |
| 69 | check: fmt vet test |
| 70 | |
| 71 | ## clean: remove build artefacts |
| 72 | clean: |
| 73 | rm -rf $(BUILD_DIR) |
| 74 | |
| 75 | .PHONY: help test test-verbose cover build version ldflags install uninstall run fmt vet check clean |