]> git.lizzy.rs Git - micro.git/blob - Makefile
Add autoretab
[micro.git] / Makefile
1 .PHONY: runtime build generate build-quick
2
3 VERSION = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) \
4         go run tools/build-version.go)
5 HASH = $(shell git rev-parse --short HEAD)
6 DATE = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) \
7         go run tools/build-date.go)
8 ADDITIONAL_GO_LINKER_FLAGS = $(shell GOOS=$(shell go env GOHOSTOS) \
9         GOARCH=$(shell go env GOHOSTARCH) \
10         go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)")
11 GOBIN ?= $(shell go env GOPATH)/bin
12 GOVARS = -X github.com/zyedidia/micro/v2/internal/util.Version=$(VERSION) -X github.com/zyedidia/micro/v2/internal/util.CommitHash=$(HASH) -X 'github.com/zyedidia/micro/v2/internal/util.CompileDate=$(DATE)'
13 DEBUGVAR = -X github.com/zyedidia/micro/v2/internal/util.Debug=ON
14 VSCODE_TESTS_BASE_URL = 'https://raw.githubusercontent.com/microsoft/vscode/e6a45f4242ebddb7aa9a229f85555e8a3bd987e2/src/vs/editor/test/common/model/'
15
16 build: generate build-quick
17
18 build-quick:
19         go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
20
21 build-dbg:
22         go build -trimpath -ldflags "-s -w $(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro
23
24 build-tags: fetch-tags generate
25         go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
26
27 build-all: build
28
29 install: generate
30         go install -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
31
32 install-all: install
33
34 fetch-tags:
35         git fetch --tags
36
37 generate:
38         GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) go generate ./runtime
39
40 testgen:
41         mkdir -p tools/vscode-tests
42         cd tools/vscode-tests && \
43         curl --remote-name-all $(VSCODE_TESTS_BASE_URL){editableTextModelAuto,editableTextModel,model.line}.test.ts
44         tsc tools/vscode-tests/*.ts > /dev/null; true
45         go run tools/testgen.go tools/vscode-tests/*.js > buffer_generated_test.go
46         mv buffer_generated_test.go internal/buffer
47         gofmt -w internal/buffer/buffer_generated_test.go
48
49 test:
50         go test ./internal/...
51         go test ./cmd/...
52
53 bench:
54         for i in 1 2 3; do \
55                 go test -bench=. ./internal/...; \
56         done > benchmark_results
57         benchstat benchmark_results
58
59 bench-baseline:
60         for i in 1 2 3; do \
61                 go test -bench=. ./internal/...; \
62         done > benchmark_results_baseline
63
64 bench-compare:
65         for i in 1 2 3; do \
66                 go test -bench=. ./internal/...; \
67         done > benchmark_results
68         benchstat -alpha 0.15 benchmark_results_baseline benchmark_results
69
70 clean:
71         rm -f micro