2016-01-07 08:00:00 +08:00
|
|
|
include $(BUILD_SYSTEM)/soong.mk
|
2015-07-17 08:27:52 +08:00
|
|
|
|
2015-10-29 03:34:03 +08:00
|
|
|
# Modifier goals we don't need to pass to Ninja.
|
|
|
|
.PHONY : $(NINJA_EXCLUDE_GOALS)
|
|
|
|
|
2015-09-04 10:41:33 +08:00
|
|
|
define replace_space_and_slash
|
|
|
|
$(subst /,_,$(subst $(space),_,$(sort $1)))
|
|
|
|
endef
|
|
|
|
|
2015-09-30 12:37:40 +08:00
|
|
|
KATI_NINJA_SUFFIX := -$(TARGET_PRODUCT)
|
2015-10-29 03:34:03 +08:00
|
|
|
ifneq ($(KATI_GOALS),)
|
|
|
|
KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-$(call replace_space_and_slash,$(KATI_GOALS))
|
2015-09-01 13:24:18 +08:00
|
|
|
endif
|
|
|
|
ifneq ($(ONE_SHOT_MAKEFILE),)
|
2015-09-04 10:41:33 +08:00
|
|
|
KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-mmm-$(call replace_space_and_slash,$(ONE_SHOT_MAKEFILE))
|
|
|
|
endif
|
2015-09-01 13:24:18 +08:00
|
|
|
|
2015-09-23 05:37:53 +08:00
|
|
|
my_checksum_suffix :=
|
|
|
|
my_ninja_suffix_too_long := $(filter 1, $(shell v='$(KATI_NINJA_SUFFIX)' && echo $$(($${$(pound)v} > 64))))
|
|
|
|
ifneq ($(my_ninja_suffix_too_long),)
|
|
|
|
# Replace the suffix with a checksum if it gets too long.
|
|
|
|
my_checksum_suffix := $(KATI_NINJA_SUFFIX)
|
|
|
|
KATI_NINJA_SUFFIX := -$(word 1, $(shell echo $(my_checksum_suffix) | $(MD5SUM)))
|
|
|
|
endif
|
|
|
|
|
2015-09-30 12:37:40 +08:00
|
|
|
KATI_BUILD_NINJA := $(OUT_DIR)/build$(KATI_NINJA_SUFFIX).ninja
|
2015-11-10 06:21:12 +08:00
|
|
|
KATI_ENV_SH := $(OUT_DIR)/env$(KATI_NINJA_SUFFIX).sh
|
2015-09-23 05:37:53 +08:00
|
|
|
|
|
|
|
# Write out a file mapping checksum to the real suffix.
|
|
|
|
ifneq ($(my_checksum_suffix),)
|
|
|
|
my_ninja_suffix_file := $(basename $(KATI_BUILD_NINJA)).suf
|
|
|
|
$(shell mkdir -p $(dir $(my_ninja_suffix_file)) && \
|
|
|
|
echo $(my_checksum_suffix) > $(my_ninja_suffix_file))
|
|
|
|
endif
|
|
|
|
|
2015-07-17 08:27:52 +08:00
|
|
|
ifeq (,$(NINJA_STATUS))
|
2016-06-01 03:38:04 +08:00
|
|
|
NINJA_STATUS := [%p %f/%t]$(space)
|
2015-07-17 08:27:52 +08:00
|
|
|
endif
|
|
|
|
|
2016-05-06 07:52:37 +08:00
|
|
|
NINJA_EXTRA_ARGS :=
|
|
|
|
|
2015-07-29 08:57:45 +08:00
|
|
|
ifneq (,$(filter showcommands,$(ORIGINAL_MAKECMDGOALS)))
|
2016-05-06 07:52:37 +08:00
|
|
|
NINJA_EXTRA_ARGS += "-v"
|
2015-07-17 08:27:52 +08:00
|
|
|
endif
|
|
|
|
|
2015-09-24 04:52:22 +08:00
|
|
|
# Make multiple rules to generate the same target an error instead of
|
|
|
|
# proceeding with undefined behavior.
|
2016-05-06 07:52:37 +08:00
|
|
|
NINJA_EXTRA_ARGS += -w dupbuild=err
|
2015-09-24 04:52:22 +08:00
|
|
|
|
2016-08-28 09:29:08 +08:00
|
|
|
ifneq ($(filter-out false,$(USE_GOMA)),)
|
2015-09-06 15:35:21 +08:00
|
|
|
KATI_MAKEPARALLEL := $(MAKEPARALLEL)
|
2015-09-24 15:22:44 +08:00
|
|
|
# Ninja runs remote jobs (i.e., commands which contain gomacc) with
|
|
|
|
# this parallelism. Note the parallelism of all other jobs is still
|
|
|
|
# limited by the -j flag passed to GNU make.
|
|
|
|
NINJA_REMOTE_NUM_JOBS ?= 500
|
2016-05-06 07:52:37 +08:00
|
|
|
NINJA_EXTRA_ARGS += -j$(NINJA_REMOTE_NUM_JOBS)
|
2015-09-06 15:35:21 +08:00
|
|
|
else
|
2015-09-19 05:54:40 +08:00
|
|
|
NINJA_MAKEPARALLEL := $(MAKEPARALLEL) --ninja
|
2016-09-09 08:08:31 +08:00
|
|
|
|
|
|
|
# We never want Kati to see MAKEFLAGS, as forcefully overriding variables is
|
|
|
|
# terrible. The variables in MAKEFLAGS are still available in the environment,
|
|
|
|
# so if part of the build wants input from the user, it should be explicitly
|
|
|
|
# checking for an environment variable or using ?=
|
|
|
|
#
|
|
|
|
# makeparallel already clears MAKEFLAGS, so it's not necessary in the GOMA case
|
|
|
|
KATI_MAKEPARALLEL := MAKEFLAGS=
|
2015-09-06 15:35:21 +08:00
|
|
|
endif
|
|
|
|
|
2016-05-06 07:52:37 +08:00
|
|
|
NINJA_ARGS += $(NINJA_EXTRA_ARGS)
|
|
|
|
|
2015-11-10 06:53:36 +08:00
|
|
|
COMBINED_BUILD_NINJA := $(OUT_DIR)/combined$(KATI_NINJA_SUFFIX).ninja
|
|
|
|
|
2016-11-03 07:24:52 +08:00
|
|
|
$(COMBINED_BUILD_NINJA): $(KATI_BUILD_NINJA) FORCE
|
2015-11-10 06:53:36 +08:00
|
|
|
$(hide) echo "builddir = $(OUT_DIR)" > $(COMBINED_BUILD_NINJA)
|
2016-09-01 00:35:32 +08:00
|
|
|
$(hide) echo "include $(KATI_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
|
|
|
|
$(hide) echo "include $(SOONG_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
|
2016-11-03 07:24:52 +08:00
|
|
|
$(hide) echo "build $(COMBINED_BUILD_NINJA): phony $(SOONG_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
|
2015-11-10 06:53:36 +08:00
|
|
|
|
2015-10-29 03:34:03 +08:00
|
|
|
$(sort $(DEFAULT_GOAL) $(ANDROID_GOALS)) : ninja_wrapper
|
2015-07-17 08:27:52 +08:00
|
|
|
@#empty
|
|
|
|
|
2015-10-29 04:28:11 +08:00
|
|
|
.PHONY: ninja_wrapper
|
2015-11-10 06:53:36 +08:00
|
|
|
ninja_wrapper: $(COMBINED_BUILD_NINJA) $(MAKEPARALLEL)
|
2015-07-17 08:27:52 +08:00
|
|
|
@echo Starting build with ninja
|
2016-10-04 04:38:27 +08:00
|
|
|
+$(hide) export NINJA_STATUS="$(NINJA_STATUS)" && source $(KATI_ENV_SH) && exec $(NINJA_MAKEPARALLEL) $(NINJA) -d keepdepfile $(NINJA_GOALS) -C $(TOP) -f $(COMBINED_BUILD_NINJA) $(NINJA_ARGS)
|
2015-07-17 08:27:52 +08:00
|
|
|
|
2016-03-23 05:44:17 +08:00
|
|
|
# Dummy Android.mk and CleanSpec.mk files so that kati won't recurse into the
|
|
|
|
# out directory
|
|
|
|
DUMMY_OUT_MKS := $(OUT_DIR)/Android.mk $(OUT_DIR)/CleanSpec.mk
|
|
|
|
$(DUMMY_OUT_MKS):
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) echo '# This file prevents findleaves.py from traversing this directory further' >$@
|
|
|
|
|
2015-10-07 10:40:11 +08:00
|
|
|
KATI_FIND_EMULATOR := --use_find_emulator
|
|
|
|
ifeq ($(KATI_EMULATE_FIND),false)
|
|
|
|
KATI_FIND_EMULATOR :=
|
|
|
|
endif
|
2016-03-23 05:44:17 +08:00
|
|
|
$(KATI_BUILD_NINJA): $(CKATI) $(MAKEPARALLEL) $(DUMMY_OUT_MKS) run_soong FORCE
|
2015-09-01 13:24:18 +08:00
|
|
|
@echo Running kati to generate build$(KATI_NINJA_SUFFIX).ninja...
|
2016-06-16 05:55:58 +08:00
|
|
|
+$(hide) $(KATI_MAKEPARALLEL) $(CKATI) --ninja --ninja_dir=$(OUT_DIR) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --no_ignore_dirty=$(SOONG_OUT_DIR)/%.mk --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo $(KATI_FIND_EMULATOR) -f build/core/main.mk $(KATI_GOALS) --gen_all_targets BUILDING_WITH_NINJA=true SOONG_ANDROID_MK=$(SOONG_ANDROID_MK) SOONG_MAKEVARS_MK=$(SOONG_MAKEVARS_MK)
|
2015-09-06 15:35:21 +08:00
|
|
|
|
2015-07-17 08:27:52 +08:00
|
|
|
.PHONY: FORCE
|
|
|
|
FORCE:
|