-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathMakefile
108 lines (92 loc) · 4.13 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
TAG := $(shell git describe --tags --abbrev=0)
VERSION := $(shell git describe --tags)
VERSION_HASH := $(shell git rev-parse HEAD)
# deployment directory
DEPLOYMENT_WINDOWS:=cmd/goneovim/deploy/windows
DEPLOYMENT_DARWIN:=cmd/goneovim/deploy/darwin
DEPLOYMENT_LINUX:=cmd/goneovim/deploy/linux
DEPLOYMENT_FREEBSD:=cmd/goneovim/deploy/freebsd
# runtime directory
ifeq ($(OS),Windows_NT)
RUNTIME_DIR=$(DEPLOYMENT_WINDOWS)/
OSNAME=Windows
else ifeq ($(shell uname), Darwin)
RUNTIME_DIR=$(DEPLOYMENT_DARWIN)/goneovim.app/Contents/Resources/
OSNAME=Darwin
else ifeq ($(shell uname), Linux)
RUNTIME_DIR=$(DEPLOYMENT_LINUX)/
OSNAME=Linux
else ifeq ($(shell uname), FreeBSD)
RUNTIME_DIR=$(DEPLOYMENT_FREEBSD)/
OSNAME=FreeBSD
endif
# qt bindings cmd
GOQTSETUP:=$(shell go env GOPATH)/bin/qtsetup
GOQTMOC:=$(shell go env GOPATH)/bin/qtmoc
GOQTDEPLOY:=$(shell go env GOPATH)/bin/qtdeploy
.PHONY: app qt_bindings clean linux windows darwin debug test help
# If the first argument is "run"...
ifeq (debug,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "run"
DEBUG_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(DEBUG_ARGS):;@:)
endif
app: ## Build goneovim
@test -f ./editor/moc.go & $(GOQTMOC) desktop ./cmd/goneovim && \
go generate && \
$(GOQTDEPLOY) build desktop ./cmd/goneovim && \
cp -pR runtime $(RUNTIME_DIR)
ifeq ($(OSNAME),Darwin)
@/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string $(VERSION_HASH)" "./cmd/goneovim/deploy/darwin/goneovim.app/Contents/Info.plist" && \
/usr/libexec/PlistBuddy -c "Add :CFBundleShortVersionString string $(VERSION)" "./cmd/goneovim/deploy/darwin/goneovim.app/Contents/Info.plist"
@if [ -d "./cmd/goneovim/deploy/darwin/goneovim.app/Contents/Frameworks/" ]; then \
cd cmd/goneovim/deploy/darwin/goneovim.app/Contents/Frameworks/ && \
rm -fr QtQuick.framework ; \
rm -fr QtVirtualKeyboard.framework; \
else \
exit 0; \
fi
endif
qt_bindings: ## Setup Qt bindings for Go.
@go get -v github.com/akiyosi/[email protected] && \
go get github.com/akiyosi/qt/internal/[email protected] && \
go get github.com/akiyosi/qt/internal/binding/files/docs/[email protected] && \
go get github.com/akiyosi/qt/internal/binding/files/docs/[email protected] && \
go get github.com/akiyosi/qt/internal/cmd/[email protected] && \
go install -v -tags=no_env github.com/akiyosi/qt/cmd/[email protected] && \
go install -v -tags=no_env github.com/akiyosi/qt/cmd/[email protected] && \
go install -v -tags=no_env github.com/akiyosi/qt/cmd/[email protected] && \
go install -v -tags=no_env github.com/akiyosi/qt/cmd/[email protected] && \
go install -v -tags=no_env github.com/akiyosi/qt/cmd/[email protected] && \
go mod vendor && \
$(GOQTSETUP) -test=false
deps: ## Get dependent libraries.
@go get github.com/akiyosi/goneovim
@$(GOQTMOC) desktop ./cmd/goneovim
test: ## Test goneovim
@go generate && go test ./editor
clean: ## Delete pre-built application binaries and Moc files.
@rm -fr cmd/goneovim/deploy/*
@rm -fr editor/*moc*
linux: ## Build binaries for Linux using Docker.
@go generate && \
cd cmd/goneovim && \
$(GOQTDEPLOY) -docker build linux_static && \
cp -pR ../../runtime $(DEPLOYMENT_LINUX)
windows: ## Build binaries for Windows using Docker.
@go generate && \
cd cmd/goneovim && \
$(GOQTDEPLOY) -docker build windows_64_static && \
cp -pR ../../runtime $(DEPLOYMENT_WINDOWS)
darwin: ## Build binaries for MacOS using Vagrant.
@go generate && \
cd cmd/goneovim && \
$(GOQTDEPLOY) -vagrant build darwin/darwin && \
cp -pR ../../runtime $(DEPLOYMENT_WINDOWS)
debug: ## Debug runs of the application using delve.
@test -f ./editor/moc.go & $(GOQTMOC) desktop ./cmd/goneovim && \
cd cmd/goneovim && \
dlv debug --output goneovim --build-flags -race -- $(DEBUG_ARGS)
help: ## Display this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "%-20s %s\n", $$1, $$2}'