-
Notifications
You must be signed in to change notification settings - Fork 68
/
Makefile
74 lines (54 loc) · 1.67 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
VERSION :=$(shell git describe --tags --always)
LDFLAGS := "-s -w -X main.version=$(VERSION)"
OUT_DIR := dist
CMD := ./cmd/rmfakecloud
BINARY := rmfakecloud
BUILD = go build -ldflags $(LDFLAGS) -o $(@) $(CMD)
ASSETS = ui/dist
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)
PNPM = cd ui; pnpm
.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/pnpm-lock.yaml
#@cp ui/node_modules/pdfjs-dist/build/pdf.worker.js ui/public/
$(PNPM) 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/pnpm-lock.yaml: ui/node_modules ui/package.json
$(PNPM) i
@touch -mr $(shell ls -Atd $? | head -1) $@
ui/node_modules:
mkdir -p $@
runui: ui/pnpm-lock.yaml
$(PNPM) run dev
clean:
rm -f $(OUT_DIR)/*
rm -fr $(ASSETS)
test: testui testgo
testui:
echo "TODO: fix this"
#CI=true $(PNPM) test
testgo:
go test ./...