-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
102 lines (73 loc) · 3.69 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
OUTPUT_DIR = ./builds
GIT_COMMIT = `git rev-parse HEAD | cut -c1-7`
VERSION = 3.0.3
BUILD_OPTIONS = -ldflags "-X main.Version=$(VERSION) -X main.CommitID=$(GIT_COMMIT)"
STATIC_OPTIONS = -ldflags "-extldflags='-static' -X main.Version=$(VERSION) -X main.CommitID=$(GIT_COMMIT)"
WEBPACK_MODE = production
# JSMAPFILE = bindata/static/js/tty2web-bundle.js.map # uncomment if map needed
tty2web: main.go server/*.go webtty/*.go backend/*.go Makefile
go get -u ./...
go build ${BUILD_OPTIONS}
tty2web-static: main.go server/*.go webtty/*.go backend/*.go Makefile
go get -u ./...
CGO_ENABLED=0 go build ${STATIC_OPTIONS}
.PHONY: asset
asset: bindata/static/js/tty2web-bundle.js $(JSMAPFILE) bindata/static/index.html bindata/static/favicon.png bindata/static/css/index.css bindata/static/css/xterm.css bindata/static/css/xterm_customize.css bindata/static/js/sidenav.js
.PHONY: all
all: asset tty2web
bindata/static:
mkdir -p bindata/static
bindata/static/index.html: bindata/static resources/index.html
cp resources/index.html bindata/static/index.html
bindata/static/favicon.png: bindata/static resources/favicon.png
cp resources/favicon.png bindata/static/favicon.png
bindata/static/js: bindata/static
mkdir -p bindata/static/js
bindata/static/js/tty2web-bundle.js: bindata/static/js js/dist/tty2web-bundle.js
cp js/dist/tty2web-bundle.js bindata/static/js/tty2web-bundle.js
bindata/static/js/tty2web-bundle.js.map: bindata/static/js js/dist/tty2web-bundle.js.map
cp js/dist/tty2web-bundle.js.map bindata/static/js/tty2web-bundle.js.map
bindata/static/js/sidenav.js: bindata/static/js resources/js/sidenav.js
cp resources/js/sidenav.js bindata/static/js/sidenav.js
bindata/static/css: bindata/static
mkdir -p bindata/static/css
bindata/static/css/index.css: bindata/static/css resources/index.css
cp resources/index.css bindata/static/css/index.css
bindata/static/css/xterm_customize.css: bindata/static/css resources/xterm_customize.css
cp resources/xterm_customize.css bindata/static/css/xterm_customize.css
bindata/static/css/xterm.css: bindata/static/css js/node_modules/xterm/css/xterm.css
cp js/node_modules/xterm/css/xterm.css bindata/static/css/xterm.css
js/node_modules/xterm/dist/xterm.css:
cd js && \
npm install
js/dist/tty2web-bundle.js: js/src/* js/node_modules/webpack
cd js && \
npm exec webpack -- --mode=$(WEBPACK_MODE)
# `npm bin`/webpack
js/node_modules/webpack:
cd js && \
npm install
tools:
go install github.com/mitchellh/gox@latest
go install github.com/tcnksm/ghr@latest
test:
if [ `go fmt $(go list ./... | grep -v /vendor/) | wc -l` -gt 0 ]; then echo "go fmt error"; exit 1; fi
cross_compile:
GOARM=5 gox -os="darwin linux freebsd netbsd openbsd" -arch="386 amd64 arm" -osarch="!darwin/arm" -output "${OUTPUT_DIR}/pkg/{{.OS}}_{{.Arch}}/{{.Dir}}"
targz:
mkdir -p ${OUTPUT_DIR}/dist
cd ${OUTPUT_DIR}/pkg/; for osarch in *; do (cd $$osarch; tar zcvf ../../dist/tty2web_${VERSION}_$$osarch.tar.gz ./*); done;
shasums:
cd ${OUTPUT_DIR}/dist; sha256sum * > ./SHA256SUMS
dokbuild:
docker run -it --rm -v $(PWD):/app golang:alpine /bin/sh -c 'apk add nodejs npm make file git && git config --global --add safe.directory /app && cd /app && make tools && make -B all && make rel && make relwin'
rel:
mkdir -p release
CGO_ENABLED=0 gox -osarch="!darwin/386" -ldflags="-s -w -X main.Version=$(VERSION) -X main.CommitID=$(GIT_COMMIT)" -output="release/{{.Dir}}_{{.OS}}_{{.Arch}}"
relwin:
mkdir -p release
CGO_ENABLED=0 gox -osarch="windows/amd64" -ldflags="-X main.Version=$(VERSION) -X main.CommitID=$(GIT_COMMIT)" -output="release/{{.Dir}}_{{.OS}}_{{.Arch}}"
draft:
ghr -draft v$(VERSION) release/
release:
ghr -c ${GIT_COMMIT} --delete --prerelease -u kost -r tty2web pre-release ${OUTPUT_DIR}/dist