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
|
BINARY := turbo-js
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-js, 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-js where your shell can find it
install:
@scripts/install.sh
## uninstall: remove an installed turbo-js
uninstall:
@scripts/install.sh --uninstall
## run: build and start the editor (make run FILE=main.js)
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
|