summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 9e49817a92a74ac6ba060677adecd26acb405803 (plain)
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
STYLES=style/public/index.css style/public/search.css
CACHE_FILES=data/crate_data.db data/users.db data/2019.rmpz

all: website

website: download-caches data/index/1 styles Cargo.lock
	cd front_end && cargo run --release --bin website
	cd style && npm start

Cargo.lock: Cargo.toml
	rm Cargo.lock; git submodule update --init --recursive
	cargo update

download-caches: $(CACHE_FILES)

$(CACHE_FILES):
	if [ ! -d data/data.tar.xz -a -f data.tar.xz ]; then mv data.tar.xz data/; fi
	if [ ! -f data/data.tar.xz ]; then curl --fail --output data/data.tar.xz https://lib.rs/data/data.tar.xz; fi

	cd data; unxz < data.tar.xz | tar xv
	touch $@

styles: $(STYLES)

$(STYLES): style/node_modules/.bin/gulp
	cd style && npm run build

style/package.json:
	git submodule update --init --recursive

style/node_modules/.bin/gulp: style/package.json
	@echo Installing Sass
	cd style && npm install
	touch $@

data/index/1:
	@echo Getting crates index
	git submodule update --init

.PHONY: all download-caches styles clean clean-cache

clean:
	rm -rf style/public/*.css Cargo.lock
	git submodule update --init --recursive
	git submodule sync

clean-cache: clean
	rm data/*rmpz data/users.db