Dan Willemsen | 04f53ed | 2016-11-09 17:22:15 -0800 | [diff] [blame] | 1 | SOONG := $(SOONG_OUT_DIR)/soong |
| 2 | SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap |
| 3 | SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja |
| 4 | SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make |
| 5 | SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk |
| 6 | SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables |
| 7 | SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk |
| 8 | |
| 9 | BINDER32BIT := |
| 10 | ifneq ($(TARGET_USES_64_BIT_BINDER),true) |
| 11 | ifneq ($(TARGET_IS_64_BIT),true) |
| 12 | BINDER32BIT := true |
| 13 | endif |
| 14 | endif |
| 15 | |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 16 | ifeq ($(WRITE_SOONG_VARIABLES),true) |
Dan Albert | a3afbb9 | 2017-03-29 13:58:13 -0700 | [diff] [blame] | 17 | # Converts a list to a JSON list. |
| 18 | # $1: List separator. |
| 19 | # $2: List. |
| 20 | _json_list = [$(if $(2),"$(subst $(1),"$(comma)",$(2))")] |
| 21 | |
| 22 | # Converts a space-separated list to a JSON list. |
| 23 | json_list = $(call _json_list,$(space),$(1)) |
| 24 | |
| 25 | # Converts a comma-separated list to a JSON list. |
| 26 | csv_to_json_list = $(call _json_list,$(comma),$(1)) |
| 27 | |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 28 | # 1: Key name |
| 29 | # 2: Value |
| 30 | add_json_val = $(eval _contents := $$(_contents) "$$(strip $$(1))":$$(space)$$(strip $$(2))$$(comma)$$(newline)) |
| 31 | add_json_str = $(call add_json_val,$(1),"$(strip $(2))") |
| 32 | add_json_list = $(call add_json_val,$(1),$(call json_list,$(patsubst %,%,$(2)))) |
| 33 | add_json_csv = $(call add_json_val,$(1),$(call csv_to_json_list,$(strip $(2)))) |
| 34 | add_json_bool = $(call add_json_val,$(1),$(if $(strip $(2)),true,false)) |
| 35 | |
| 36 | invert_bool = $(if $(strip $(1)),,true) |
| 37 | |
Dan Willemsen | 04f53ed | 2016-11-09 17:22:15 -0800 | [diff] [blame] | 38 | # Create soong.variables with copies of makefile settings. Runs every build, |
| 39 | # but only updates soong.variables if it changes |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 40 | $(shell mkdir -p $(dir $(SOONG_VARIABLES))) |
| 41 | _contents := {$(newline) |
| 42 | |
| 43 | $(call add_json_str, Make_suffix, -$(TARGET_PRODUCT)) |
| 44 | |
| 45 | $(call add_json_val, Platform_sdk_version, $(PLATFORM_SDK_VERSION)) |
| 46 | $(call add_json_csv, Platform_version_active_codenames, $(PLATFORM_VERSION_ALL_CODENAMES)) |
| 47 | $(call add_json_csv, Platform_version_future_codenames, $(PLATFORM_VERSION_FUTURE_CODENAMES)) |
| 48 | |
| 49 | $(call add_json_bool, Allow_missing_dependencies, $(ALLOW_MISSING_DEPENDENCIES)) |
| 50 | $(call add_json_bool, Unbundled_build, $(TARGET_BUILD_APPS)) |
| 51 | $(call add_json_bool, Pdk, $(filter true,$(TARGET_BUILD_PDK))) |
| 52 | |
| 53 | $(call add_json_bool, Debuggable, $(filter userdebug eng,$(TARGET_BUILD_VARIANT))) |
| 54 | $(call add_json_bool, Eng, $(filter eng,$(TARGET_BUILD_VARIANT))) |
| 55 | |
| 56 | $(call add_json_str, DeviceName, $(TARGET_DEVICE)) |
| 57 | $(call add_json_str, DeviceArch, $(TARGET_ARCH)) |
| 58 | $(call add_json_str, DeviceArchVariant, $(TARGET_ARCH_VARIANT)) |
| 59 | $(call add_json_str, DeviceCpuVariant, $(TARGET_CPU_VARIANT)) |
| 60 | $(call add_json_list, DeviceAbi, $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)) |
| 61 | |
| 62 | $(call add_json_str, DeviceSecondaryArch, $(TARGET_2ND_ARCH)) |
| 63 | $(call add_json_str, DeviceSecondaryArchVariant, $(TARGET_2ND_ARCH_VARIANT)) |
| 64 | $(call add_json_str, DeviceSecondaryCpuVariant, $(TARGET_2ND_CPU_VARIANT)) |
| 65 | $(call add_json_list, DeviceSecondaryAbi, $(TARGET_2ND_CPU_ABI) $(TARGET_2ND_CPU_ABI2)) |
| 66 | |
| 67 | $(call add_json_str, HostArch, $(HOST_ARCH)) |
| 68 | $(call add_json_str, HostSecondaryArch, $(HOST_2ND_ARCH)) |
| 69 | $(call add_json_bool, HostStaticBinaries, $(BUILD_HOST_static)) |
| 70 | |
| 71 | $(call add_json_str, CrossHost, $(HOST_CROSS_OS)) |
| 72 | $(call add_json_str, CrossHostArch, $(HOST_CROSS_ARCH)) |
| 73 | $(call add_json_str, CrossHostSecondaryArch, $(HOST_CROSS_2ND_ARCH)) |
| 74 | |
Colin Cross | c7bd540 | 2017-10-30 17:31:44 -0700 | [diff] [blame] | 75 | $(call add_json_list, ResourceOverlays, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS)) |
| 76 | $(call add_json_list, EnforceRROTargets, $(PRODUCT_ENFORCE_RRO_TARGETS)) |
| 77 | $(call add_json_list, EnforceRROExcludedOverlays, $(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS)) |
| 78 | |
| 79 | $(call add_json_str, AAPTCharacteristics, $(TARGET_AAPT_CHARACTERISTICS)) |
| 80 | $(call add_json_list, AAPTConfig, $(PRODUCT_AAPT_CONFIG)) |
| 81 | $(call add_json_str, AAPTPreferredConfig, $(PRODUCT_AAPT_PREF_CONFIG)) |
| 82 | $(call add_json_list, AAPTPrebuiltDPI, $(PRODUCT_AAPT_PREBUILT_DPI)) |
| 83 | |
Colin Cross | 0e10ff5 | 2017-12-01 17:13:56 -0800 | [diff] [blame] | 84 | $(call add_json_str, DefaultAppCertificate, $(PRODUCT_DEFAULT_DEV_CERTIFICATE)) |
| 85 | |
Colin Cross | c7bd540 | 2017-10-30 17:31:44 -0700 | [diff] [blame] | 86 | $(call add_json_str, AppsDefaultVersionName, $(APPS_DEFAULT_VERSION_NAME)) |
| 87 | |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 88 | $(call add_json_list, SanitizeHost, $(SANITIZE_HOST)) |
| 89 | $(call add_json_list, SanitizeDevice, $(SANITIZE_TARGET)) |
| 90 | $(call add_json_list, SanitizeDeviceDiag, $(SANITIZE_TARGET_DIAG)) |
| 91 | $(call add_json_list, SanitizeDeviceArch, $(SANITIZE_TARGET_ARCH)) |
| 92 | |
| 93 | $(call add_json_bool, Safestack, $(filter true,$(USE_SAFESTACK))) |
| 94 | $(call add_json_bool, EnableCFI, $(call invert_bool,$(filter false,$(ENABLE_CFI)))) |
Vishwath Mohan | 23b2d2e | 2017-10-31 02:25:16 -0700 | [diff] [blame] | 95 | $(call add_json_list, CFIExcludePaths, $(CFI_EXCLUDE_PATHS) $(PRODUCT_CFI_EXCLUDE_PATHS)) |
| 96 | $(call add_json_list, CFIIncludePaths, $(CFI_INCLUDE_PATHS) $(PRODUCT_CFI_INCLUDE_PATHS)) |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 97 | $(call add_json_list, IntegerOverflowExcludePaths, $(INTEGER_OVERFLOW_EXCLUDE_PATHS) $(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS)) |
| 98 | |
| 99 | $(call add_json_bool, ClangTidy, $(filter 1 true,$(WITH_TIDY))) |
| 100 | $(call add_json_str, TidyChecks, $(WITH_TIDY_CHECKS)) |
| 101 | |
| 102 | $(call add_json_bool, NativeCoverage, $(filter true,$(NATIVE_COVERAGE))) |
Ryan Campbell | a435aa5 | 2017-10-20 16:19:42 -0700 | [diff] [blame] | 103 | $(call add_json_list, CoveragePaths, $(COVERAGE_PATHS)) |
| 104 | $(call add_json_list, CoverageExcludePaths, $(COVERAGE_EXCLUDE_PATHS)) |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 105 | |
| 106 | $(call add_json_bool, ArtUseReadBarrier, $(call invert_bool,$(filter false,$(PRODUCT_ART_USE_READ_BARRIER)))) |
| 107 | $(call add_json_bool, Binder32bit, $(BINDER32BIT)) |
| 108 | $(call add_json_bool, Brillo, $(BRILLO)) |
| 109 | $(call add_json_str, BtConfigIncludeDir, $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)) |
| 110 | $(call add_json_bool, Device_uses_hwc2, $(filter true,$(TARGET_USES_HWC2))) |
| 111 | $(call add_json_list, DeviceKernelHeaders, $(TARGET_PROJECT_SYSTEM_INCLUDES)) |
| 112 | $(call add_json_bool, DevicePrefer32BitExecutables, $(filter true,$(TARGET_PREFER_32_BIT_EXECUTABLES))) |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 113 | $(call add_json_str, DeviceVndkVersion, $(BOARD_VNDK_VERSION)) |
Justin Yun | 2a233b3 | 2017-12-07 17:08:19 +0900 | [diff] [blame] | 114 | $(call add_json_str, Platform_vndk_version, $(PLATFORM_VNDK_VERSION)) |
Justin Yun | 9272ef8 | 2017-11-17 16:09:17 +0900 | [diff] [blame] | 115 | $(call add_json_list, ExtraVndkVersions, $(PRODUCT_EXTRA_VNDK_VERSIONS)) |
Jiyong Park | 641b6cc | 2018-01-15 14:48:40 +0900 | [diff] [blame^] | 116 | $(call add_json_list, DeviceSystemSdkVersions, $(BOARD_SYSTEMSDK_VERSIONS)) |
| 117 | $(call add_json_list, Platform_systemsdk_versions, $(PLATFORM_SYSTEMSDK_VERSIONS)) |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 118 | $(call add_json_bool, Malloc_not_svelte, $(call invert_bool,$(filter true,$(MALLOC_SVELTE)))) |
| 119 | $(call add_json_str, Override_rs_driver, $(OVERRIDE_RS_DRIVER)) |
Steven Moreland | 0cf92b0 | 2017-12-13 14:07:13 -0800 | [diff] [blame] | 120 | |
Steven Moreland | 0cf92b0 | 2017-12-13 14:07:13 -0800 | [diff] [blame] | 121 | $(call add_json_bool, Treble_linker_namespaces, $(filter true,$(PRODUCT_TREBLE_LINKER_NAMESPACES))) |
Steven Moreland | 0cf92b0 | 2017-12-13 14:07:13 -0800 | [diff] [blame] | 122 | $(call add_json_bool, Enforce_vintf_manifest, $(filter true,$(PRODUCT_ENFORCE_VINTF_MANIFEST))) |
| 123 | |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 124 | $(call add_json_bool, Uml, $(filter true,$(TARGET_USER_MODE_LINUX))) |
| 125 | $(call add_json_str, VendorPath, $(TARGET_COPY_OUT_VENDOR)) |
Jiyong Park | 9848be3 | 2017-12-18 10:34:26 +0900 | [diff] [blame] | 126 | $(call add_json_str, OdmPath, $(TARGET_COPY_OUT_ODM)) |
| 127 | $(call add_json_str, OemPath, $(TARGET_COPY_OUT_OEM)) |
Colin Cross | 829a16e | 2017-10-31 13:55:01 -0700 | [diff] [blame] | 128 | $(call add_json_bool, MinimizeJavaDebugInfo, $(filter true,$(PRODUCT_MINIMIZE_JAVA_DEBUG_INFO))) |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 129 | |
| 130 | $(call add_json_bool, UseGoma, $(filter-out false,$(USE_GOMA))) |
| 131 | |
Jayant Chowdhary | 85fbcf4 | 2017-11-27 15:01:02 -0800 | [diff] [blame] | 132 | $(call add_json_str, DistDir, $(if $(dist_goal), $(DIST_DIR))) |
| 133 | |
Jeff Gaston | 1fe28d3 | 2017-11-21 15:05:07 -0800 | [diff] [blame] | 134 | $(call add_json_list, NamespacesToExport, $(PRODUCT_SOONG_NAMESPACES)) |
| 135 | |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 136 | _contents := $(subst $(comma)$(newline)__SV_END,$(newline)}$(newline),$(_contents)__SV_END) |
| 137 | |
| 138 | $(file >$(SOONG_VARIABLES).tmp,$(_contents)) |
| 139 | |
| 140 | $(shell if ! cmp -s $(SOONG_VARIABLES).tmp $(SOONG_VARIABLES); then \ |
| 141 | mv $(SOONG_VARIABLES).tmp $(SOONG_VARIABLES); \ |
Dan Willemsen | 04f53ed | 2016-11-09 17:22:15 -0800 | [diff] [blame] | 142 | else \ |
Dan Willemsen | 7ad0305 | 2017-10-12 15:26:29 -0700 | [diff] [blame] | 143 | rm $(SOONG_VARIABLES).tmp; \ |
| 144 | fi) |
| 145 | |
| 146 | _json_list := |
| 147 | json_list := |
| 148 | csv_to_json_list := |
| 149 | add_json_val := |
| 150 | add_json_str := |
| 151 | add_json_list := |
| 152 | add_json_csv := |
| 153 | add_json_bool := |
| 154 | invert_bool := |
| 155 | _contents := |
| 156 | |
| 157 | endif # CONFIGURE_SOONG |