-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (47 loc) · 1.48 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
FRONTEND_DIR := ${PWD}/frontend
FRONTEND_OUT_DIR := ${FRONTEND_DIR}/dist
BACKEND_DIR := ${PWD}/backend
BUILD_LOG := ${PWD}/build.log
define say_begin
@printf '\033[0;1;32m${1}\033[m ${2}...'
endef
define say_done
@printf '\033[0;1;32mdone\033[m\n'
endef
define try_build
@echo "Attempting to run command: ${1}\n---" >> ${BUILD_LOG}
@sh -c "${1}" >> ${BUILD_LOG} 2>&1; \
RESULT=$$?; \
if [ "$$RESULT" -ne 0 ]; then \
echo "---\nCommand failed with exit code: $$RESULT" >> ${BUILD_LOG}; \
printf '\033[0;1;31mfailed\033[m\n'; \
echo see ${BUILD_LOG} for details; \
exit "$$RESULT"; \
fi
@echo "---\nCommand succeeded" >> ${BUILD_LOG}
endef
all: frontend backend
frontend:
@$(call say_begin,building,frontend)
@$(call try_build,yarn --cwd ${FRONTEND_DIR} install)
@$(call try_build,yarn --cwd ${FRONTEND_DIR} build --output-path ${FRONTEND_OUT_DIR} --no-color)
@$(call say_done)
backend:
@$(call say_begin,building,backend)
@$(call try_build,cargo build \
--release \
--manifest-path '${BACKEND_DIR}/Cargo.toml' \
--config 'env.MPDWEB_FRONTEND_OUT_DIR=\"${FRONTEND_OUT_DIR}\"')
@$(call say_done)
clean:
@rm ${BUILD_LOG}
@$(call say_begin,cleaning,frontend)
@rm -rf ${FRONTEND_DIR}/node_modules
@rm -rf ${FRONTEND_OUT_DIR}
@$(call say_done)
@$(call say_begin,cleaning,backend)
@cargo --quiet clean --manifest-path ${BACKEND_DIR}/Cargo.toml
@$(call say_done)
install:
@cargo install --locked --offline --path ${BACKEND_DIR}
.PHONY: all frontend backend install