]> git.lizzy.rs Git - micro.git/blob - Makefile
Fix save with sudo auto-detection and sudo/doas message
[micro.git] / Makefile
1 .PHONY: runtime
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 "$(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 # Builds micro after checking dependencies but without updating the runtime
17 build:
18         go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
19
20 build-dbg:
21         go build -trimpath -ldflags "-s -w $(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro
22
23 build-tags: fetch-tags
24         go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
25
26 # Builds micro after building the runtime and checking dependencies
27 build-all: runtime build
28
29 # Builds micro without checking for dependencies
30 build-quick:
31         go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
32
33 # Same as 'build' but installs to $GOBIN afterward
34 install:
35         go install -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
36
37 # Same as 'build-all' but installs to $GOBIN afterward
38 install-all: runtime install
39
40 # Same as 'build-quick' but installs to $GOBIN afterward
41 install-quick:
42         go install -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)"  ./cmd/micro
43
44 fetch-tags:
45         git fetch --tags
46
47 # Builds the runtime
48 runtime:
49         git submodule update --init
50         rm -f runtime/syntax/*.hdr
51         go run runtime/syntax/make_headers.go runtime/syntax
52         go build -o tools/bindata ./tools/go-bindata
53         tools/bindata -pkg config -nomemcopy -nometadata -o runtime.go runtime/...
54         mv runtime.go internal/config
55         gofmt -w internal/config/runtime.go
56
57 testgen:
58         mkdir -p tools/vscode-tests
59         cd tools/vscode-tests && \
60         curl --remote-name-all $(VSCODE_TESTS_BASE_URL){editableTextModelAuto,editableTextModel,model.line}.test.ts
61         tsc tools/vscode-tests/*.ts > /dev/null; true
62         go run tools/testgen.go tools/vscode-tests/*.js > buffer_generated_test.go
63         mv buffer_generated_test.go internal/buffer
64         gofmt -w internal/buffer/buffer_generated_test.go
65
66 test:
67         go test ./internal/...
68         go test ./cmd/...
69
70 bench:
71         for i in 1 2 3; do \
72                 go test -bench=. ./internal/...; \
73         done > benchmark_results
74         benchstat benchmark_results
75
76 bench-baseline:
77         for i in 1 2 3; do \
78                 go test -bench=. ./internal/...; \
79         done > benchmark_results_baseline
80
81 bench-compare:
82         for i in 1 2 3; do \
83                 go test -bench=. ./internal/...; \
84         done > benchmark_results
85         benchstat -alpha 0.15 benchmark_results_baseline benchmark_results
86
87 clean:
88         rm -f micro