]> git.lizzy.rs Git - micro.git/blob - Makefile
Add buffer test and benchmark suite (and tool to generate it)
[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 GOBIN ?= $(shell go env GOPATH)/bin
11 GOVARS = -X github.com/zyedidia/micro/internal/util.Version=$(VERSION) -X github.com/zyedidia/micro/internal/util.CommitHash=$(HASH) -X 'github.com/zyedidia/micro/internal/util.CompileDate=$(DATE)' -X github.com/zyedidia/micro/internal/util.Debug=OFF
12 VSCODE_TESTS_BASE_URL = 'https://raw.githubusercontent.com/microsoft/vscode/e6a45f4242ebddb7aa9a229f85555e8a3bd987e2/src/vs/editor/test/common/model/'
13
14 # Builds micro after checking dependencies but without updating the runtime
15 build:
16         go build -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
17
18 build-dbg:
19         go build -ldflags "-s -w $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
20
21 build-tags: fetch-tags
22         go build -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
23
24 # Builds micro after building the runtime and checking dependencies
25 build-all: runtime build
26
27 # Builds micro without checking for dependencies
28 build-quick:
29         go build -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
30
31 # Same as 'build' but installs to $GOBIN afterward
32 install:
33         go install -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
34
35 # Same as 'build-all' but installs to $GOBIN afterward
36 install-all: runtime install
37
38 # Same as 'build-quick' but installs to $GOBIN afterward
39 install-quick:
40         go install -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)"  ./cmd/micro
41
42 fetch-tags:
43         git fetch --tags
44
45 # Builds the runtime
46 runtime:
47         git submodule update --init
48         go run runtime/syntax/make_headers.go runtime/syntax
49         go build -o tools/bindata ./tools/go-bindata
50         tools/bindata -pkg config -nomemcopy -nometadata -o runtime.go runtime/...
51         mv runtime.go internal/config
52         gofmt -w internal/config/runtime.go
53
54 testgen:
55         mkdir -p tools/vscode-tests
56         cd tools/vscode-tests && \
57         curl --remote-name-all $(VSCODE_TESTS_BASE_URL){editableTextModelAuto,editableTextModel,model.line}.test.ts
58         tsc tools/vscode-tests/*.ts > /dev/null; true
59         go run tools/testgen.go tools/vscode-tests/*.js > buffer_generated_test.go
60         mv buffer_generated_test.go internal/buffer
61         gofmt -w internal/buffer/buffer_generated_test.go
62
63 test:
64         go test ./internal/...
65
66 bench:
67         go test -bench=. ./internal/...
68
69 clean:
70         rm -f micro