-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
65 lines (50 loc) · 1.42 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
PKG_NAME=rhex
DOCS_DEFAULT_MODULE=rhex
ifeq (, $(shell which cargo-check 2> /dev/null))
DEFAULT_TARGET=build
else
DEFAULT_TARGET=check
endif
default: $(DEFAULT_TARGET)
# Mostly generic part goes below
ifneq ($(RELEASE),)
$(info RELEASE BUILD)
CARGO_FLAGS += --release
ALL_TARGETS += build test bench $(EXAMPLES)
else
$(info DEBUG BUILD; use `RELEASE=true make [args]` for release build)
ALL_TARGETS += build $(EXAMPLES) test
endif
EXAMPLES = $(shell cd examples 2>/dev/null && ls *.rs 2>/dev/null | sed -e 's/.rs$$//g' )
all: $(ALL_TARGETS)
.PHONY: run test build doc clean clippy
run test build clean:
cargo $@ $(CARGO_FLAGS)
check:
$(info Running check; use `make build` to actually build)
cargo $@ $(CARGO_FLAGS)
clippy:
cargo build --features clippy
.PHONY: bench
bench:
cargo $@ $(filter-out --release,$(CARGO_FLAGS))
.PHONY: longtest
longtest:
for i in `seq 10`; do cargo test $(CARGO_FLAGS) || exit 1 ; done
.PHONY: $(EXAMPLES)
$(EXAMPLES):
cargo build --example $@ $(CARGO_FLAGS)
doc: FORCE
cp src/lib.rs src/lib.rs.orig
sed -i -e '/\/\/ MAKE_DOC_REPLACEME/{ r examples/echo.rs' -e 'd }' src/lib.rs
-cargo doc
mv src/lib.rs.orig src/lib.rs
publishdoc: doc
echo '<meta http-equiv="refresh" content="0;url='${DOCS_DEFAULT_MODULE}'/index.html">' > target/doc/index.html
ghp-import -n target/doc
git push -f origin gh-pages
.PHONY: docview
docview: doc
xdg-open target/doc/$(PKG_NAME)/index.html
.PHONY: FORCE
FORCE: