forked from servo/html5ever
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.in
92 lines (67 loc) · 2.5 KB
/
Makefile.in
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
# Copyright 2014 The html5ever Project Developers. See the
# COPYRIGHT file at the top-level directory of this distribution.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
VPATH := %VPATH%
RUSTC ?= rustc
RUST_DIRS := -L $(VPATH)/target -L $(VPATH)/target/deps
RUSTC_CMD := $(RUSTC) -D warnings -C rpath $(RUST_DIRS) --extern time=`find $(VPATH)/target/deps -name 'libtime-*.rlib'` $(RUSTFLAGS)
# We build the library itself using Cargo.
CARGO_SOURCES := $(shell find $(VPATH)/src $(VPATH)/macros/src -type f -name '*.rs')
EXT_TEST_TOP_SRC := $(VPATH)/tests/html5ever-external-test.rs
EXT_TEST_ALL_SRC := $(shell find $(VPATH)/tests -type f -name '*.rs')
EXT_BENCH_TOP_SRC := $(VPATH)/bench/bin.rs
EXT_BENCH_ALL_SRC := $(shell find $(VPATH)/bench -type f -name '*.rs')
LIB := libhtml5ever.dummy
EXAMPLES := tokenize noop-tokenize print-tree-actions \
print-rcdom html2html noop-tree-builder
.PHONY: all
all: $(LIB)
.PHONY: examples
examples: $(EXAMPLES)
$(LIB): $(CARGO_SOURCES)
(cd $(VPATH) && cargo build)
touch $(LIB)
.PHONY: for_c
for_c: libhtml5ever_for_c.a
libhtml5ever_for_c.a: $(LIB) $(CARGO_SOURCES)
$(RUSTC_CMD) -o $@ --cfg for_c --crate-type staticlib $(VPATH)/src/lib.rs
define DEF_EXAMPLE
$(1): $$(VPATH)/examples/$(1).rs $$(LIB)
$$(RUSTC_CMD) $$<
endef
$(foreach example,$(EXAMPLES),\
$(eval $(call DEF_EXAMPLE,$(example))))
# Run #[test] functions
html5ever-test: $(LIB)
$(RUSTC_CMD) -o $@ --test $(VPATH)/src/lib.rs
# Run external tests loaded from JSON
html5ever-external-test: $(EXT_TEST_ALL_SRC) $(LIB)
$(RUSTC_CMD) $(EXT_TEST_TOP_SRC)
# Run benchmarks
html5ever-external-bench: $(EXT_BENCH_ALL_SRC) $(LIB)
$(RUSTC_CMD) $(EXT_BENCH_TOP_SRC)
.PHONY: check
check: check-build check-internal check-external
.PHONY: check-build
check-build: all examples html5ever-test html5ever-external-test html5ever-external-bench
.PHONY: check-internal
check-internal: html5ever-test
./html5ever-test
.PHONY: check-external
check-external: html5ever-external-test
HTML5EVER_SRC_DIR=$(VPATH) ./html5ever-external-test
.PHONY: bench
bench: html5ever-external-bench
./html5ever-external-bench --bench
.PHONY: clean
clean:
(cd $(VPATH) && cargo clean)
rm -f *.o *.a *.so *.dylib *.dll *.dummy *-test *-bench $(EXAMPLES)
.PHONY: docs
docs:
(cd $(VPATH) && cargo doc)