Merge "Switch to $(file) instead of a rule to create soong.variables" am: a0d0ea3b5c am: 9ecc0da241

am: 05fda09148

Change-Id: I2e622fbcc0c495969942aecd576d66310b0795b1
This commit is contained in:
Dan Willemsen 2017-10-15 03:30:42 +00:00 committed by android-build-merger
commit 0f62817417

View file

@ -13,6 +13,7 @@ BINDER32BIT := true
endif endif
endif endif
ifeq ($(WRITE_SOONG_VARIABLES),true)
# Converts a list to a JSON list. # Converts a list to a JSON list.
# $1: List separator. # $1: List separator.
# $2: List. # $2: List.
@ -24,77 +25,105 @@ json_list = $(call _json_list,$(space),$(1))
# Converts a comma-separated list to a JSON list. # Converts a comma-separated list to a JSON list.
csv_to_json_list = $(call _json_list,$(comma),$(1)) csv_to_json_list = $(call _json_list,$(comma),$(1))
# 1: Key name
# 2: Value
add_json_val = $(eval _contents := $$(_contents) "$$(strip $$(1))":$$(space)$$(strip $$(2))$$(comma)$$(newline))
add_json_str = $(call add_json_val,$(1),"$(strip $(2))")
add_json_list = $(call add_json_val,$(1),$(call json_list,$(patsubst %,%,$(2))))
add_json_csv = $(call add_json_val,$(1),$(call csv_to_json_list,$(strip $(2))))
add_json_bool = $(call add_json_val,$(1),$(if $(strip $(2)),true,false))
invert_bool = $(if $(strip $(1)),,true)
# Create soong.variables with copies of makefile settings. Runs every build, # Create soong.variables with copies of makefile settings. Runs every build,
# but only updates soong.variables if it changes # but only updates soong.variables if it changes
SOONG_VARIABLES_TMP := $(SOONG_VARIABLES).$$$$ $(shell mkdir -p $(dir $(SOONG_VARIABLES)))
$(SOONG_VARIABLES): FORCE _contents := {$(newline)
$(hide) mkdir -p $(dir $@)
$(hide) (\ $(call add_json_str, Make_suffix, -$(TARGET_PRODUCT))
echo '{'; \
echo ' "Make_suffix": "-$(TARGET_PRODUCT)",'; \ $(call add_json_val, Platform_sdk_version, $(PLATFORM_SDK_VERSION))
echo ''; \ $(call add_json_csv, Platform_version_active_codenames, $(PLATFORM_VERSION_ALL_CODENAMES))
echo ' "Platform_sdk_version": $(PLATFORM_SDK_VERSION),'; \ $(call add_json_csv, Platform_version_future_codenames, $(PLATFORM_VERSION_FUTURE_CODENAMES))
echo ' "Platform_version_active_codenames": $(call csv_to_json_list,$(PLATFORM_VERSION_ALL_CODENAMES)),'; \
echo ' "Platform_version_future_codenames": $(call csv_to_json_list,$(PLATFORM_VERSION_FUTURE_CODENAMES)),'; \ $(call add_json_bool, Allow_missing_dependencies, $(ALLOW_MISSING_DEPENDENCIES))
echo ' "Unbundled_build": $(if $(TARGET_BUILD_APPS),true,false),'; \ $(call add_json_bool, Unbundled_build, $(TARGET_BUILD_APPS))
echo ' "Brillo": $(if $(BRILLO),true,false),'; \ $(call add_json_bool, Pdk, $(filter true,$(TARGET_BUILD_PDK)))
echo ' "Malloc_not_svelte": $(if $(filter true,$(MALLOC_SVELTE)),false,true),'; \
echo ' "Allow_missing_dependencies": $(if $(ALLOW_MISSING_DEPENDENCIES),true,false),'; \ $(call add_json_bool, Debuggable, $(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
echo ' "SanitizeHost": $(call json_list,$(SANITIZE_HOST)),'; \ $(call add_json_bool, Eng, $(filter eng,$(TARGET_BUILD_VARIANT)))
echo ' "SanitizeDevice": $(call json_list,$(SANITIZE_TARGET)),'; \
echo ' "SanitizeDeviceDiag": $(call json_list,$(SANITIZE_TARGET_DIAG)),'; \ $(call add_json_str, DeviceName, $(TARGET_DEVICE))
echo ' "SanitizeDeviceArch": $(call json_list,$(SANITIZE_TARGET_ARCH)),'; \ $(call add_json_str, DeviceArch, $(TARGET_ARCH))
echo ' "HostStaticBinaries": $(if $(strip $(BUILD_HOST_static)),true,false),'; \ $(call add_json_str, DeviceArchVariant, $(TARGET_ARCH_VARIANT))
echo ' "Binder32bit": $(if $(BINDER32BIT),true,false),'; \ $(call add_json_str, DeviceCpuVariant, $(TARGET_CPU_VARIANT))
echo ' "DevicePrefer32BitExecutables": $(if $(filter true,$(TARGET_PREFER_32_BIT_EXECUTABLES)),true,false),'; \ $(call add_json_list, DeviceAbi, $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2))
echo ' "UseGoma": $(if $(filter-out false,$(USE_GOMA)),true,false),'; \
echo ' "Debuggable": $(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),true,false),'; \ $(call add_json_str, DeviceSecondaryArch, $(TARGET_2ND_ARCH))
echo ' "Eng": $(if $(filter eng,$(TARGET_BUILD_VARIANT)),true,false),'; \ $(call add_json_str, DeviceSecondaryArchVariant, $(TARGET_2ND_ARCH_VARIANT))
echo ' "VendorPath": "$(TARGET_COPY_OUT_VENDOR)",'; \ $(call add_json_str, DeviceSecondaryCpuVariant, $(TARGET_2ND_CPU_VARIANT))
echo ''; \ $(call add_json_list, DeviceSecondaryAbi, $(TARGET_2ND_CPU_ABI) $(TARGET_2ND_CPU_ABI2))
echo ' "ClangTidy": $(if $(filter 1 true,$(WITH_TIDY)),true,false),'; \
echo ' "TidyChecks": "$(WITH_TIDY_CHECKS)",'; \ $(call add_json_str, HostArch, $(HOST_ARCH))
echo ''; \ $(call add_json_str, HostSecondaryArch, $(HOST_2ND_ARCH))
echo ' "NativeCoverage": $(if $(filter true,$(NATIVE_COVERAGE)),true,false),'; \ $(call add_json_bool, HostStaticBinaries, $(BUILD_HOST_static))
echo ' "CoveragePaths": $(call csv_to_json_list,$(COVERAGE_PATHS)),'; \
echo ' "CoverageExcludePaths": $(call csv_to_json_list,$(COVERAGE_EXCLUDE_PATHS)),'; \ $(call add_json_str, CrossHost, $(HOST_CROSS_OS))
echo ''; \ $(call add_json_str, CrossHostArch, $(HOST_CROSS_ARCH))
echo ' "DeviceName": "$(TARGET_DEVICE)",'; \ $(call add_json_str, CrossHostSecondaryArch, $(HOST_CROSS_2ND_ARCH))
echo ' "DeviceArch": "$(TARGET_ARCH)",'; \
echo ' "DeviceArchVariant": "$(TARGET_ARCH_VARIANT)",'; \ $(call add_json_list, SanitizeHost, $(SANITIZE_HOST))
echo ' "DeviceCpuVariant": "$(TARGET_CPU_VARIANT)",'; \ $(call add_json_list, SanitizeDevice, $(SANITIZE_TARGET))
echo ' "DeviceAbi": ["$(TARGET_CPU_ABI)", "$(TARGET_CPU_ABI2)"],'; \ $(call add_json_list, SanitizeDeviceDiag, $(SANITIZE_TARGET_DIAG))
echo ' "DeviceUsesClang": $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false),'; \ $(call add_json_list, SanitizeDeviceArch, $(SANITIZE_TARGET_ARCH))
echo ' "DeviceVndkVersion": "$(BOARD_VNDK_VERSION)",'; \
echo ''; \ $(call add_json_bool, Safestack, $(filter true,$(USE_SAFESTACK)))
echo ' "DeviceSecondaryArch": "$(TARGET_2ND_ARCH)",'; \ $(call add_json_bool, EnableCFI, $(call invert_bool,$(filter false,$(ENABLE_CFI))))
echo ' "DeviceSecondaryArchVariant": "$(TARGET_2ND_ARCH_VARIANT)",'; \ $(call add_json_list, IntegerOverflowExcludePaths, $(INTEGER_OVERFLOW_EXCLUDE_PATHS) $(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS))
echo ' "DeviceSecondaryCpuVariant": "$(TARGET_2ND_CPU_VARIANT)",'; \
echo ' "DeviceSecondaryAbi": ["$(TARGET_2ND_CPU_ABI)", "$(TARGET_2ND_CPU_ABI2)"],'; \ $(call add_json_bool, ClangTidy, $(filter 1 true,$(WITH_TIDY)))
echo ''; \ $(call add_json_str, TidyChecks, $(WITH_TIDY_CHECKS))
echo ' "HostArch": "$(HOST_ARCH)",'; \
echo ' "HostSecondaryArch": "$(HOST_2ND_ARCH)",'; \ $(call add_json_bool, NativeCoverage, $(filter true,$(NATIVE_COVERAGE)))
echo ''; \ $(call add_json_csv, CoveragePaths, $(COVERAGE_PATHS))
echo ' "CrossHost": "$(HOST_CROSS_OS)",'; \ $(call add_json_csv, CoverageExcludePaths, $(COVERAGE_EXCLUDE_PATHS))
echo ' "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \
echo ' "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)",'; \ $(call add_json_bool, ArtUseReadBarrier, $(call invert_bool,$(filter false,$(PRODUCT_ART_USE_READ_BARRIER))))
echo ' "Safestack": $(if $(filter true,$(USE_SAFESTACK)),true,false),'; \ $(call add_json_bool, Binder32bit, $(BINDER32BIT))
echo ' "EnableCFI": $(if $(filter false,$(ENABLE_CFI)),false,true),'; \ $(call add_json_bool, Brillo, $(BRILLO))
echo ' "IntegerOverflowExcludePaths": $(call json_list,$(INTEGER_OVERFLOW_EXCLUDE_PATHS) $(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS)),'; \ $(call add_json_str, BtConfigIncludeDir, $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR))
echo ' "Device_uses_hwc2": $(if $(filter true,$(TARGET_USES_HWC2)),true,false),'; \ $(call add_json_bool, Device_uses_hwc2, $(filter true,$(TARGET_USES_HWC2)))
echo ' "Override_rs_driver": "$(OVERRIDE_RS_DRIVER)",'; \ $(call add_json_list, DeviceKernelHeaders, $(TARGET_PROJECT_SYSTEM_INCLUDES))
echo ' "Treble": $(if $(filter true,$(PRODUCT_FULL_TREBLE)),true,false),'; \ $(call add_json_bool, DevicePrefer32BitExecutables, $(filter true,$(TARGET_PREFER_32_BIT_EXECUTABLES)))
echo ' "Pdk": $(if $(filter true,$(TARGET_BUILD_PDK)),true,false),'; \ $(call add_json_val, DeviceUsesClang, $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false))
echo ' "Uml": $(if $(filter true,$(TARGET_USER_MODE_LINUX)),true,false),'; \ $(call add_json_str, DeviceVndkVersion, $(BOARD_VNDK_VERSION))
echo ''; \ $(call add_json_bool, Malloc_not_svelte, $(call invert_bool,$(filter true,$(MALLOC_SVELTE))))
echo ' "ArtUseReadBarrier": $(if $(filter false,$(PRODUCT_ART_USE_READ_BARRIER)),false,true),'; \ $(call add_json_str, Override_rs_driver, $(OVERRIDE_RS_DRIVER))
echo ''; \ $(call add_json_bool, Treble, $(filter true,$(PRODUCT_FULL_TREBLE)))
echo ' "BtConfigIncludeDir": "$(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)",'; \ $(call add_json_bool, Uml, $(filter true,$(TARGET_USER_MODE_LINUX)))
echo ''; \ $(call add_json_str, VendorPath, $(TARGET_COPY_OUT_VENDOR))
echo ' "DeviceKernelHeaders": $(call json_list,$(strip $(TARGET_PROJECT_SYSTEM_INCLUDES)))'; \
echo '}') > $(SOONG_VARIABLES_TMP); \ $(call add_json_bool, UseGoma, $(filter-out false,$(USE_GOMA)))
if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \
mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \ _contents := $(subst $(comma)$(newline)__SV_END,$(newline)}$(newline),$(_contents)__SV_END)
$(file >$(SOONG_VARIABLES).tmp,$(_contents))
$(shell if ! cmp -s $(SOONG_VARIABLES).tmp $(SOONG_VARIABLES); then \
mv $(SOONG_VARIABLES).tmp $(SOONG_VARIABLES); \
else \ else \
rm $(SOONG_VARIABLES_TMP); \ rm $(SOONG_VARIABLES).tmp; \
fi fi)
_json_list :=
json_list :=
csv_to_json_list :=
add_json_val :=
add_json_str :=
add_json_list :=
add_json_csv :=
add_json_bool :=
invert_bool :=
_contents :=
endif # CONFIGURE_SOONG