1ifeq ($(filter address,$(SANITIZE_HOST)),)
2NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/ninja
3else
4NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/asan/bin/ninja
5endif
6
7KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh
8
9# Modifier goals we don't need to pass to Ninja.
10NINJA_EXCLUDE_GOALS := all
11
12# A list of goals which affect parsing of makefiles and we need to pass to Kati.
13PARSE_TIME_MAKE_GOALS := \
14	$(PARSE_TIME_MAKE_GOALS) \
15	$(dont_bother_goals) \
16	all \
17	brillo_tests \
18	btnod \
19	build-art% \
20	build_kernel-nodeps \
21	clean-oat% \
22	continuous_instrumentation_tests \
23	continuous_native_tests \
24	cts \
25	custom_images \
26	dicttool_aosp \
27	docs \
28	eng \
29	oem_image \
30	online-system-api-sdk-docs \
31	product-graph \
32	samplecode \
33	sdk \
34	sdk_addon \
35	sdk_repo \
36	stnod \
37	test-art% \
38	user \
39	userdataimage \
40	userdebug
41
42include $(wildcard vendor/*/build/ninja_config.mk)
43
44# Any Android goals that need to be built.
45ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS),\
46    $(sort $(ORIGINAL_MAKECMDGOALS) $(MAKECMDGOALS)))
47# Temporary compatibility support until the build server configs are updated
48ANDROID_GOALS := $(patsubst win_sdk,sdk,$(ANDROID_GOALS))
49ifneq ($(HOST_OS),linux)
50  ANDROID_GOALS := $(filter-out sdk,$(ANDROID_GOALS))
51  ANDROID_GOALS := $(patsubst sdk_repo,sdk-repo-build-tools sdk-repo-platform-tools,$(ANDROID_GOALS))
52endif
53# Goals we need to pass to Ninja.
54NINJA_GOALS := $(filter-out $(NINJA_EXCLUDE_GOALS), $(ANDROID_GOALS))
55ifndef NINJA_GOALS
56  NINJA_GOALS := droid
57endif
58# Goals we need to pass to Kati.
59KATI_GOALS := $(filter $(PARSE_TIME_MAKE_GOALS), $(ANDROID_GOALS))
60