BINARY := turbo-python BUILD_DIR := bin # The version the binary reports is stamped in by the linker, so that a release # cannot ship an About box still naming the previous one. git describe gives # the last tag, how far past it this is, and the commit; a checkout with no # tags, or no git at all, falls back to "devel". VERSION_PKG := rickub.com/turbo-editors/turbo-core/version VERSION := $(shell git describe --tags --dirty 2>/dev/null || echo devel) COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null) BUILT := $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -X '$(VERSION_PKG).stamp=$(VERSION)' \ -X '$(VERSION_PKG).commit=$(COMMIT)' \ -X '$(VERSION_PKG).built=$(BUILT)' .DEFAULT_GOAL := help ## help: list the available targets help: @grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## //' ## test: run the whole test suite test: go test ./... ## test-verbose: run the whole test suite, naming every test test-verbose: go test -v ./... ## cover: run the tests and report statement coverage per package cover: go test -cover ./... ## build: compile the editor into bin/turbo-python, then check it reports its version build: go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY) . @scripts/check-version.sh $(BUILD_DIR)/$(BINARY) "$(VERSION)" "$(COMMIT)" ## version: print the version this checkout would build version: @echo "$(VERSION) ($(COMMIT))" ## ldflags: print the linker flags a stamped build uses ## (03-build-releases.sh reads this, so the stamp is defined once) ldflags: @printf '%s\n' "$(LDFLAGS)" ## install: build and install turbo-python where your shell can find it install: @scripts/install.sh ## uninstall: remove an installed turbo-python uninstall: @scripts/install.sh --uninstall ## run: build and start the editor (make run FILE=main.go) run: build ./$(BUILD_DIR)/$(BINARY) $(FILE) ## fmt: format every Go file in place fmt: go fmt ./... ## vet: run the standard Go static checks vet: go vet ./... ## check: format, vet and test — what to run before committing check: fmt vet test ## clean: remove build artefacts clean: rm -rf $(BUILD_DIR) .PHONY: help test test-verbose cover build version ldflags install uninstall run fmt vet check clean