This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
forked from habitat-sh/habitat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
169 lines (134 loc) · 5.53 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
IN_DOCKER := true
endif
ifneq ($(IN_DOCKER),)
build_args := --build-arg HAB_DEPOT_URL=$(HAB_DEPOT_URL)
run_args := -e HAB_DEPOT_URL=$(HAB_DEPOT_URL)
run_args := $(run_args) -e HAB_ORIGIN=$(HAB_ORIGIN)
ifneq (${http_proxy},)
build_args := $(build_args) --build-arg http_proxy="${http_proxy}"
run_args := $(run_args) -e http_proxy="${http_proxy}"
endif
ifneq (${https_proxy},)
build_args := $(build_args) --build-arg https_proxy="${https_proxy}"
run_args := $(run_args) -e https_proxy="${https_proxy}"
endif
dimage := habitat/devshell
docker_cmd := env http_proxy= https_proxy= docker
compose_cmd := env http_proxy= https_proxy= docker-compose
common_run := $(compose_cmd) run --rm $(run_args)
run := $(common_run) shell
docs_host := ${DOCKER_HOST}
docs_run := $(common_run) -p 9633:9633 shell
else
run :=
docs_host := 127.0.0.1
docs_run :=
endif
BIN = director hab sup
LIB = builder-dbcache builder-protocol common core depot-client http-client net
SRV = builder-api builder-jobsrv builder-sessionsrv builder-vault builder-worker depot
ALL = $(BIN) $(LIB) $(SRV)
.DEFAULT_GOAL := build-bin
build: build-bin build-lib build-srv ## builds all the components
build-all: build
.PHONY: build build-all
build-bin: $(addprefix build-,$(BIN)) ## builds the binary components
.PHONY: build-bin
build-lib: $(addprefix build-,$(LIB)) ## builds the library components
.PHONY: build-lib
build-srv: $(addprefix build-,$(SRV)) ## builds the service components
.PHONY: build-srv
unit: unit-bin unit-lib unit-srv ## executes all the components' unit test suites
unit-all: unit
.PHONY: unit unit-all
unit-bin: $(addprefix unit-,$(BIN)) ## executes the binary components' unit test suites
.PHONY: unit-bin
unit-lib: $(addprefix unit-,$(LIB)) ## executes the library components' unit test suites
.PHONY: unit-lib
unit-srv: $(addprefix unit-,$(SRV)) ## executes the service components' unit test suites
.PHONY: unit-srv
functional: functional-bin functional-lib functional-srv ## executes all the components' functional test suites
functional-all: functional
test: functional ## executes all components' test suites
.PHONY: functional functional-all test
functional-bin: $(addprefix unit-,$(BIN)) ## executes the binary components' unit functional suites
.PHONY: functional-bin
functional-lib: $(addprefix unit-,$(LIB)) ## executes the library components' unit functional suites
.PHONY: functional-lib
functional-srv: $(addprefix unit-,$(SRV)) ## executes the service components' unit functional suites
.PHONY: functional-srv
clean: clean-bin clean-lib clean-srv ## cleans all the components' clean test suites
clean-all: clean
.PHONY: clean clean-all
clean-bin: $(addprefix clean-,$(BIN)) ## cleans the binary components' project trees
.PHONY: clean-bin
clean-lib: $(addprefix clean-,$(LIB)) ## cleans the library components' project trees
.PHONY: clean-lib
clean-srv: $(addprefix clean-,$(SRV)) ## cleans the service components' project trees
.PHONY: clean-srv
help:
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help
shell: image ## launches a development shell
$(run)
.PHONY: shell
serve-docs: docs ## serves the project documentation from an HTTP server
@echo "==> View the docs at:\n\n http://`\
echo $(docs_host) | sed -e 's|^tcp://||' -e 's|:[0-9]\{1,\}$$||'`:9633/\n\n"
$(docs_run) sh -c 'set -e; cd ./components/sup/target/doc; python -m SimpleHTTPServer 9633;'
.PHONY: serve-docs
ifneq ($(IN_DOCKER),)
distclean: ## fully cleans up project tree and any associated Docker images and containers
$(compose_cmd) stop
$(compose_cmd) rm -f -v
$(docker_cmd) rmi $(dimage) || true
($(docker_cmd) images -q -f dangling=true | xargs $(docker_cmd) rmi -f) || true
.PHONY: distclean
image: ## create an image
if [ -n "${force}" -o -n "${refresh}" -o -z "`$(docker_cmd) images -q $(dimage)`" ]; then \
if [ -n "${force}" ]; then \
$(docker_cmd) build --no-cache $(build_args) -t $(dimage) .; \
else \
$(docker_cmd) build $(build_args) -t $(dimage) .; \
fi \
fi
.PHONY: image
else
image: ## no-op
.PHONY: image
distclean: clean ## fully cleans up project tree
.PHONY: distclean
endif
docs: image ## build the docs
$(run) sh -c 'set -ex; \
cd components/sup && cargo doc && cd ../../ \
rustdoc --crate-name habitat_sup README.md -o ./components/sup/target/doc/habitat_sup; \
docco -e .sh -o components/sup/target/doc/habitat_sup/hab-plan-build components/plan-build/bin/hab-plan-build.sh; \
cp -r images ./components/sup/target/doc/habitat_sup; \
echo "<meta http-equiv=refresh content=0;url=habitat_sup/index.html>" > components/sup/target/doc/index.html;'
define BUILD
build-$1: image ## builds the $1 component
$(run) sh -c 'cd components/$1 && cargo build'
.PHONY: build-$1
endef
$(foreach component,$(ALL),$(eval $(call BUILD,$(component))))
define UNIT
unit-$1: image ## executes the $1 component's unit test suite
$(run) sh -c 'cd components/$1 && cargo test'
.PHONY: unit-$1
endef
$(foreach component,$(ALL),$(eval $(call UNIT,$(component))))
define FUNCTIONAL
functional-$1: image ## executes the $1 component's functional test suite
$(run) sh -c 'cd components/$1 && cargo test --features functional'
.PHONY: functional-$1
endef
$(foreach component,$(ALL),$(eval $(call FUNCTIONAL,$(component))))
define CLEAN
clean-$1: image ## cleans the $1 component's project tree
$(run) sh -c 'cd components/$1 && cargo clean'
.PHONY: clean-$1
endef
$(foreach component,$(ALL),$(eval $(call CLEAN,$(component))))