Bug 1378440 - part 1 - make Cargo invocation macro more generic; r=rillian
authorNathan Froyd <froydnj@mozilla.com>
Wed, 05 Jul 2017 14:19:31 -0400
changeset 367478 4168fad05a1151e4805f5d1d925bd5d187c4e5d0
parent 367477 bd35803f53f855b8e32a0a6b2f82ac43f2da5327
child 367479 90323301d1b1e3cee4d688c2f1583d8f19c1054b
push id32135
push userkwierso@gmail.com
push dateThu, 06 Jul 2017 00:12:17 +0000
treeherdermozilla-central@af0466865a21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs1378440
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1378440 - part 1 - make Cargo invocation macro more generic; r=rillian All the machinery we set up for `cargo build` is equally useful for other commands, such as `cargo check`. Let's refactor things so that it's easy to reuse said machinery for `cargo check`.
config/rules.mk
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -901,37 +901,40 @@ rust_unlock_unstable =
 ifdef MOZ_RUST_SIMD
 rust_unlock_unstable += RUSTC_BOOTSTRAP=1
 endif
 
 ifdef MOZ_USING_SCCACHE
 sccache_wrap := RUSTC_WRAPPER='$(CCACHE)'
 endif
 
-
-# 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
+define RUN_CARGO
 env $(environment_cleaner) $(rust_unlock_unstable) $(rustflags_override) $(sccache_wrap) \
 	CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
 	RUSTC=$(RUSTC) \
 	MOZ_SRC=$(topsrcdir) \
 	MOZ_DIST=$(ABS_DIST) \
 	LIBCLANG_PATH="$(MOZ_LIBCLANG_PATH)" \
 	CLANG_PATH="$(MOZ_CLANG_PATH)" \
 	PKG_CONFIG_ALLOW_CROSS=1 \
 	RUST_BACKTRACE=1 \
 	MOZ_TOPOBJDIR=$(topobjdir) \
-	$(1) \
-	$(CARGO) build $(cargo_build_flags)
+	$(2) \
+	$(CARGO) $(1) $(cargo_build_flags)
+endef
+
+# 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
+$(call RUN_CARGO,build,$(1))
 endef
 
 cargo_linker_env_var := CARGO_TARGET_$(RUST_TARGET_ENV_NAME)_LINKER
 
 # Don't define a custom linker on Windows, as it's difficult to have a
 # non-binary file that will get executed correctly by Cargo.  We don't
 # have to worry about a cross-compiling (besides x86-64 -> x86, which
 # already works with the current setup) setup on Windows, and we don't