2014-06-12 17:29:24 +10:00
|
|
|
|
RUSTC ?= rustc
|
|
|
|
|
RUSTDOC ?= rustdoc
|
|
|
|
|
RUSTFLAGS ?= -O
|
|
|
|
|
RUST_REPOSITORY ?= ../rust
|
|
|
|
|
RUST_CTAGS ?= $(RUST_REPOSITORY)/src/etc/ctags.rust
|
|
|
|
|
|
|
|
|
|
all: anymap docs test
|
|
|
|
|
|
|
|
|
|
# Recursive wildcard function
|
|
|
|
|
# http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
|
|
|
|
|
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
|
|
|
|
|
$(filter $(subst *,%,$2),$d))
|
|
|
|
|
|
|
|
|
|
SRC := $(call rwildcard,src/,*.rs)
|
2014-07-10 18:11:53 +10:00
|
|
|
|
LIB := target/$(shell rustc --print-file-name src/lib.rs)
|
2014-06-25 14:44:35 +10:00
|
|
|
|
ifeq ($(LIB),target/)
|
2014-06-12 17:29:24 +10:00
|
|
|
|
# We may not have rustc or the lib.rs file may be broken.
|
|
|
|
|
# But don't break the rules on that account.
|
2014-06-25 14:44:35 +10:00
|
|
|
|
LIB := target/libanymap.dummy
|
2014-06-12 17:29:24 +10:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
anymap: $(LIB)
|
|
|
|
|
|
|
|
|
|
$(LIB): $(SRC)
|
2014-06-25 14:44:35 +10:00
|
|
|
|
@mkdir -p target/
|
|
|
|
|
$(RUSTC) $(RUSTFLAGS) src/lib.rs --out-dir=target -L target
|
2014-06-12 17:29:24 +10:00
|
|
|
|
|
|
|
|
|
doc/anymap/index.html: $(SRC)
|
2014-06-25 14:44:35 +10:00
|
|
|
|
$(RUSTDOC) src/lib.rs -L target
|
2014-06-12 17:29:24 +10:00
|
|
|
|
|
2014-06-25 14:44:35 +10:00
|
|
|
|
target/test: $(SRC)
|
|
|
|
|
$(RUSTC) $(RUSTFLAGS) --test -o target/test src/lib.rs -L target
|
2014-06-12 17:29:24 +10:00
|
|
|
|
|
2014-06-25 14:44:35 +10:00
|
|
|
|
target/quicktest: $(SRC)
|
|
|
|
|
$(RUSTC) --test -o target/quicktest src/lib.rs -L target
|
2014-06-12 17:29:24 +10:00
|
|
|
|
|
|
|
|
|
# There are no tests to run this way at present. It’s all doctests.
|
2014-06-25 14:44:35 +10:00
|
|
|
|
# test: anymap doctest target/test
|
|
|
|
|
# target/test --test
|
2014-06-12 17:29:24 +10:00
|
|
|
|
test: anymap doctest
|
|
|
|
|
|
2014-06-25 14:44:35 +10:00
|
|
|
|
bench: anymap target/test
|
|
|
|
|
target/test --bench
|
2014-06-12 22:25:17 +10:00
|
|
|
|
|
2014-06-12 17:29:24 +10:00
|
|
|
|
doctest: $(SRC) $(LIB)
|
2014-06-25 14:44:35 +10:00
|
|
|
|
$(RUSTDOC) -L target --test src/lib.rs
|
2014-06-12 17:29:24 +10:00
|
|
|
|
|
2014-06-25 14:44:35 +10:00
|
|
|
|
# Can't wait for everything to target, optimised too? OK, you can save some time here.
|
|
|
|
|
quicktest: target/quicktest
|
|
|
|
|
target/quicktest --test
|
2014-06-12 17:29:24 +10:00
|
|
|
|
|
|
|
|
|
docs: doc/anymap/index.html
|
|
|
|
|
|
|
|
|
|
clean:
|
2014-06-25 14:44:35 +10:00
|
|
|
|
rm -rf target/ doc/
|
2014-06-12 17:29:24 +10:00
|
|
|
|
|
|
|
|
|
TAGS: $(SRC)
|
|
|
|
|
ctags -f TAGS --options="$(RUST_CTAGS)" --language=rust -R src/
|
|
|
|
|
|
|
|
|
|
.PHONY: all docs clean test doctest quicktest anymap
|