Colin Cross | 3ebb2f7 | 2015-11-09 14:53:36 -0800 | [diff] [blame] | 1 | SOONG := $(SOONG_OUT_DIR)/soong |
Dan Willemsen | cc60f01 | 2016-03-22 14:44:17 -0700 | [diff] [blame] | 2 | SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap |
Colin Cross | 3ebb2f7 | 2015-11-09 14:53:36 -0800 | [diff] [blame] | 3 | SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja |
Dan Willemsen | 5f38f9b | 2015-12-11 13:50:00 -0800 | [diff] [blame] | 4 | SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make |
Dan Willemsen | 8b999ac | 2016-03-29 12:32:16 -0700 | [diff] [blame] | 5 | SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk |
Dan Willemsen | cc60f01 | 2016-03-22 14:44:17 -0700 | [diff] [blame] | 6 | SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables |
Dan Willemsen | 57aa920 | 2016-05-11 00:23:38 -0700 | [diff] [blame] | 7 | SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk |
Dan Willemsen | 2d12ce1 | 2016-03-10 15:03:41 -0800 | [diff] [blame] | 8 | |
Dan Willemsen | cc60f01 | 2016-03-22 14:44:17 -0700 | [diff] [blame] | 9 | # We need to rebootstrap soong if SOONG_OUT_DIR or the reverse path from |
| 10 | # SOONG_OUT_DIR to TOP changes |
| 11 | SOONG_NEEDS_REBOOTSTRAP := |
| 12 | ifneq ($(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 Cross | 367ab29 | 2016-05-02 15:31:17 -0700 | [diff] [blame] | 17 | ifneq ($(strip $(shell build/soong/scripts/reverse_path.py $(SOONG_OUT_DIR))),$(strip $(shell source $(SOONG_BOOTSTRAP); echo $$SRCDIR_FROM_BUILDDIR))) |
Dan Willemsen | cc60f01 | 2016-03-22 14:44:17 -0700 | [diff] [blame] | 18 | SOONG_NEEDS_REBOOTSTRAP := FORCE |
| 19 | $(warning reverse path changed) |
| 20 | endif |
| 21 | endif |
| 22 | |
| 23 | # Bootstrap soong. |
| 24 | $(SOONG_BOOTSTRAP): bootstrap.bash $(SOONG_NEEDS_REBOOTSTRAP) |
Colin Cross | 3ebb2f7 | 2015-11-09 14:53:36 -0800 | [diff] [blame] | 25 | $(hide) mkdir -p $(dir $@) |
Dan Willemsen | cc60f01 | 2016-03-22 14:44:17 -0700 | [diff] [blame] | 26 | $(hide) BUILDDIR=$(SOONG_OUT_DIR) ./bootstrap.bash |
Colin Cross | 3ebb2f7 | 2015-11-09 14:53:36 -0800 | [diff] [blame] | 27 | |
| 28 | # Create soong.variables with copies of makefile settings. Runs every build, |
| 29 | # but only updates soong.variables if it changes |
| 30 | SOONG_VARIABLES_TMP := $(SOONG_VARIABLES).$$$$ |
| 31 | $(SOONG_VARIABLES): FORCE |
| 32 | $(hide) mkdir -p $(dir $@) |
| 33 | $(hide) (\ |
| 34 | echo '{'; \ |
Dan Willemsen | 57aa920 | 2016-05-11 00:23:38 -0700 | [diff] [blame] | 35 | echo ' "Make_suffix": "-$(TARGET_PRODUCT)",'; \ |
| 36 | echo ''; \ |
Colin Cross | 3ebb2f7 | 2015-11-09 14:53:36 -0800 | [diff] [blame] | 37 | 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 Willemsen | 60899ed | 2016-03-01 15:21:15 -0800 | [diff] [blame] | 40 | echo ' "Malloc_not_svelte": $(if $(filter true,$(MALLOC_SVELTE)),false,true),'; \ |
Dan Willemsen | 721f9bd | 2016-03-16 11:12:41 -0700 | [diff] [blame] | 41 | echo ' "Allow_missing_dependencies": $(if $(TARGET_BUILD_APPS)$(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),true,false),'; \ |
Colin Cross | 4e2c57a | 2016-01-04 14:33:45 -0800 | [diff] [blame] | 42 | echo ' "SanitizeHost": [$(if $(SANITIZE_HOST),"$(subst $(comma),"$(comma)",$(SANITIZE_HOST))")],'; \ |
| 43 | echo ' "SanitizeDevice": [$(if $(SANITIZE_TARGET),"$(subst $(comma),"$(comma)",$(SANITIZE_TARGET))")],'; \ |
Dan Willemsen | cba1557 | 2016-05-17 16:40:03 -0700 | [diff] [blame] | 44 | echo ' "HostStaticBinaries": $(if $(strip $(BUILD_HOST_static)),true,false),'; \ |
Colin Cross | 3ebb2f7 | 2015-11-09 14:53:36 -0800 | [diff] [blame] | 45 | 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 Willemsen | d6e3b84 | 2016-02-09 14:55:13 -0800 | [diff] [blame] | 59 | echo ' "HostSecondaryArch": "$(HOST_2ND_ARCH)",'; \ |
| 60 | echo ''; \ |
| 61 | echo ' "CrossHost": "$(HOST_CROSS_OS)",'; \ |
| 62 | echo ' "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \ |
Evgenii Stepanov | 7f13ab9 | 2016-05-12 18:03:23 -0700 | [diff] [blame] | 63 | echo ' "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)",'; \ |
| 64 | echo ' "Safestack": $(if $(filter true,$(USE_SAFESTACK)),true,false)'; \ |
Colin Cross | 3ebb2f7 | 2015-11-09 14:53:36 -0800 | [diff] [blame] | 65 | 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 Willemsen | 5f38f9b | 2015-12-11 13:50:00 -0800 | [diff] [blame] | 72 | # Tell soong that it is embedded in make |
| 73 | $(SOONG_IN_MAKE): |
| 74 | $(hide) mkdir -p $(dir $@) |
| 75 | $(hide) touch $@ |
| 76 | |
Dan Willemsen | 2d12ce1 | 2016-03-10 15:03:41 -0800 | [diff] [blame] | 77 | # Run Soong, this implicitly create an Android.mk listing all soong outputs as |
| 78 | # prebuilts. |
| 79 | .PHONY: run_soong |
Dan Willemsen | cc60f01 | 2016-03-22 14:44:17 -0700 | [diff] [blame] | 80 | run_soong: $(SOONG_BOOTSTRAP) $(SOONG_VARIABLES) $(SOONG_IN_MAKE) FORCE |
Dan Willemsen | 9a97ba7 | 2016-05-05 16:52:37 -0700 | [diff] [blame] | 81 | $(hide) $(SOONG) $(SOONG_BUILD_NINJA) $(NINJA_EXTRA_ARGS) |