-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
73 lines (56 loc) · 1.91 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
#!/usr/bin/env bash
SHELL := /bin/bash
PKG := github.com/dh1tw/remoteRotator
COMMITID := $(shell git describe --always --long --dirty)
COMMIT := $(shell git rev-parse --short HEAD)
VERSION := $(shell git describe --tags)
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/)
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
all: build
build:
go generate ./...
go build -v -ldflags="-X github.com/dh1tw/remoteRotator/cmd.commitHash=${COMMIT} \
-X github.com/dh1tw/remoteRotator/cmd.version=${VERSION}"
# replace the debug version of js libraries with their production, minified versions
js-production:
find hub/html/index.html -exec sed -i '' 's/vue.js/vue.min.js/g' {} \;
# replace the minified versions of js libraries with their full, development versions
js-development:
find hub/html/index.html -exec sed -i '' 's/vue.min.js/vue.js/g' {} \;
generate:
go generate ./...
# strip off dwraf table - used for travis CI
dist:
go build -v -ldflags="-w -s -X github.com/dh1tw/remoteRotator/cmd.commitHash=${COMMIT} \
-X github.com/dh1tw/remoteRotator/cmd.version=${VERSION}"
# compress binary
# there is a know issue that upx currently doesn't work with darwin/arm64.
# See https://github.com/upx/upx/issues/424
# until it's resolved, we ship darwin/arm64 uncompressed.
if [ "${GOOS}" = "windows" ]; \
then upx remoteRotator.exe; \
else \
if [ "${GOOS}" = "darwin" ] && [ "${GOARCH}" = "arm64" ]; \
then true; \
else upx remoteRotator; \
fi \
fi
# test:
# @go test -short ${PKG_LIST}
vet:
@go vet ${PKG_LIST}
lint:
@for file in ${GO_FILES} ; do \
golint $$file ; \
done
test:
go generate ./...
go test ./...
install-deps:
go get golang.org/x/tools/cmd/stringer
go get github.com/GeertJohan/go.rice/rice
clean:
-@rm remoteRotator remoteRotator-v*
.PHONY: build vet lint clean install-deps generate js-production js-development