-
Notifications
You must be signed in to change notification settings - Fork 62
/
Makefile
73 lines (53 loc) · 1.62 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
VERSION :=$(shell git describe --tags)
LDFLAGS := "-s -w -X main.version=$(VERSION)"
OUT_DIR := dist
CMD := ./cmd/rmfakecloud
BINARY := rmfakecloud
BUILD = go build -ldflags $(LDFLAGS) -o $(@) $(CMD)
ASSETS = ui/build
GOFILES := $(shell find . -iname '*.go' ! -iname "*_test.go")
GOFILES += $(ASSETS)
UIFILES := $(shell find ui/src)
UIFILES += $(shell find ui/public)
UIFILES += ui/package.json
TARGETS := $(addprefix $(OUT_DIR)/$(BINARY)-, x64 armv6 armv7 arm64 win64 docker)
YARN = yarn --cwd ui
.PHONY: all run runui clean test testgo testui
build: $(OUT_DIR)/$(BINARY)-x64
all: $(TARGETS)
$(OUT_DIR)/$(BINARY)-x64:$(GOFILES)
GOOS=linux $(BUILD)
$(OUT_DIR)/$(BINARY)-armv6:$(GOFILES)
GOARCH=arm GOARM=6 $(BUILD)
$(OUT_DIR)/$(BINARY)-armv7:$(GOFILES)
GOARCH=arm GOARM=7 $(BUILD)
$(OUT_DIR)/$(BINARY)-win64:$(GOFILES)
GOOS=windows $(BUILD)
$(OUT_DIR)/$(BINARY)-arm64:$(GOFILES)
GOARCH=arm64 $(BUILD)
$(OUT_DIR)/$(BINARY)-docker:$(GOFILES)
CGO_ENABLED=0 $(BUILD)
container: $(OUT_DIR)/$(BINARY)-docker
docker build -t rmfakecloud -f Dockerfile.make .
run: $(ASSETS)
go run $(CMD) $(ARG)
$(ASSETS): $(UIFILES) ui/yarn.lock
@cp ui/node_modules/pdfjs-dist/build/pdf.worker.js ui/public/
$(YARN) build
@#remove unneeded stuff, todo: eject
@rm ui/build/service-worker.js ui/build/precache-manifest* ui/build/asset-manifest.json 2> /dev/null || true
ui/yarn.lock: ui/node_modules ui/package.json
$(YARN)
@touch -mr $(shell ls -Atd $? | head -1) $@
ui/node_modules:
mkdir -p $@
runui: ui/yarn.lock
$(YARN) start
clean:
rm -f $(OUT_DIR)/*
rm -fr $(ASSETS)
test: testui testgo
testui:
CI=true $(YARN) test
testgo:
go test ./...