From 4b0bc59e626786d2b0ebd0dd4c7ade2c257e05a8 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 8 Nov 2022 09:58:31 +0100 Subject: [PATCH] Makefile now handle TARGET_DIR env. var. for build too --- Makefile | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 2241b1b33f6..ba431224048 100644 --- a/Makefile +++ b/Makefile @@ -283,12 +283,16 @@ endif HOST_TARGET=$(shell rustup show | grep 'Default host: ' | cut -d':' -f2 | tr -d ' ') -TARGET_DIR ?= target/release +TARGET_DIR ?= ifneq (, $(TARGET)) TARGET_DIR ?= target/$(TARGET)/release endif +ifneq (, $(TARGET_DIR)) + target_dir := --target-dir "$(TARGET_DIR)" +endif + $(info -----------) $(info $(bold)$(green)INFORMATION$(reset)) $(info -----------) @@ -362,7 +366,7 @@ check-capi: capi-setup --no-default-features --features wat,compiler,wasi,middlewares $(capi_compiler_features) build-wasmer: - $(CARGO_BINARY) build $(CARGO_TARGET) --release --manifest-path lib/cli/Cargo.toml $(compiler_features) --features="webc_runner" --bin wasmer + $(CARGO_BINARY) build $(CARGO_TARGET) --release --manifest-path lib/cli/Cargo.toml $(compiler_features) --features="webc_runner" --bin wasmer $(target_dir) build-wasmer-debug: $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/cli/Cargo.toml $(compiler_features) --features "webc_runner,debug" --bin wasmer @@ -421,50 +425,50 @@ build-docs-capi: capi-setup # when generating the documentation, we rename it to its # crate's name. Then we restore the lib's name. sed "$(SEDI)" -e 's/name = "wasmer" # ##lib.name##/name = "wasmer_c_api" # ##lib.name##/' lib/c-api/Cargo.toml - RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) doc $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,compiler,cranelift,wasi + RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) doc $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,compiler,cranelift,wasi $(target_dir) sed "$(SEDI)" -e 's/name = "wasmer_c_api" # ##lib.name##/name = "wasmer" # ##lib.name##/' lib/c-api/Cargo.toml build-capi: capi-setup - RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ + RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release $(target_dir) \ --no-default-features --features wat,compiler,wasi,middlewares,webc_runner $(capi_compiler_features) build-capi-singlepass: capi-setup - RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ + RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release $(target_dir) \ --no-default-features --features wat,compiler,singlepass,wasi,middlewares,webc_runner build-capi-singlepass-universal: capi-setup - RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ + RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release $(target_dir) \ --no-default-features --features wat,compiler,singlepass,wasi,middlewares,webc_runner build-capi-cranelift: capi-setup - RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ + RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release $(target_dir) \ --no-default-features --features wat,compiler,cranelift,wasi,middlewares,webc_runner build-capi-cranelift-universal: capi-setup - RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ + RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release $(target_dir) \ --no-default-features --features wat,compiler,cranelift,wasi,middlewares,webc_runner build-capi-llvm: capi-setup - RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ + RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release $(target_dir) \ --no-default-features --features wat,compiler,llvm,wasi,middlewares,webc_runner build-capi-llvm-universal: capi-setup - RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ + RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release $(target_dir) \ --no-default-features --features wat,compiler,llvm,wasi,middlewares,webc_runner # Headless (we include the minimal to be able to run) build-capi-headless: capi-setup ifeq ($(CARGO_TARGET),) - RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build --target $(HOST_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ + RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build --target $(HOST_TARGET) --manifest-path lib/c-api/Cargo.toml --release $(target_dir) \ --no-default-features --features compiler-headless,wasi else - RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \ + RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release $(target_dir) \ --no-default-features --features compiler-headless,wasi endif build-capi-headless-ios: capi-setup - RUSTFLAGS="${RUSTFLAGS} -C panic=abort" cargo lipo --manifest-path lib/c-api/Cargo.toml --release \ + RUSTFLAGS="${RUSTFLAGS} -C panic=abort" cargo lipo --manifest-path lib/c-api/Cargo.toml --release $(target_dir) \ --no-default-features --features compiler-headless,wasi #####