Set --ninja_suffix based on make/mm/mmm targets

This fixes two issues:

- Switching make target didn't work well when the latter
  make target is not a subset of the first make target.
- Switching between m and mm/mmm forced build.ninja to be
  regenerated.

Bug: 23685536

Change-Id: I3c3550d6cca3007d166a13367d6bc22cc3feede2
This commit is contained in:
Shinichiro Hamaji 2015-09-01 14:24:18 +09:00
parent ec8f973147
commit bfd01872cb
1 changed files with 17 additions and 5 deletions

View File

@ -1,9 +1,21 @@
KATI ?= $(HOST_OUT_EXECUTABLES)/ckati
KATI_OUTPUTS := $(PRODUCT_OUT)/build.ninja $(PRODUCT_OUT)/ninja.sh
KATI_OUTPUT_PATTERNS := $(PRODUCT_OUT)/build%.ninja $(PRODUCT_OUT)/ninja%.sh
NINJA_GOALS := fastincremental generateonly droid showcommands
ANDROID_TARGETS := $(filter-out $(KATI_OUTPUTS) $(NINJA_GOALS),$(ORIGINAL_MAKECMDGOALS))
ANDROID_TARGETS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(NINJA_GOALS),$(ORIGINAL_MAKECMDGOALS))
KATI_NINJA_SUFFIX :=
ifneq ($(ANDROID_TARGETS),)
KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-$(subst $(space),_,$(sort $(ANDROID_TARGETS)))
endif
ifneq ($(ONE_SHOT_MAKEFILE),)
KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-mmm-$(subst /,_,$(strip $(ONE_SHOT_MAKEFILE)))
endif
KATI_BUILD_NINJA := $(PRODUCT_OUT)/build$(KATI_NINJA_SUFFIX).ninja
KATI_NINJA_SH := $(PRODUCT_OUT)/ninja$(KATI_NINJA_SUFFIX).sh
KATI_OUTPUTS := $(KATI_BUILD_NINJA) $(KATI_NINJA_SH)
ifeq (,$(NINJA_STATUS))
NINJA_STATUS := [%p %s/%t]$(space)
@ -22,7 +34,7 @@ fastincremental droid $(ANDROID_TARGETS): ninja.intermediate
.INTERMEDIATE: ninja.intermediate
ninja.intermediate: $(KATI_OUTPUTS)
@echo Starting build with ninja
$(hide) PATH=prebuilts/ninja/$(HOST_PREBUILT_TAG)/:$$PATH NINJA_STATUS="$(NINJA_STATUS)" $(PRODUCT_OUT)/ninja.sh -C $(TOP) $(NINJA_ARGS) $(ANDROID_TARGETS)
$(hide) PATH=prebuilts/ninja/$(HOST_PREBUILT_TAG)/:$$PATH NINJA_STATUS="$(NINJA_STATUS)" $(KATI_NINJA_SH) -C $(TOP) $(NINJA_ARGS) $(ANDROID_TARGETS)
else
generateonly droid $(ANDROID_TARGETS): $(KATI_OUTPUTS)
@#empty
@ -36,9 +48,9 @@ $(KATI_OUTPUTS): kati.intermediate $(KATI_FORCE)
.INTERMEDIATE: kati.intermediate
kati.intermediate: $(KATI)
@echo Running kati to generate build.ninja...
@echo Running kati to generate build$(KATI_NINJA_SUFFIX).ninja...
@#TODO: use separate ninja file for mm or single target build
$(hide) $(KATI) --ninja --ninja_dir=$(PRODUCT_OUT) --regen --ignore_dirty=$(OUT_DIR)/% --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo --use_find_emulator $(KATI_REMOTE_NUM_JOBS_FLAG) -f build/core/main.mk $(ANDROID_TARGETS) USE_NINJA=false
$(hide) $(KATI) --ninja --ninja_dir=$(PRODUCT_OUT) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo --use_find_emulator $(KATI_REMOTE_NUM_JOBS_FLAG) -f build/core/main.mk $(ANDROID_TARGETS) USE_NINJA=false
KATI_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CPPFLAGS)
KATI_LD := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_LDFLAGS)