blob: c2c9e6c05ec207102f5d9596ea4cf23a4a4ab0ea [file] [log] [blame]
Colin Cross3ebb2f72015-11-09 14:53:36 -08001SOONG := $(SOONG_OUT_DIR)/soong
Dan Willemsencc60f012016-03-22 14:44:17 -07002SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap
Colin Cross3ebb2f72015-11-09 14:53:36 -08003SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja
Dan Willemsen5f38f9b2015-12-11 13:50:00 -08004SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make
Dan Willemsen8b999ac2016-03-29 12:32:16 -07005SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk
Dan Willemsencc60f012016-03-22 14:44:17 -07006SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables
Dan Willemsen57aa9202016-05-11 00:23:38 -07007SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk
Dan Willemsen2d12ce12016-03-10 15:03:41 -08008
Dan Willemsencc60f012016-03-22 14:44:17 -07009# We need to rebootstrap soong if SOONG_OUT_DIR or the reverse path from
10# SOONG_OUT_DIR to TOP changes
11SOONG_NEEDS_REBOOTSTRAP :=
12ifneq ($(wildcard $(SOONG_BOOTSTRAP)),)
13 ifneq ($(SOONG_OUT_DIR),$(strip $(shell source $(SOONG_BOOTSTRAP); echo $$BUILDDIR)))
14 SOONG_NEEDS_REBOOTSTRAP := FORCE
15 $(warning soong_out_dir changed)
16 endif
Colin Cross367ab292016-05-02 15:31:17 -070017 ifneq ($(strip $(shell build/soong/scripts/reverse_path.py $(SOONG_OUT_DIR))),$(strip $(shell source $(SOONG_BOOTSTRAP); echo $$SRCDIR_FROM_BUILDDIR)))
Dan Willemsencc60f012016-03-22 14:44:17 -070018 SOONG_NEEDS_REBOOTSTRAP := FORCE
19 $(warning reverse path changed)
20 endif
21endif
22
23# Bootstrap soong.
24$(SOONG_BOOTSTRAP): bootstrap.bash $(SOONG_NEEDS_REBOOTSTRAP)
Colin Cross3ebb2f72015-11-09 14:53:36 -080025 $(hide) mkdir -p $(dir $@)
Dan Willemsencc60f012016-03-22 14:44:17 -070026 $(hide) BUILDDIR=$(SOONG_OUT_DIR) ./bootstrap.bash
Colin Cross3ebb2f72015-11-09 14:53:36 -080027
28# Create soong.variables with copies of makefile settings. Runs every build,
29# but only updates soong.variables if it changes
30SOONG_VARIABLES_TMP := $(SOONG_VARIABLES).$$$$
31$(SOONG_VARIABLES): FORCE
32 $(hide) mkdir -p $(dir $@)
33 $(hide) (\
34 echo '{'; \
Dan Willemsen57aa9202016-05-11 00:23:38 -070035 echo ' "Make_suffix": "-$(TARGET_PRODUCT)",'; \
36 echo ''; \
Colin Cross3ebb2f72015-11-09 14:53:36 -080037 echo ' "Platform_sdk_version": $(PLATFORM_SDK_VERSION),'; \
38 echo ' "Unbundled_build": $(if $(TARGET_BUILD_APPS),true,false),'; \
39 echo ' "Brillo": $(if $(BRILLO),true,false),'; \
Dan Willemsen60899ed2016-03-01 15:21:15 -080040 echo ' "Malloc_not_svelte": $(if $(filter true,$(MALLOC_SVELTE)),false,true),'; \
Dan Willemsen721f9bd2016-03-16 11:12:41 -070041 echo ' "Allow_missing_dependencies": $(if $(TARGET_BUILD_APPS)$(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),true,false),'; \
Colin Cross4e2c57a2016-01-04 14:33:45 -080042 echo ' "SanitizeHost": [$(if $(SANITIZE_HOST),"$(subst $(comma),"$(comma)",$(SANITIZE_HOST))")],'; \
43 echo ' "SanitizeDevice": [$(if $(SANITIZE_TARGET),"$(subst $(comma),"$(comma)",$(SANITIZE_TARGET))")],'; \
Dan Willemsencba15572016-05-17 16:40:03 -070044 echo ' "HostStaticBinaries": $(if $(strip $(BUILD_HOST_static)),true,false),'; \
Colin Cross3ebb2f72015-11-09 14:53:36 -080045 echo ''; \
46 echo ' "DeviceName": "$(TARGET_DEVICE)",'; \
47 echo ' "DeviceArch": "$(TARGET_ARCH)",'; \
48 echo ' "DeviceArchVariant": "$(TARGET_ARCH_VARIANT)",'; \
49 echo ' "DeviceCpuVariant": "$(TARGET_CPU_VARIANT)",'; \
50 echo ' "DeviceAbi": ["$(TARGET_CPU_ABI)", "$(TARGET_CPU_ABI2)"],'; \
51 echo ' "DeviceUsesClang": $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false),'; \
52 echo ''; \
53 echo ' "DeviceSecondaryArch": "$(TARGET_2ND_ARCH)",'; \
54 echo ' "DeviceSecondaryArchVariant": "$(TARGET_2ND_ARCH_VARIANT)",'; \
55 echo ' "DeviceSecondaryCpuVariant": "$(TARGET_2ND_CPU_VARIANT)",'; \
56 echo ' "DeviceSecondaryAbi": ["$(TARGET_2ND_CPU_ABI)", "$(TARGET_2ND_CPU_ABI2)"],'; \
57 echo ''; \
58 echo ' "HostArch": "$(HOST_ARCH)",'; \
Dan Willemsend6e3b842016-02-09 14:55:13 -080059 echo ' "HostSecondaryArch": "$(HOST_2ND_ARCH)",'; \
60 echo ''; \
61 echo ' "CrossHost": "$(HOST_CROSS_OS)",'; \
62 echo ' "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \
Evgenii Stepanov7f13ab92016-05-12 18:03:23 -070063 echo ' "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)",'; \
64 echo ' "Safestack": $(if $(filter true,$(USE_SAFESTACK)),true,false)'; \
Colin Cross3ebb2f72015-11-09 14:53:36 -080065 echo '}') > $(SOONG_VARIABLES_TMP); \
66 if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \
67 mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \
68 else \
69 rm $(SOONG_VARIABLES_TMP); \
70 fi
71
Dan Willemsen5f38f9b2015-12-11 13:50:00 -080072# Tell soong that it is embedded in make
73$(SOONG_IN_MAKE):
74 $(hide) mkdir -p $(dir $@)
75 $(hide) touch $@
76
Dan Willemsen2d12ce12016-03-10 15:03:41 -080077# Run Soong, this implicitly create an Android.mk listing all soong outputs as
78# prebuilts.
79.PHONY: run_soong
Dan Willemsencc60f012016-03-22 14:44:17 -070080run_soong: $(SOONG_BOOTSTRAP) $(SOONG_VARIABLES) $(SOONG_IN_MAKE) FORCE
Dan Willemsen9a97ba72016-05-05 16:52:37 -070081 $(hide) $(SOONG) $(SOONG_BUILD_NINJA) $(NINJA_EXTRA_ARGS)