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