From 04f53ed92303006e4dc7bc4d57cb999cd892c46d Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Wed, 9 Nov 2016 17:22:15 -0800 Subject: [PATCH] Split (ninja|soong).mk into config and rule portions So that an external tool can read the configuration using dump-many-vars, and write out the soong.variables file while only loading config.mk. Also remove dumpvar-% from PARSE_TIME_MAKE_GOALS, since it's only used with CALLED_FROM_SETUP / config.mk. This provides an easy way to test this change as well. Test: get_build_var NINJA Test: get_build_var ANDROID_GOALS Test: get_build_var NINJA_GOALS Test: get_build_var KATI_GOALS Test: MAKECMDGOALS="droid sdk dumpvar-ANDROID_GOALS" get_build_var ANDROID_GOALS Test: MAKECMDGOALS="droid sdk dumpvar-NINJA_GOALS" get_build_var NINJA_GOALS Test: MAKECMDGOALS="droid sdk dumpvar-KATI_GOALS" get_build_var KATI_GOALS Test: MAKECMDGOALS="out/build-a.ninja dumpvar-ANDROID_GOALS" get_build_var ANDROID_GOALS Test: get_build_var SOONG_MAKEVARS_MK Test: get_build_var SOONG_VARIABLES Test: CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core make -f build/core/config.mk out/soong/soong.variables showcommands Test: Compare soong.variables from above, and before/after with `m` Test: Compare out before/after with `m doesnotexist` Test: `m dist doesnotexist` Change-Id: I1bc291aa165297c930fe600067edad6ce4979210 --- core/config.mk | 6 ++++ core/ninja.mk | 70 -------------------------------------------- core/ninja_config.mk | 69 +++++++++++++++++++++++++++++++++++++++++++ core/soong.mk | 69 ------------------------------------------- core/soong_config.mk | 68 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 143 insertions(+), 139 deletions(-) create mode 100644 core/ninja_config.mk create mode 100644 core/soong_config.mk diff --git a/core/config.mk b/core/config.mk index b43169fbf..8d5d31a7f 100644 --- a/core/config.mk +++ b/core/config.mk @@ -857,4 +857,10 @@ dont_bother_goals := clean clobber dataclean installclean \ vbmetaimage-nodeps \ product-graph dump-products +ifndef KATI +include $(BUILD_SYSTEM)/ninja_config.mk +-include vendor/google/build/ninja_config.mk +include $(BUILD_SYSTEM)/soong_config.mk +endif + include $(BUILD_SYSTEM)/dumpvar.mk diff --git a/core/ninja.mk b/core/ninja.mk index b865a7975..8a5a904c3 100644 --- a/core/ninja.mk +++ b/core/ninja.mk @@ -1,78 +1,8 @@ -ifeq ($(filter address,$(SANITIZE_HOST)),) -NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/ninja -else -NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/asan/bin/ninja -endif - include $(BUILD_SYSTEM)/soong.mk -KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh - # 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. -PARSE_TIME_MAKE_GOALS := \ - $(PARSE_TIME_MAKE_GOALS) \ - $(dont_bother_goals) \ - all \ - APP-% \ - DUMP_% \ - ECLIPSE-% \ - PRODUCT-% \ - AUX-% \ - boottarball-nodeps \ - brillo_tests \ - 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 \ - 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% \ - vts \ - win_sdk \ - winsdk-tools - --include vendor/google/build/ninja_config.mk - -# Any Android goals that need to be built. -ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(CKATI) $(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)) - define replace_space_and_slash $(subst /,_,$(subst $(space),_,$(sort $1))) endef diff --git a/core/ninja_config.mk b/core/ninja_config.mk new file mode 100644 index 000000000..ab885151d --- /dev/null +++ b/core/ninja_config.mk @@ -0,0 +1,69 @@ +ifeq ($(filter address,$(SANITIZE_HOST)),) +NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/ninja +else +NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/asan/bin/ninja +endif + +KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh + +# 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. +PARSE_TIME_MAKE_GOALS := \ + $(PARSE_TIME_MAKE_GOALS) \ + $(dont_bother_goals) \ + all \ + APP-% \ + DUMP_% \ + ECLIPSE-% \ + PRODUCT-% \ + AUX-% \ + boottarball-nodeps \ + brillo_tests \ + btnod \ + build-art% \ + build_kernel-nodeps \ + clean-oat% \ + continuous_instrumentation_tests \ + continuous_native_tests \ + cts \ + custom_images \ + deps-license \ + dicttool_aosp \ + dist \ + dump-products \ + eng \ + fusion \ + oem_image \ + 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% \ + vts \ + win_sdk \ + winsdk-tools + +# Any Android goals that need to be built. +ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(CKATI) $(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)) diff --git a/core/soong.mk b/core/soong.mk index 73622a262..4a74f2ee3 100644 --- a/core/soong.mk +++ b/core/soong.mk @@ -1,11 +1,3 @@ -SOONG := $(SOONG_OUT_DIR)/soong -SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap -SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja -SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make -SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk -SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables -SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk - # We need to rebootstrap soong if SOONG_OUT_DIR or the reverse path from # SOONG_OUT_DIR to TOP changes SOONG_NEEDS_REBOOTSTRAP := @@ -25,67 +17,6 @@ $(SOONG_BOOTSTRAP): bootstrap.bash $(SOONG_NEEDS_REBOOTSTRAP) $(hide) mkdir -p $(dir $@) $(hide) BUILDDIR=$(SOONG_OUT_DIR) ./bootstrap.bash -BINDER32BIT := -ifneq ($(TARGET_USES_64_BIT_BINDER),true) -ifneq ($(TARGET_IS_64_BIT),true) -BINDER32BIT := true -endif -endif - -# Create soong.variables with copies of makefile settings. Runs every build, -# but only updates soong.variables if it changes -SOONG_VARIABLES_TMP := $(SOONG_VARIABLES).$$$$ -$(SOONG_VARIABLES): FORCE - $(hide) mkdir -p $(dir $@) - $(hide) (\ - echo '{'; \ - echo ' "Make_suffix": "-$(TARGET_PRODUCT)",'; \ - echo ''; \ - echo ' "Platform_sdk_version": $(PLATFORM_SDK_VERSION),'; \ - echo ' "Unbundled_build": $(if $(TARGET_BUILD_APPS),true,false),'; \ - echo ' "Brillo": $(if $(BRILLO),true,false),'; \ - echo ' "Malloc_not_svelte": $(if $(filter true,$(MALLOC_SVELTE)),false,true),'; \ - echo ' "Allow_missing_dependencies": $(if $(TARGET_BUILD_APPS)$(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),true,false),'; \ - echo ' "SanitizeHost": [$(if $(SANITIZE_HOST),"$(subst $(space),"$(comma)",$(SANITIZE_HOST))")],'; \ - echo ' "SanitizeDevice": [$(if $(SANITIZE_TARGET),"$(subst $(space),"$(comma)",$(SANITIZE_TARGET))")],'; \ - echo ' "SanitizeDeviceArch": [$(if $(SANITIZE_TARGET_ARCH),"$(subst $(space),"$(comma)",$(SANITIZE_TARGET_ARCH))")],'; \ - echo ' "HostStaticBinaries": $(if $(strip $(BUILD_HOST_static)),true,false),'; \ - echo ' "Cpusets": $(if $(strip $(ENABLE_CPUSETS)),true,false),'; \ - echo ' "Schedboost": $(if $(strip $(ENABLE_SCHEDBOOST)),true,false),'; \ - echo ' "Binder32bit": $(if $(BINDER32BIT),true,false),'; \ - echo ' "DevicePrefer32BitExecutables": $(if $(filter true,$(TARGET_PREFER_32_BIT_EXECUTABLES)),true,false),'; \ - echo ' "UseGoma": $(if $(filter-out false,$(USE_GOMA)),true,false),'; \ - echo ' "Debuggable": $(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),true,false),'; \ - echo ''; \ - echo ' "ClangTidy": $(if $(filter 1 true,$(WITH_TIDY)),true,false),'; \ - echo ' "TidyChecks": "$(WITH_TIDY_CHECKS)",'; \ - echo ''; \ - echo ' "DeviceName": "$(TARGET_DEVICE)",'; \ - echo ' "DeviceArch": "$(TARGET_ARCH)",'; \ - echo ' "DeviceArchVariant": "$(TARGET_ARCH_VARIANT)",'; \ - echo ' "DeviceCpuVariant": "$(TARGET_CPU_VARIANT)",'; \ - echo ' "DeviceAbi": ["$(TARGET_CPU_ABI)", "$(TARGET_CPU_ABI2)"],'; \ - echo ' "DeviceUsesClang": $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false),'; \ - echo ''; \ - echo ' "DeviceSecondaryArch": "$(TARGET_2ND_ARCH)",'; \ - echo ' "DeviceSecondaryArchVariant": "$(TARGET_2ND_ARCH_VARIANT)",'; \ - echo ' "DeviceSecondaryCpuVariant": "$(TARGET_2ND_CPU_VARIANT)",'; \ - echo ' "DeviceSecondaryAbi": ["$(TARGET_2ND_CPU_ABI)", "$(TARGET_2ND_CPU_ABI2)"],'; \ - echo ''; \ - echo ' "HostArch": "$(HOST_ARCH)",'; \ - echo ' "HostSecondaryArch": "$(HOST_2ND_ARCH)",'; \ - echo ''; \ - echo ' "CrossHost": "$(HOST_CROSS_OS)",'; \ - echo ' "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \ - echo ' "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)",'; \ - echo ' "Safestack": $(if $(filter true,$(USE_SAFESTACK)),true,false)'; \ - echo '}') > $(SOONG_VARIABLES_TMP); \ - if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \ - mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \ - else \ - rm $(SOONG_VARIABLES_TMP); \ - fi - # Tell soong that it is embedded in make $(SOONG_IN_MAKE): $(hide) mkdir -p $(dir $@) diff --git a/core/soong_config.mk b/core/soong_config.mk new file mode 100644 index 000000000..995d9ed38 --- /dev/null +++ b/core/soong_config.mk @@ -0,0 +1,68 @@ +SOONG := $(SOONG_OUT_DIR)/soong +SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap +SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja +SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make +SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk +SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables +SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk + +BINDER32BIT := +ifneq ($(TARGET_USES_64_BIT_BINDER),true) +ifneq ($(TARGET_IS_64_BIT),true) +BINDER32BIT := true +endif +endif + +# Create soong.variables with copies of makefile settings. Runs every build, +# but only updates soong.variables if it changes +SOONG_VARIABLES_TMP := $(SOONG_VARIABLES).$$$$ +$(SOONG_VARIABLES): FORCE + $(hide) mkdir -p $(dir $@) + $(hide) (\ + echo '{'; \ + echo ' "Make_suffix": "-$(TARGET_PRODUCT)",'; \ + echo ''; \ + echo ' "Platform_sdk_version": $(PLATFORM_SDK_VERSION),'; \ + echo ' "Unbundled_build": $(if $(TARGET_BUILD_APPS),true,false),'; \ + echo ' "Brillo": $(if $(BRILLO),true,false),'; \ + echo ' "Malloc_not_svelte": $(if $(filter true,$(MALLOC_SVELTE)),false,true),'; \ + echo ' "Allow_missing_dependencies": $(if $(TARGET_BUILD_APPS)$(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),true,false),'; \ + echo ' "SanitizeHost": [$(if $(SANITIZE_HOST),"$(subst $(space),"$(comma)",$(SANITIZE_HOST))")],'; \ + echo ' "SanitizeDevice": [$(if $(SANITIZE_TARGET),"$(subst $(space),"$(comma)",$(SANITIZE_TARGET))")],'; \ + echo ' "SanitizeDeviceArch": [$(if $(SANITIZE_TARGET_ARCH),"$(subst $(space),"$(comma)",$(SANITIZE_TARGET_ARCH))")],'; \ + echo ' "HostStaticBinaries": $(if $(strip $(BUILD_HOST_static)),true,false),'; \ + echo ' "Cpusets": $(if $(strip $(ENABLE_CPUSETS)),true,false),'; \ + echo ' "Schedboost": $(if $(strip $(ENABLE_SCHEDBOOST)),true,false),'; \ + echo ' "Binder32bit": $(if $(BINDER32BIT),true,false),'; \ + echo ' "DevicePrefer32BitExecutables": $(if $(filter true,$(TARGET_PREFER_32_BIT_EXECUTABLES)),true,false),'; \ + echo ' "UseGoma": $(if $(filter-out false,$(USE_GOMA)),true,false),'; \ + echo ' "Debuggable": $(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),true,false),'; \ + echo ''; \ + echo ' "ClangTidy": $(if $(filter 1 true,$(WITH_TIDY)),true,false),'; \ + echo ' "TidyChecks": "$(WITH_TIDY_CHECKS)",'; \ + echo ''; \ + echo ' "DeviceName": "$(TARGET_DEVICE)",'; \ + echo ' "DeviceArch": "$(TARGET_ARCH)",'; \ + echo ' "DeviceArchVariant": "$(TARGET_ARCH_VARIANT)",'; \ + echo ' "DeviceCpuVariant": "$(TARGET_CPU_VARIANT)",'; \ + echo ' "DeviceAbi": ["$(TARGET_CPU_ABI)", "$(TARGET_CPU_ABI2)"],'; \ + echo ' "DeviceUsesClang": $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false),'; \ + echo ''; \ + echo ' "DeviceSecondaryArch": "$(TARGET_2ND_ARCH)",'; \ + echo ' "DeviceSecondaryArchVariant": "$(TARGET_2ND_ARCH_VARIANT)",'; \ + echo ' "DeviceSecondaryCpuVariant": "$(TARGET_2ND_CPU_VARIANT)",'; \ + echo ' "DeviceSecondaryAbi": ["$(TARGET_2ND_CPU_ABI)", "$(TARGET_2ND_CPU_ABI2)"],'; \ + echo ''; \ + echo ' "HostArch": "$(HOST_ARCH)",'; \ + echo ' "HostSecondaryArch": "$(HOST_2ND_ARCH)",'; \ + echo ''; \ + echo ' "CrossHost": "$(HOST_CROSS_OS)",'; \ + echo ' "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \ + echo ' "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)",'; \ + echo ' "Safestack": $(if $(filter true,$(USE_SAFESTACK)),true,false)'; \ + echo '}') > $(SOONG_VARIABLES_TMP); \ + if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \ + mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \ + else \ + rm $(SOONG_VARIABLES_TMP); \ + fi