зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1329737 - part 2 - turn CARGO_BUILD into a callable function; r=rillian
This change paves the way for injecting target- or host-specific environment variables for a particular `cargo build` invocation. Doing this is not strictly necessary: all of our current `cargo build` invocations use mostly target-specific environment variables (e.g. PKG_CONFIG_ALLOW_CROSS). But separating things out makes the code notationally cleaner and also avoids weirdness when target==host.
This commit is contained in:
Родитель
d9e05176d0
Коммит
67c11f7395
|
@ -963,7 +963,15 @@ else
|
|||
environment_cleaner =
|
||||
endif
|
||||
|
||||
CARGO_BUILD = env $(environment_cleaner) $(rustflags_override) \
|
||||
# This function is intended to be called by:
|
||||
#
|
||||
# $(call CARGO_BUILD,EXTRA_ENV_VAR1=X EXTRA_ENV_VAR2=Y ...)
|
||||
#
|
||||
# but, given the idiosyncracies of make, can also be called without arguments:
|
||||
#
|
||||
# $(call CARGO_BUILD)
|
||||
define CARGO_BUILD
|
||||
env $(environment_cleaner) $(rustflags_override) \
|
||||
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
|
||||
RUSTC=$(RUSTC) \
|
||||
MOZ_DIST=$(ABS_DIST) \
|
||||
|
@ -972,7 +980,9 @@ CARGO_BUILD = env $(environment_cleaner) $(rustflags_override) \
|
|||
PKG_CONFIG_ALLOW_CROSS=1 \
|
||||
RUST_BACKTRACE=1 \
|
||||
MOZ_TOPOBJDIR=$(topobjdir) \
|
||||
$(1) \
|
||||
$(CARGO) build $(cargo_build_flags)
|
||||
endef
|
||||
|
||||
ifdef RUST_LIBRARY_FILE
|
||||
|
||||
|
@ -987,7 +997,7 @@ endif
|
|||
# build.
|
||||
force-cargo-library-build:
|
||||
$(REPORT_BUILD)
|
||||
$(CARGO_BUILD) --lib $(cargo_target_flag) $(rust_features_flag)
|
||||
$(call CARGO_BUILD) --lib $(cargo_target_flag) $(rust_features_flag)
|
||||
|
||||
$(RUST_LIBRARY_FILE): force-cargo-library-build
|
||||
endif # RUST_LIBRARY_FILE
|
||||
|
@ -1000,7 +1010,7 @@ endif
|
|||
|
||||
force-cargo-host-library-build:
|
||||
$(REPORT_BUILD)
|
||||
$(CARGO_BUILD) --lib $(cargo_host_flag) $(host_rust_features_flag)
|
||||
$(call CARGO_BUILD) --lib $(cargo_host_flag) $(host_rust_features_flag)
|
||||
|
||||
$(HOST_RUST_LIBRARY_FILE): force-cargo-host-library-build
|
||||
endif # HOST_RUST_LIBRARY_FILE
|
||||
|
@ -1008,14 +1018,14 @@ endif # HOST_RUST_LIBRARY_FILE
|
|||
ifdef RUST_PROGRAMS
|
||||
force-cargo-program-build:
|
||||
$(REPORT_BUILD)
|
||||
$(CARGO_BUILD) $(addprefix --bin ,$(RUST_CARGO_PROGRAMS)) $(cargo_target_flag)
|
||||
$(call CARGO_BUILD) $(addprefix --bin ,$(RUST_CARGO_PROGRAMS)) $(cargo_target_flag)
|
||||
|
||||
$(RUST_PROGRAMS): force-cargo-program-build
|
||||
endif # RUST_PROGRAMS
|
||||
ifdef HOST_RUST_PROGRAMS
|
||||
force-cargo-host-program-build:
|
||||
$(REPORT_BUILD)
|
||||
$(CARGO_BUILD) $(addprefix --bin ,$(HOST_RUST_CARGO_PROGRAMS)) $(cargo_host_flag)
|
||||
$(call CARGO_BUILD) $(addprefix --bin ,$(HOST_RUST_CARGO_PROGRAMS)) $(cargo_host_flag)
|
||||
|
||||
$(HOST_RUST_PROGRAMS): force-cargo-host-program-build
|
||||
endif # HOST_RUST_PROGRAMS
|
||||
|
|
Загрузка…
Ссылка в новой задаче