| 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 |
GOBIN ?= $(shell go env GOPATH)/bin |
| 9 |
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)' |
| 10 |
DEBUGVAR = -X github.com/zyedidia/micro/v2/internal/util.Debug=ON |
| 11 |
VSCODE_TESTS_BASE_URL = 'https://raw.githubusercontent.com/microsoft/vscode/e6a45f4242ebddb7aa9a229f85555e8a3bd987e2/src/vs/editor/test/common/model/' |
| 12 |
CGO_ENABLED := $(if $(CGO_ENABLED),$(CGO_ENABLED),0) |
| 13 |
|
| 14 |
ADDITIONAL_GO_LINKER_FLAGS := "" |
| 15 |
GOHOSTOS = $(shell go env GOHOSTOS) |
| 16 |
ifeq ($(GOHOSTOS), darwin) |
| 17 |
# Native darwin resp. macOS builds need external and dynamic linking |
| 18 |
ADDITIONAL_GO_LINKER_FLAGS += $(shell GOOS=$(GOHOSTOS) \ |
| 19 |
GOARCH=$(shell go env GOHOSTARCH) \ |
| 20 |
go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)") |
| 21 |
CGO_ENABLED = 1 |
| 22 |
endif |
| 23 |
|
| 24 |
build: generate build-quick |
| 25 |
|
| 26 |
build-quick: |
| 27 |
CGO_ENABLED=$(CGO_ENABLED) go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro |
| 28 |
|
| 29 |
build-dbg: |
| 30 |
CGO_ENABLED=$(CGO_ENABLED) go build -trimpath -ldflags "$(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro |
| 31 |
|
| 32 |
build-tags: fetch-tags build |
| 33 |
|
| 34 |
build-all: build |
| 35 |
|
| 36 |
install: generate |
| 37 |
go install -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro |
| 38 |
|
| 39 |
install-all: install |
| 40 |
|
| 41 |
fetch-tags: |
| 42 |
git fetch --tags --force |
| 43 |
|
| 44 |
generate: |
| 45 |
GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) go generate ./runtime |
| 46 |
|
| 47 |
testgen: |
| 48 |
mkdir -p tools/vscode-tests |
| 49 |
cd tools/vscode-tests && \ |
| 50 |
curl --remote-name-all $(VSCODE_TESTS_BASE_URL){editableTextModelAuto,editableTextModel,model.line}.test.ts |
| 51 |
tsc tools/vscode-tests/*.ts > /dev/null; true |
| 52 |
go run tools/testgen.go tools/vscode-tests/*.js > buffer_generated_test.go |
| 53 |
mv buffer_generated_test.go internal/buffer |
| 54 |
gofmt -w internal/buffer/buffer_generated_test.go |
| 55 |
|
| 56 |
test: |
| 57 |
go test ./internal/... |
| 58 |
go test ./cmd/... |
| 59 |
|
| 60 |
bench: |
| 61 |
for i in 1 2 3; do \ |
| 62 |
go test -bench=. ./internal/...; \ |
| 63 |
done > benchmark_results |
| 64 |
benchstat benchmark_results |
| 65 |
|
| 66 |
bench-baseline: |
| 67 |
for i in 1 2 3; do \ |
| 68 |
go test -bench=. ./internal/...; \ |
| 69 |
done > benchmark_results_baseline |
| 70 |
|
| 71 |
bench-compare: |
| 72 |
for i in 1 2 3; do \ |
| 73 |
go test -bench=. ./internal/...; \ |
| 74 |
done > benchmark_results |
| 75 |
benchstat -alpha 0.15 benchmark_results_baseline benchmark_results |
| 76 |
|
| 77 |
clean: |
| 78 |
rm -f micro |