2016-01-07 08:00:00 +08:00
|
|
|
NINJA ?= prebuilts/ninja/$(HOST_PREBUILT_TAG)/ninja
|
|
|
|
|
|
|
|
ifeq ($(USE_SOONG),true)
|
|
|
|
USE_SOONG_FOR_KATI := true
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(USE_SOONG_FOR_KATI),true)
|
|
|
|
include $(BUILD_SYSTEM)/soong.mk
|
|
|
|
else
|
2015-07-17 08:27:52 +08:00
|
|
|
KATI ?= $(HOST_OUT_EXECUTABLES)/ckati
|
2015-09-06 15:35:21 +08:00
|
|
|
MAKEPARALLEL ?= $(HOST_OUT_EXECUTABLES)/makeparallel
|
2016-01-07 08:00:00 +08:00
|
|
|
endif
|
2015-07-17 08:27:52 +08:00
|
|
|
|
2015-09-30 12:37:40 +08:00
|
|
|
KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh
|
2015-10-29 03:34:03 +08:00
|
|
|
|
|
|
|
# Modifier goals we don't need to pass to Ninja.
|
|
|
|
NINJA_EXCLUDE_GOALS := showcommands all dist
|
|
|
|
.PHONY : $(NINJA_EXCLUDE_GOALS)
|
|
|
|
|
|
|
|
# A list of goals which affect parsing of makefiles and we need to pass to Kati.
|
2015-09-04 13:38:37 +08:00
|
|
|
PARSE_TIME_MAKE_GOALS := \
|
|
|
|
$(PARSE_TIME_MAKE_GOALS) \
|
|
|
|
$(dont_bother_goals) \
|
2015-10-29 03:34:03 +08:00
|
|
|
all \
|
2015-09-04 13:38:37 +08:00
|
|
|
APP-% \
|
|
|
|
DUMP_% \
|
|
|
|
ECLIPSE-% \
|
|
|
|
PRODUCT-% \
|
|
|
|
boottarball-nodeps \
|
|
|
|
btnod \
|
|
|
|
build-art% \
|
|
|
|
build_kernel-nodeps \
|
|
|
|
clean-oat% \
|
|
|
|
continuous_instrumentation_tests \
|
|
|
|
continuous_native_tests \
|
|
|
|
cts \
|
|
|
|
custom_images \
|
|
|
|
deps-license \
|
|
|
|
dicttool_aosp \
|
|
|
|
dist \
|
|
|
|
dump-products \
|
|
|
|
dumpvar-% \
|
|
|
|
eng \
|
|
|
|
fusion \
|
|
|
|
oem_image \
|
2016-03-05 20:05:49 +08:00
|
|
|
old-cts \
|
2015-09-04 13:38:37 +08:00
|
|
|
online-system-api-sdk-docs \
|
|
|
|
pdk \
|
|
|
|
platform \
|
|
|
|
platform-java \
|
|
|
|
product-graph \
|
|
|
|
samplecode \
|
|
|
|
sdk \
|
|
|
|
sdk_addon \
|
|
|
|
sdk_repo \
|
|
|
|
snod \
|
|
|
|
stnod \
|
|
|
|
systemimage-nodeps \
|
|
|
|
systemtarball-nodeps \
|
|
|
|
target-files-package \
|
|
|
|
test-art% \
|
|
|
|
user \
|
|
|
|
userdataimage \
|
|
|
|
userdebug \
|
|
|
|
valgrind-test-art% \
|
2016-04-01 22:39:48 +08:00
|
|
|
vts \
|
2015-09-04 13:38:37 +08:00
|
|
|
win_sdk \
|
|
|
|
winsdk-tools
|
|
|
|
|
|
|
|
-include vendor/google/build/ninja_config.mk
|
2015-07-17 08:27:52 +08:00
|
|
|
|
2015-10-29 03:34:03 +08:00
|
|
|
# Any Android goals that need to be built.
|
|
|
|
ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(KATI) $(MAKEPARALLEL),\
|
|
|
|
$(sort $(ORIGINAL_MAKECMDGOALS) $(MAKECMDGOALS)))
|
|
|
|
# Goals we need to pass to Ninja.
|
|
|
|
NINJA_GOALS := $(filter-out $(NINJA_EXCLUDE_GOALS), $(ANDROID_GOALS))
|
|
|
|
# Goals we need to pass to Kati.
|
|
|
|
KATI_GOALS := $(filter $(PARSE_TIME_MAKE_GOALS), $(ANDROID_GOALS))
|
2015-09-01 13:24:18 +08:00
|
|
|
|
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
|
|
|
|
ifneq ($(BUILD_MODULES_IN_PATHS),)
|
|
|
|
KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-mmma-$(call replace_space_and_slash,$(BUILD_MODULES_IN_PATHS))
|
2015-09-01 13:24:18 +08:00
|
|
|
endif
|
|
|
|
|
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))
|
|
|
|
NINJA_STATUS := [%p %s/%t]$(space)
|
|
|
|
endif
|
|
|
|
|
2015-07-29 08:57:45 +08:00
|
|
|
ifneq (,$(filter showcommands,$(ORIGINAL_MAKECMDGOALS)))
|
2015-07-17 08:27:52 +08:00
|
|
|
NINJA_ARGS += "-v"
|
|
|
|
endif
|
|
|
|
|
2015-09-24 15:22:44 +08:00
|
|
|
ifdef 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
|
|
|
|
NINJA_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
|
2015-09-06 15:35:21 +08:00
|
|
|
endif
|
|
|
|
|
2015-11-10 06:53:36 +08:00
|
|
|
ifeq ($(USE_SOONG),true)
|
|
|
|
COMBINED_BUILD_NINJA := $(OUT_DIR)/combined$(KATI_NINJA_SUFFIX).ninja
|
|
|
|
|
|
|
|
$(COMBINED_BUILD_NINJA): $(KATI_BUILD_NINJA) $(SOONG_ANDROID_MK)
|
|
|
|
$(hide) echo "builddir = $(OUT_DIR)" > $(COMBINED_BUILD_NINJA)
|
|
|
|
$(hide) echo "subninja $(SOONG_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
|
|
|
|
$(hide) echo "subninja $(KATI_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
|
|
|
|
else
|
|
|
|
COMBINED_BUILD_NINJA := $(KATI_BUILD_NINJA)
|
|
|
|
endif
|
|
|
|
|
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
|
2015-11-10 06:53:36 +08:00
|
|
|
+$(hide) export NINJA_STATUS="$(NINJA_STATUS)" && source $(KATI_ENV_SH) && $(NINJA_MAKEPARALLEL) $(NINJA) $(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): $(KATI) $(MAKEPARALLEL) $(DUMMY_OUT_MKS) $(SOONG_ANDROID_MK) FORCE
|
2015-09-01 13:24:18 +08:00
|
|
|
@echo Running kati to generate build$(KATI_NINJA_SUFFIX).ninja...
|
2015-11-10 06:53:36 +08:00
|
|
|
+$(hide) $(KATI_MAKEPARALLEL) $(KATI) --ninja --ninja_dir=$(OUT_DIR) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --no_ignore_dirty=$(SOONG_ANDROID_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)
|
2015-07-17 08:27:52 +08:00
|
|
|
|
2016-01-07 08:00:00 +08:00
|
|
|
ifneq ($(USE_SOONG_FOR_KATI),true)
|
2015-09-23 07:52:58 +08:00
|
|
|
KATI_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CFLAGS) $(CLANG_HOST_GLOBAL_CPPFLAGS)
|
2015-07-17 08:27:52 +08:00
|
|
|
KATI_LD := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_LDFLAGS)
|
2015-08-04 09:15:43 +08:00
|
|
|
# Build static ckati. Unfortunately Mac OS X doesn't officially support static exectuables.
|
|
|
|
ifeq ($(BUILD_OS),linux)
|
2016-02-26 15:58:13 +08:00
|
|
|
# We need everything in libpthread.a otherwise C++11's threading library will be disabled.
|
|
|
|
KATI_LD += -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -ldl
|
2015-08-04 09:15:43 +08:00
|
|
|
endif
|
|
|
|
|
2015-07-17 08:27:52 +08:00
|
|
|
KATI_INTERMEDIATES_PATH := $(HOST_OUT_INTERMEDIATES)/EXECUTABLES/ckati_intermediates
|
|
|
|
KATI_BIN_PATH := $(HOST_OUT_EXECUTABLES)
|
|
|
|
include build/kati/Makefile.ckati
|
|
|
|
|
2015-09-30 12:54:33 +08:00
|
|
|
MAKEPARALLEL_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CFLAGS) $(CLANG_HOST_GLOBAL_CPPFLAGS)
|
2015-09-06 15:35:21 +08:00
|
|
|
MAKEPARALLEL_LD := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_LDFLAGS)
|
|
|
|
# Build static makeparallel. Unfortunately Mac OS X doesn't officially support static exectuables.
|
|
|
|
ifeq ($(BUILD_OS),linux)
|
|
|
|
MAKEPARALLEL_LD += -static
|
|
|
|
endif
|
|
|
|
|
|
|
|
MAKEPARALLEL_INTERMEDIATES_PATH := $(HOST_OUT_INTERMEDIATES)/EXECUTABLES/makeparallel_intermediates
|
|
|
|
MAKEPARALLEL_BIN_PATH := $(HOST_OUT_EXECUTABLES)
|
|
|
|
include build/tools/makeparallel/Makefile
|
2016-01-07 08:00:00 +08:00
|
|
|
endif
|
2015-09-06 15:35:21 +08:00
|
|
|
|
2015-07-17 08:27:52 +08:00
|
|
|
.PHONY: FORCE
|
|
|
|
FORCE:
|