From d54ee9689db9ce94f655adbd15974953c9bab1f5 Mon Sep 17 00:00:00 2001 From: kwantam Date: Sun, 26 Apr 2015 03:42:55 -0400 Subject: [PATCH] do not consider deps for EXESs when making goal "test" In the normal case, one does, e.g., make TEST="cat" test This means that the value of EXES in the Makefile contains all possible targets, which means many prerequisites that aren't required get built. With this change, when the `test` target is in effect (and, in particular, *only* the test target), then the value of EXES is ignored when calculating dependencies. Otherwise, the values of EXES and TESTS are both considered. --- Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 750bfbc5e..7a3822151 100644 --- a/Makefile +++ b/Makefile @@ -183,7 +183,13 @@ endef DEPLIBS := libc DEPPLUGS := # now, add in deps in src/utilname/deps.mk -$(foreach build,$(sort $(EXES) $(TESTS)),$(eval $(call DEP_INCLUDE,$(build)))) +# if we're testing, only consider the TESTS variable, +# otherwise consider the EXES variable +ifeq ($(MAKECMDGOALS),test) +$(foreach build,$(TESTS),$(eval $(call DEP_INCLUDE,$(build)))) +else +$(foreach build,$(sort $(TESTS) $(EXES)),$(eval $(call DEP_INCLUDE,$(build)))) +endif # uniqify deps DEPLIBS := $(sort $(DEPLIBS)) DEPPLUGS := $(sort $(DEPPLUGS)) @@ -248,8 +254,8 @@ endef # Test exe built rules define TEST_BUILD -test_$(1): $(TEMPDIR)/$(1)/$(1)_test $(BUILDDIR)/$(1) - $(call command,cp $(BUILDDIR)/$(1) $(TEMPDIR)/$(1) && cd $(TEMPDIR)/$(1) && $$<) +test_$(1): $(BUILDDIR)/$(1) $(TEMPDIR)/$(1)/$(1)_test + $(call command,cp $(BUILDDIR)/$(1) $(TEMPDIR)/$(1) && cd $(TEMPDIR)/$(1) && $(TEMPDIR)/$(1)/$(1)_test) $(TEMPDIR)/$(1)/$(1)_test: $(TESTDIR)/$(1).rs | $(TEMPDIR)/$(1) $(call command,$(RUSTC) $(RUSTCTESTFLAGS) $(DEP_EXTERN) --test -o $$@ $$<)