-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (38 loc) · 1.17 KB
/
Copy pathMakefile
File metadata and controls
47 lines (38 loc) · 1.17 KB
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
.PHONY: backend frontend clean
BACKEND_SRC := $(shell find backend -name "*.go")
FRONTEND_SRC := $(shell find frontend -type f ! -path "frontend/dist/*" ! -path "frontend/node_modules/*")
FRONTEND_STAMP := build/frontend/.stamp
all: backend frontend
build/system: $(BACKEND_SRC)
@echo "[+] Building backend..."
mkdir -p build
cd backend && go build -o ../build/system .
@echo "[✔] Backend build finished"
build/frontend: $(FRONTEND_SRC)
@echo "[+] Installing frontend deps..."
cd frontend && yarn install
@echo "[+] Building frontend..."
cd frontend && yarn build
@echo "[✔] Frontend build finished"
@mkdir -p build/frontend
@cp -r frontend/dist/. build/frontend/
@touch $(FRONTEND_STAMP)
backend:
@if [ -f build/system ]; then \
if [ -z "$$(find backend -name '*.go' -newer build/system)" ]; then \
echo "[✔] backend is up-to-date, no build needed"; \
exit 0; \
fi; \
fi; \
$(MAKE) build/system
frontend:
@if [ -f $(FRONTEND_STAMP) ]; then \
if [ -z "$$(find frontend -type f -newer $(FRONTEND_STAMP))" ]; then \
echo "[✔] frontend is up-to-date, no build needed"; \
exit 0; \
fi; \
fi; \
$(MAKE) build/frontend
clean:
rm -rf build
rm -rf build