-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (52 loc) · 1.46 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
# Taken from https://github.com/ianstormtaylor/makefile-help
# Show this help prompt.
help:
@ echo
@ echo ' Usage:'
@ echo ''
@ echo ' make <target> [flags...]'
@ echo ''
@ echo ' Targets:'
@ echo ''
@ awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | sort
@ echo ''
@ echo ' Flags:'
@ echo ''
@ awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?\?=/{ print " ", $$1, $$2, comment }' $(MAKEFILE_LIST) | column -t -s '?=' | sort
@ echo ''
.DEFAULT_GOAL = build
# Build the project for release, default is for debugging
release ?= 0
# Show output when running the tests, default is 0
showoutput ?= 0
# `cargo build` flags
BUILD_FLAGS ?=
# `cargo test` flags
TEST_FLAGS ?= --color=always
# flags for the `cargo test` generated binary
TEST_BIN_FLAGS ?=
ifeq ($(release),1)
BUILD_FLAGS := $(BUILD_FLAGS) -r
endif
ifeq ($(showoutput),1)
TEST_BIN_FLAGS := $(TEST_BIN_FLAGS) --nocapture
TEST_FLAGS := $(TEST_FLAGS)
endif
# Builds the project
build: test
cargo build $(BUILD_FLAGS)
# Run the tests
test:
cargo test $(TEST_FLAGS) -- $(TEST_BIN_FLAGS)
# Clean all artifacts
clean:
cargo clean
# Generates the doc
doc: test
cargo doc --no-deps
# Prints Makefile variables - for debugging
debug:
@echo "BUILD_FLAGS=$(BUILD_FLAGS)"
@echo "TEST_FLAGS=$(TEST_FLAGS)"
@echo "TEST_BIN_FLAGS=$(TEST_BIN_FLAGS)"
.PHONY: build test clean debug doc