-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
115 lines (92 loc) · 3.01 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
SOURCES:=$(shell find src -type f -name '*.rs')
X86_64:=x86_64-unknown-linux-gnu
ARMV7:=armv7-unknown-linux-gnueabihf
AARCH64:=aarch64-unknown-linux-gnu
DATABASE:=$(shell echo ${DATABASE_URL} | awk -F':' '{print $$2}')
MEDIA_DIR:=data/media
THUMBNAIL_DIR:=data/thumbnails
${DATABASE}:
mkdir -p $(shell dirname ${DATABASE})
sqlx database create
sqlx migrate run --source migrations
${MEDIA_DIR}:
mkdir -p ${MEDIA_DIR}
${THUMBNAIL_DIR}:
mkdir -p ${THUMBNAIL_DIR}
_release: ${DATABASE}
cargo build --locked --release --target ${TARGET}
mkdir -p release
cp target/${TARGET}/release/spis release/spis-${TARGET}
release/spis-${X86_64}: ${SOURCES}
TARGET=${X86_64} $(MAKE) --no-print-directory _release
release/spis-${ARMV7}: ${SOURCES}
TARGET=${ARMV7} $(MAKE) --no-print-directory _release
release/spis-${AARCH64}: ${SOURCES}
TARGET=${AARCH64} $(MAKE) --no-print-directory _release
.PHONY: toolchain
toolchain:
rustup show
cargo install sqlx-cli@0.8.0
cargo install cargo-tarpaulin@0.31.0
.PHONY: dev-clippy
dev-clippy: ${DATABASE}
watchexec --stop-timeout=0 -r -e rs,toml,html,css -- \
cargo clippy -F dev -- --no-deps -D warnings
.PHONY: dev-spis
dev-spis: ${DATABASE} ${MEDIA_DIR} ${THUMBNAIL_DIR}
watchexec --stop-timeout=0 -r -e rs,toml,html,css -- \
cargo run --color always -F dev
.PHONY: dev-nginx
dev-nginx: ${DATABASE} ${MEDIA_DIR} ${THUMBNAIL_DIR}
bash -c 'RUST_LOG=error cargo run -q -- template nginx --full > /tmp/nginx.conf && nginx -g "daemon off;" -c /tmp/nginx.conf'
.PHONY: dev
dev:
$(MAKE) --no-print-directory -j 2 dev-nginx dev-spis
.PHONY: lint-fmt
lint-fmt:
cargo fmt -- --check
.PHONY: lint-clippy
lint-clippy: ${DATABASE}
cargo clippy -F dev -- --no-deps -D warnings
.PHONY: lint
lint: lint-fmt lint-clippy
.PHONY: test
test: ${DATABASE} ${MEDIA_DIR} ${THUMBNAIL_DIR}
cargo tarpaulin --ignore-tests --color always --timeout 120 --skip-clean --out Xml
.PHONY: template
template: ${DATABASE} ${MEDIA_DIR} ${THUMBNAIL_DIR}
cargo build --color always
cargo run -q -- \
--server-socket /storage/spis/data/spis.sock \
--data-dir /storage/spis/data \
--media-dir /storage/spis/media template \
nginx --port 8080 > examples/systemd/nginx.conf
cargo run -q -- \
--server-socket /storage/spis/data/spis.sock \
--data-dir /storage/spis/data \
--media-dir /storage/spis/media template \
systemd --bin /usr/bin/spis --user www-data > examples/systemd/spis.service
cargo run -q -- \
--data-dir /tmp/spis_data \
--media-dir /tmp/spis_media template \
docker-compose > examples/docker/docker-compose.yml
git diff --exit-code
.PHONY: docker-build
docker-build: release/spis-${X86_64}
docker build -t spis-local -f docker/Dockerfile .
.PHONY: docker-exec
docker-exec: docker-build
docker run -it --rm \
--entrypoint bash \
spis-local
.PHONY: docker-run
docker-run: docker-build
docker run -it --rm \
-p 8080:8080 \
-v ${PWD}/data/media:/var/lib/spis/media \
-e SPIS_PROCESSING_RUN_ON_START=true \
spis-local
.PHONY: clean
clean:
rm -rf target release data/spis.db data/thumbnails
cargo clean