1
- .PHONY : $(MAKECMDGOALS ) all
1
+ # .PHONY: $(MAKECMDGOALS) all
2
2
.DEFAULT_GOAL := help
3
3
RUN := $(shell realpath $(shell dirname $(firstword $(MAKEFILE_LIST ) ) ) /scripts/docker-compose-run.sh)
4
4
@@ -19,6 +19,8 @@ export SCOPE ?= ""
19
19
export AUTOSPAWN ?= true
20
20
# Override to control if services are turned off after integration tests.
21
21
export AUTODESPAWN ?= ${AUTOSPAWN}
22
+ # Override autoinstalling of tools. (Eg `cargo install`)
23
+ export AUTOINSTALL ?= false
22
24
# Override to true for a bit more log output in your environment building (more coming!)
23
25
export VERBOSE ?= false
24
26
# Override to set a different Rust toolchain
@@ -57,6 +59,10 @@ FORMATTING_BEGIN_YELLOW = \033[0;33m
57
59
FORMATTING_BEGIN_BLUE = \033[36m
58
60
FORMATTING_END = \033[0m
59
61
62
+ # "One weird trick!" https://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
63
+ EMPTY: =
64
+ SPACE: = ${EMPTY} ${EMPTY}
65
+
60
66
help :
61
67
@printf -- " ${FORMATTING_BEGIN_BLUE} __ __ __${FORMATTING_END} \n"
62
68
@printf -- " ${FORMATTING_BEGIN_BLUE} \ \ / / / /${FORMATTING_END} \n"
@@ -175,22 +181,83 @@ build-dev: ## Build the project in development mode (Supports `ENVIRONMENT=true`
175
181
176
182
build-all : build-x86_64-unknown-linux-musl build-aarch64-unknown-linux-musl # # Build the project in release mode for all supported platforms
177
183
178
- build-x86_64-unknown-linux-gnu : # # Build dynamically linked binary in release mode for the x86_64 architecture
179
- $(RUN ) build-x86_64-unknown-linux-gnu
184
+ build-x86_64-unknown-linux-gnu : target/x86_64-unknown-linux-gnu/release/vector # # Build a release binary for the x86_64-unknown-linux-gnu triple.
185
+ @echo " Output to ${<} "
186
+
187
+ build-aarch64-unknown-linux-gnu : target/aarch64-unknown-linux-gnu/release/vector # # Build a release binary for the aarch64-unknown-linux-gnu triple.
188
+ @echo " Output to ${<} "
180
189
181
190
build-x86_64-unknown-linux-musl : # # Build static binary in release mode for the x86_64 architecture
182
191
$(RUN ) build-x86_64-unknown-linux-musl
183
192
184
193
build-aarch64-unknown-linux-musl : load-qemu-binfmt # # Build static binary in release mode for the aarch64 architecture
185
194
$(RUN ) build-aarch64-unknown-linux-musl
186
195
196
+ # #@ Cross Compiling
197
+ .PHONY : cross-enable
198
+ cross-enable : cargo-install-cross
199
+
200
+ .PHONY : CARGO_HANDLES_FRESHNESS
201
+ CARGO_HANDLES_FRESHNESS :
202
+ ${EMPTY}
203
+
204
+ # This is basically a shorthand for folks.
205
+ # `cross-anything-triple` will call `cross anything --target triple` with the right features.
206
+ .PHONY : cross-%
207
+ cross-% : export PAIR =$(subst -, ,$($(strip @) :cross-%=%) )
208
+ cross-% : export COMMAND ?=$(word 1,${PAIR})
209
+ cross-% : export TRIPLE ?=$(subst ${SPACE},-,$(wordlist 2,99,${PAIR}) )
210
+ cross-% : export PROFILE ?= release
211
+ cross-% : export RUSTFLAGS += -C link-arg=-s
212
+ cross-% : cargo-install-cross
213
+ cross ${COMMAND} \
214
+ $(if $(findstring release,$(PROFILE ) ) ,--release,) \
215
+ --target ${TRIPLE} \
216
+ --no-default-features \
217
+ --features target-${TRIPLE}
218
+
219
+ target/% /vector : export PAIR =$(subst /, ,$(@:target/%/vector=% ) )
220
+ target/% /vector : export TRIPLE ?=$(word 1,${PAIR})
221
+ target/% /vector : export PROFILE ?=$(word 2,${PAIR})
222
+ target/% /vector : export RUSTFLAGS += -C link-arg=-s
223
+ target/% /vector : cargo-install-cross CARGO_HANDLES_FRESHNESS
224
+ cross build \
225
+ $(if $(findstring release,$(PROFILE ) ) ,--release,) \
226
+ --target ${TRIPLE} \
227
+ --no-default-features \
228
+ --features target-${TRIPLE}
229
+
230
+ target/% /vector.tar.gz : export PAIR =$(subst /, ,$(@:target/%/vector.tar.gz=% ) )
231
+ target/% /vector.tar.gz : export TRIPLE ?=$(word 1,${PAIR})
232
+ target/% /vector.tar.gz : export PROFILE ?=$(word 2,${PAIR})
233
+ target/% /vector.tar.gz : target/% /vector CARGO_HANDLES_FRESHNESS
234
+ tar --create \
235
+ --gzip \
236
+ --verbose \
237
+ --file target/${TRIPLE} /${PROFILE} /vector.tar.gz \
238
+ --transform=' s|target/${TRIPLE}/${PROFILE}/|bin/|' \
239
+ --transform=' s|distribution/|etc/|' \
240
+ --transform ' s|^|vector-${TRIPLE}/|' \
241
+ target/${TRIPLE} /${PROFILE} /vector \
242
+ README.md \
243
+ LICENSE \
244
+ config \
245
+ distribution/init.d \
246
+ distribution/systemd
247
+
187
248
# #@ Testing (Supports `ENVIRONMENT=true`)
188
249
189
250
test : # # Run the unit test suite
190
251
${MAYBE_ENVIRONMENT_EXEC} cargo test --no-default-features --features ${DEFAULT_FEATURES} ${SCOPE} -- --nocapture
191
252
192
253
test-all : test test-behavior test-integration # # Runs all tests, unit, behaviorial, and integration.
193
254
255
+ test-x86_64-unknown-linux-gnu : cross-test-x86_64-unknown-linux-gnu # # Runs unit tests on the x86_64-unknown-linux-gnu triple
256
+ ${EMPTY}
257
+
258
+ test-aarch64-unknown-linux-gnu : cross-test-aarch64-unknown-linux-gnu # # Runs unit tests on the aarch64-unknown-linux-gnu triple
259
+ ${EMPTY}
260
+
194
261
test-behavior : # # Runs behaviorial test
195
262
${MAYBE_ENVIRONMENT_EXEC} cargo run -- test tests/behavior/** /* .toml
196
263
@@ -671,21 +738,39 @@ package-x86_64-unknown-linux-gnu-all: package-archive-x86_64-unknown-linux-gnu p
671
738
package-aarch64-unknown-linux-musl-all : package-archive-aarch64-unknown-linux-musl package-deb-aarch64 package-rpm-aarch64 # Build all aarch64 MUSL packages
672
739
673
740
# archives
741
+ .PHONY : package-archive
742
+
743
+ target/artifacts/vector-% .tar.gz : export TRIPLE :=$(@:target/artifacts/vector-%.tar.gz=% )
744
+ target/artifacts/vector-% .tar.gz : target/% /release/vector.tar.gz
745
+ @echo " Built to ${<} , relocating to ${@ } "
746
+ @mkdir -p target/artifacts/
747
+ @cp -v \
748
+ ${<} \
749
+ ${@ }
674
750
675
751
package-archive : build # # Build the Vector archive
676
752
${MAYBE_ENVIRONMENT_EXEC} ./scripts/package-archive.sh
677
753
754
+ .PHONY : package-archive-all
678
755
package-archive-all : package-archive-x86_64-unknown-linux-musl package-archive-x86_64-unknown-linux-gnu package-archive-aarch64-unknown-linux-musl # # Build all archives
679
756
757
+ .PHONY : package-archive-x86_64-unknown-linux-musl
680
758
package-archive-x86_64-unknown-linux-musl : build-x86_64-unknown-linux-musl # # Build the x86_64 archive
681
759
$(RUN ) package-archive-x86_64-unknown-linux-musl
682
760
683
- package-archive-x86_64-unknown-linux-gnu : build-x86_64-unknown-linux-gnu # # Build the x86_64 archive
684
- $(RUN ) package-archive-x86_64-unknown-linux-gnu
761
+ .PHONY : package-archive-x86_64-unknown-linux-gnu
762
+ package-archive-x86_64-unknown-linux-gnu : target/artifacts/vector-x86_64-unknown-linux-gnu.tar.gz # # Build an archive of the x86_64-unknown-linux-gnu triple.
763
+ @echo " Output to ${<} ."
685
764
686
- package-archive-aarch64-unknown-linux-musl : build-aarch64-unknown-linux-musl # # Build the aarch64 archive
765
+ .PHONY : package-archive-aarch64-unknown-linux-musl
766
+ package-archive-aarch64-unknown-linux-musl : build-aarch64-unknown-linux-musl # # Build an archive of the aarch64-unknown-linux-gnu triple.
687
767
$(RUN ) package-archive-aarch64-unknown-linux-musl
688
768
769
+ .PHONY : package-archive-aarch64-unknown-linux-gnu
770
+ package-archive-aarch64-unknown-linux-gnu : target/artifacts/vector-aarch64-unknown-linux-gnu.tar.gz # # Build the aarch64 archive
771
+ @echo " Output to ${<} ."
772
+
773
+
689
774
# debs
690
775
691
776
package-deb : # # Build the deb package
@@ -825,6 +910,10 @@ git-hooks: ## Add Vector-local git hooks for commit sign-off
825
910
update-kubernetes-yaml : # # Regenerate the Kubernetes YAML config
826
911
${MAYBE_ENVIRONMENT_EXEC} ./scripts/kubernetes-yaml.sh update
827
912
913
+ cargo-install-% : override TOOL = $(@:cargo-install-%=% )
914
+ cargo-install-% :
915
+ $(if $(findstring true,$(AUTOINSTALL ) ) ,${MAYBE_ENVIRONMENT_EXEC} cargo install ${TOOL} --quiet,)
916
+
828
917
.PHONY : ensure-has-wasm-toolchain # ## Configures a wasm toolchain for test artifact building, if required
829
918
ensure-has-wasm-toolchain : target/wasm32-wasi/.obtained
830
919
target/wasm32-wasi/.obtained :
0 commit comments