-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
167 lines (144 loc) · 4.47 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Force Go modules, even if in GOPATH
GO111MODULE := on
export
SUPPORTED_ARCH := windows/386 windows/amd64 darwin/amd64 linux/386 linux/amd64
SHELL := /usr/bin/env bash
ifdef TRAVIS_TAG
VERSION ?= ${TRAVIS_TAG}
endif
VERSION ?= $(shell git rev-parse --verify HEAD)
VERSION_FLAGS := -ldflags='-s -w -X github.com/johnstarich/sage/consts.Version=${VERSION}'
LINT_VERSION=1.23.3
# Ensure there's at least an empty bindata file when executing a target
ENSURE_STUB := $(shell [[ -f ./server/bindata.go ]] || { mkdir -p web/build && GO111MODULE=on go generate ./server; })
.PHONY: all
all: lint test build
.PHONY: version
version:
@echo ${VERSION}
.PHONY: lint
lint:
@if ! which golangci-lint >/dev/null || [[ "$$(golangci-lint version 2>&1)" != *${LINT_VERSION}* ]]; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v${LINT_VERSION}; \
fi
golangci-lint run
.PHONY: lint-fix
lint-fix:
golangci-lint run --fix
.PHONY: test
test:
set -e; \
tmpfile=$$(mktemp); \
trap 'rm -f "$$tmpfile"' EXIT; \
go test ./... -race -cover -coverprofile "$$tmpfile" >&2; \
coverage=$$(go tool cover -func "$$tmpfile" | tail -1 | awk '{print $$3}'); \
printf '##########################\n' >&2; \
printf '### Coverage is %6s ###\n' "$$coverage" >&2; \
printf '##########################\n' >&2; \
echo "$$coverage"; \
if [[ -n "$$COVERALLS_TOKEN" ]]; then \
go get github.com/mattn/goveralls; \
goveralls -coverprofile="$$tmpfile" -service=travis-ci -repotoken "$$COVERALLS_TOKEN"; \
fi
.PHONY: build
build: static
go build ${VERSION_FLAGS} -o out/sage
.PHONY: docker
docker:
./goproxy.sh \
docker build \
--build-arg VERSION=${VERSION} \
-t johnstarich/sage:${VERSION} \
.
.PHONY: clean
clean: cache out
rm -rf cache/ out/
cache:
mkdir cache
out:
mkdir out
cache/ofxhome.xml: cache
# API v1.1.2
if [[ ! -f cache/ofxhome.xml ]]; then \
curl -v -o cache/ofxhome.xml http://www.ofxhome.com/api.php?dump=yes; \
else \
touch cache/ofxhome.xml; \
fi
.PHONY: release
release: clean
$(MAKE) -j4 dist
$(MAKE) apps
# Try to create easily-scripted file names for download
$(SUPPORTED_ARCH): GOOS = $(@D)
$(SUPPORTED_ARCH): GOARCH = $(@F)
$(SUPPORTED_ARCH): CGO_ENABLED = 0
windows/%: EXT = .exe
%/386: ARCH = i386
%/amd64: ARCH = x86_64
$(SUPPORTED_ARCH): out static
go build -v ${VERSION_FLAGS} -o out/sage-${VERSION}-${GOOS}-${ARCH}${EXT}
.PHONY: dist
dist: $(SUPPORTED_ARCH)
.PHONY: static-deps
static-deps:
npm ci --prefix=web
.PHONY: static
static: cache/ofxhome.xml static-deps
npm run --prefix=web build
# Unset vars from upcoming targets
GOOS= GOARCH= go generate ./server ./client/direct/drivers
.PHONY: start
start:
trap 'jobs -p | xargs kill' EXIT; \
mkdir -p ./data; \
npm --prefix=web run start-api & \
npm --prefix=web start
.PHONY: start-app
start-app:
@if [[ -e out/sage ]]; then \
echo "Make sure you ran 'make build' recently!"; \
else \
$(MAKE) build; \
fi
npm --prefix=web run start-app
.PHONY: start-pass
start-pass:
trap 'jobs -p | xargs kill' EXIT; \
mkdir -p ./data; \
npm --prefix=web run start-api-pass & \
npm --prefix=web start
.PHONY: apps
apps: out
docker run \
--name sage-apps-builder \
--rm -it \
--env DEBUG='electron-windows-installer:*' \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI') \
-v "${PWD}:/project:delegated" \
electronuserland/builder:wine-mono make docker-apps && \
ls -Rlh out/ && \
find out -type f -mindepth 2 | xargs -I{} mv -f {} out/ && \
rm -f out/RELEASES out/*.nupkg && \
mv -f "out/Sage-1.0.0 Setup.exe" out/Sage-for-Windows.exe && \
mv -f out/Sage-darwin-x64-1.0.0.zip out/Sage-for-Mac.zip && \
mv -f out/sage_1.0.0_amd64.deb out/Sage-for-Linux.deb
.PHONY: docker-apps
docker-apps:
apt update
apt install -y --no-install-recommends \
fakeroot \
p7zip \
zip
rm -rf ~/.wine
fakeroot $(MAKE) static-deps
# Fix wrong 7-zip architecture for win32 build
wget -O /tmp/7z.7z https://www.7-zip.org/a/7z1900-extra.7z
7zr x -o/tmp/7z-files /tmp/7z.7z
cp /tmp/7z-files/7za.dll ./web/node_modules/electron-winstaller/vendor/7z.dll
cp /tmp/7z-files/7za.exe ./web/node_modules/electron-winstaller/vendor/7z.exe
npm config set loglevel verbose
(for i in {1..60}; do sleep 60; echo "Keeping Travis CI happy $$i"; done &) && \
npm run --prefix=web windows && cp -fr web/out/make/* out/ && \
npm run --prefix=web mac && cp -fr web/out/make/* out/ && \
npm run --prefix=web linux && cp -fr web/out/make/* out/ && \
chmod -R 777 out/