blob: 7a884e083633e58c2ed633a786bf3e9fd2a1cdfa [file] [log] [blame]
Dan Willemsen04f53ed2016-11-09 17:22:15 -08001SOONG := $(SOONG_OUT_DIR)/soong
2SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap
3SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja
4SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make
5SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk
6SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables
7SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk
8
9BINDER32BIT :=
10ifneq ($(TARGET_USES_64_BIT_BINDER),true)
11ifneq ($(TARGET_IS_64_BIT),true)
12BINDER32BIT := true
13endif
14endif
15
Dan Willemsen7ad03052017-10-12 15:26:29 -070016ifeq ($(WRITE_SOONG_VARIABLES),true)
Dan Alberta3afbb92017-03-29 13:58:13 -070017# 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.
23json_list = $(call _json_list,$(space),$(1))
24
25# Converts a comma-separated list to a JSON list.
26csv_to_json_list = $(call _json_list,$(comma),$(1))
27
Dan Willemsen7ad03052017-10-12 15:26:29 -070028# 1: Key name
29# 2: Value
30add_json_val = $(eval _contents := $$(_contents) "$$(strip $$(1))":$$(space)$$(strip $$(2))$$(comma)$$(newline))
31add_json_str = $(call add_json_val,$(1),"$(strip $(2))")
32add_json_list = $(call add_json_val,$(1),$(call json_list,$(patsubst %,%,$(2))))
33add_json_csv = $(call add_json_val,$(1),$(call csv_to_json_list,$(strip $(2))))
34add_json_bool = $(call add_json_val,$(1),$(if $(strip $(2)),true,false))
35
36invert_bool = $(if $(strip $(1)),,true)
37
Dan Willemsen04f53ed2016-11-09 17:22:15 -080038# Create soong.variables with copies of makefile settings. Runs every build,
39# but only updates soong.variables if it changes
Dan Willemsen7ad03052017-10-12 15:26:29 -070040$(shell mkdir -p $(dir $(SOONG_VARIABLES)))
41_contents := {$(newline)
42
43$(call add_json_str, Make_suffix, -$(TARGET_PRODUCT))
44
Nan Zhangcf9d5032018-01-10 11:40:14 -080045$(call add_json_str, BuildId, $(BUILD_ID))
46$(call add_json_str, BuildNumberFromFile, $$$(BUILD_NUMBER_FROM_FILE))
47
Colin Cross34aba6c2018-05-09 11:10:15 -070048$(call add_json_str, Platform_version_name, $(PLATFORM_VERSION))
Dan Willemsen7ad03052017-10-12 15:26:29 -070049$(call add_json_val, Platform_sdk_version, $(PLATFORM_SDK_VERSION))
Colin Crossf6d3fff2018-04-18 12:40:16 -070050$(call add_json_str, Platform_sdk_codename, $(PLATFORM_VERSION_CODENAME))
51$(call add_json_bool, Platform_sdk_final, $(filter REL,$(PLATFORM_VERSION_CODENAME)))
Dan Willemsen7ad03052017-10-12 15:26:29 -070052$(call add_json_csv, Platform_version_active_codenames, $(PLATFORM_VERSION_ALL_CODENAMES))
53$(call add_json_csv, Platform_version_future_codenames, $(PLATFORM_VERSION_FUTURE_CODENAMES))
54
55$(call add_json_bool, Allow_missing_dependencies, $(ALLOW_MISSING_DEPENDENCIES))
56$(call add_json_bool, Unbundled_build, $(TARGET_BUILD_APPS))
57$(call add_json_bool, Pdk, $(filter true,$(TARGET_BUILD_PDK)))
58
59$(call add_json_bool, Debuggable, $(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
60$(call add_json_bool, Eng, $(filter eng,$(TARGET_BUILD_VARIANT)))
61
62$(call add_json_str, DeviceName, $(TARGET_DEVICE))
63$(call add_json_str, DeviceArch, $(TARGET_ARCH))
64$(call add_json_str, DeviceArchVariant, $(TARGET_ARCH_VARIANT))
65$(call add_json_str, DeviceCpuVariant, $(TARGET_CPU_VARIANT))
66$(call add_json_list, DeviceAbi, $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2))
67
68$(call add_json_str, DeviceSecondaryArch, $(TARGET_2ND_ARCH))
69$(call add_json_str, DeviceSecondaryArchVariant, $(TARGET_2ND_ARCH_VARIANT))
70$(call add_json_str, DeviceSecondaryCpuVariant, $(TARGET_2ND_CPU_VARIANT))
71$(call add_json_list, DeviceSecondaryAbi, $(TARGET_2ND_CPU_ABI) $(TARGET_2ND_CPU_ABI2))
72
73$(call add_json_str, HostArch, $(HOST_ARCH))
74$(call add_json_str, HostSecondaryArch, $(HOST_2ND_ARCH))
75$(call add_json_bool, HostStaticBinaries, $(BUILD_HOST_static))
76
77$(call add_json_str, CrossHost, $(HOST_CROSS_OS))
78$(call add_json_str, CrossHostArch, $(HOST_CROSS_ARCH))
79$(call add_json_str, CrossHostSecondaryArch, $(HOST_CROSS_2ND_ARCH))
80
Colin Crossc7bd5402017-10-30 17:31:44 -070081$(call add_json_list, ResourceOverlays, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS))
82$(call add_json_list, EnforceRROTargets, $(PRODUCT_ENFORCE_RRO_TARGETS))
83$(call add_json_list, EnforceRROExcludedOverlays, $(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS))
84
85$(call add_json_str, AAPTCharacteristics, $(TARGET_AAPT_CHARACTERISTICS))
86$(call add_json_list, AAPTConfig, $(PRODUCT_AAPT_CONFIG))
87$(call add_json_str, AAPTPreferredConfig, $(PRODUCT_AAPT_PREF_CONFIG))
88$(call add_json_list, AAPTPrebuiltDPI, $(PRODUCT_AAPT_PREBUILT_DPI))
89
Colin Cross0e10ff52017-12-01 17:13:56 -080090$(call add_json_str, DefaultAppCertificate, $(PRODUCT_DEFAULT_DEV_CERTIFICATE))
91
Colin Crossc7bd5402017-10-30 17:31:44 -070092$(call add_json_str, AppsDefaultVersionName, $(APPS_DEFAULT_VERSION_NAME))
93
Dan Willemsen7ad03052017-10-12 15:26:29 -070094$(call add_json_list, SanitizeHost, $(SANITIZE_HOST))
95$(call add_json_list, SanitizeDevice, $(SANITIZE_TARGET))
96$(call add_json_list, SanitizeDeviceDiag, $(SANITIZE_TARGET_DIAG))
97$(call add_json_list, SanitizeDeviceArch, $(SANITIZE_TARGET_ARCH))
98
99$(call add_json_bool, Safestack, $(filter true,$(USE_SAFESTACK)))
100$(call add_json_bool, EnableCFI, $(call invert_bool,$(filter false,$(ENABLE_CFI))))
Vishwath Mohan23b2d2e2017-10-31 02:25:16 -0700101$(call add_json_list, CFIExcludePaths, $(CFI_EXCLUDE_PATHS) $(PRODUCT_CFI_EXCLUDE_PATHS))
102$(call add_json_list, CFIIncludePaths, $(CFI_INCLUDE_PATHS) $(PRODUCT_CFI_INCLUDE_PATHS))
Dan Willemsen7ad03052017-10-12 15:26:29 -0700103$(call add_json_list, IntegerOverflowExcludePaths, $(INTEGER_OVERFLOW_EXCLUDE_PATHS) $(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS))
104
105$(call add_json_bool, ClangTidy, $(filter 1 true,$(WITH_TIDY)))
106$(call add_json_str, TidyChecks, $(WITH_TIDY_CHECKS))
107
108$(call add_json_bool, NativeCoverage, $(filter true,$(NATIVE_COVERAGE)))
Ryan Campbella435aa52017-10-20 16:19:42 -0700109$(call add_json_list, CoveragePaths, $(COVERAGE_PATHS))
110$(call add_json_list, CoverageExcludePaths, $(COVERAGE_EXCLUDE_PATHS))
Dan Willemsen7ad03052017-10-12 15:26:29 -0700111
112$(call add_json_bool, ArtUseReadBarrier, $(call invert_bool,$(filter false,$(PRODUCT_ART_USE_READ_BARRIER))))
113$(call add_json_bool, Binder32bit, $(BINDER32BIT))
Dan Willemsen7ad03052017-10-12 15:26:29 -0700114$(call add_json_str, BtConfigIncludeDir, $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR))
115$(call add_json_bool, Device_uses_hwc2, $(filter true,$(TARGET_USES_HWC2)))
116$(call add_json_list, DeviceKernelHeaders, $(TARGET_PROJECT_SYSTEM_INCLUDES))
Colin Crossd0f3a3b2018-10-01 15:31:16 -0700117$(call add_json_bool, DevicePrefer32BitApps, $(filter true,$(TARGET_PREFER_32_BIT_APPS)))
Dan Willemsen7ad03052017-10-12 15:26:29 -0700118$(call add_json_bool, DevicePrefer32BitExecutables, $(filter true,$(TARGET_PREFER_32_BIT_EXECUTABLES)))
Dan Willemsen7ad03052017-10-12 15:26:29 -0700119$(call add_json_str, DeviceVndkVersion, $(BOARD_VNDK_VERSION))
Justin Yun2a233b32017-12-07 17:08:19 +0900120$(call add_json_str, Platform_vndk_version, $(PLATFORM_VNDK_VERSION))
Justin Yun9272ef82017-11-17 16:09:17 +0900121$(call add_json_list, ExtraVndkVersions, $(PRODUCT_EXTRA_VNDK_VERSIONS))
Jiyong Park641b6cc2018-01-15 14:48:40 +0900122$(call add_json_list, DeviceSystemSdkVersions, $(BOARD_SYSTEMSDK_VERSIONS))
123$(call add_json_list, Platform_systemsdk_versions, $(PLATFORM_SYSTEMSDK_VERSIONS))
Dan Willemsen7ad03052017-10-12 15:26:29 -0700124$(call add_json_bool, Malloc_not_svelte, $(call invert_bool,$(filter true,$(MALLOC_SVELTE))))
125$(call add_json_str, Override_rs_driver, $(OVERRIDE_RS_DRIVER))
Colin Cross3aa2f8f2018-10-05 14:41:04 -0700126$(call add_json_bool, UncompressPrivAppDex, $(call invert_bool,$(filter true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS))))
127$(call add_json_list, ModulesLoadedByPrivilegedModules, $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))
128$(call add_json_bool, DefaultStripDex, $(call invert_bool,$(filter nostripping,$(DEX_PREOPT_DEFAULT))))
129$(call add_json_bool, DisableDexPreopt, $(filter false,$(WITH_DEXPREOPT)))
130$(call add_json_list, DisableDexPreoptModules, $(DEXPREOPT_DISABLED_MODULES))
Steven Moreland0cf92b02017-12-13 14:07:13 -0800131
Ari Hausman-Cohen271d8612018-06-20 18:11:12 -0700132$(call add_json_bool, Product_is_iot, $(filter true,$(PRODUCT_IOT)))
133
Steven Moreland0cf92b02017-12-13 14:07:13 -0800134$(call add_json_bool, Treble_linker_namespaces, $(filter true,$(PRODUCT_TREBLE_LINKER_NAMESPACES)))
Steven Moreland0cf92b02017-12-13 14:07:13 -0800135$(call add_json_bool, Enforce_vintf_manifest, $(filter true,$(PRODUCT_ENFORCE_VINTF_MANIFEST)))
136
Dan Willemsen7ad03052017-10-12 15:26:29 -0700137$(call add_json_bool, Uml, $(filter true,$(TARGET_USER_MODE_LINUX)))
Rajeev Kumar2052eb52018-03-09 17:49:49 -0800138$(call add_json_bool, Use_lmkd_stats_log, $(filter true,$(TARGET_LMKD_STATS_LOG)))
Dan Willemsen7ad03052017-10-12 15:26:29 -0700139$(call add_json_str, VendorPath, $(TARGET_COPY_OUT_VENDOR))
Jiyong Park9848be32017-12-18 10:34:26 +0900140$(call add_json_str, OdmPath, $(TARGET_COPY_OUT_ODM))
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900141$(call add_json_str, ProductPath, $(TARGET_COPY_OUT_PRODUCT))
Dario Freni5f681e12018-05-29 13:09:01 +0100142$(call add_json_str, ProductServicesPath, $(TARGET_COPY_OUT_PRODUCT_SERVICES))
Colin Cross829a16e2017-10-31 13:55:01 -0700143$(call add_json_bool, MinimizeJavaDebugInfo, $(filter true,$(PRODUCT_MINIMIZE_JAVA_DEBUG_INFO)))
Dan Willemsen7ad03052017-10-12 15:26:29 -0700144
145$(call add_json_bool, UseGoma, $(filter-out false,$(USE_GOMA)))
Risanf6c45ce2017-11-27 18:51:55 +0900146$(call add_json_bool, Arc, $(filter true,$(TARGET_ARC)))
Dan Willemsen7ad03052017-10-12 15:26:29 -0700147
Jeff Gaston1fe28d32017-11-21 15:05:07 -0800148$(call add_json_list, NamespacesToExport, $(PRODUCT_SOONG_NAMESPACES))
149
Pirama Arumuga Nainar676fbe72018-01-29 23:07:26 -0800150$(call add_json_list, PgoAdditionalProfileDirs, $(PGO_ADDITIONAL_PROFILE_DIRS))
151
Tri Vo82d1c882018-03-25 19:58:03 -0700152$(call add_json_list, BoardVendorSepolicyDirs, $(BOARD_SEPOLICY_DIRS))
153$(call add_json_list, BoardOdmSepolicyDirs, $(BOARD_ODM_SEPOLICY_DIRS))
Tri Vo49483082018-05-20 14:33:11 -0700154$(call add_json_list, BoardPlatPublicSepolicyDirs, $(BOARD_PLAT_PUBLIC_SEPOLICY_DIR))
155$(call add_json_list, BoardPlatPrivateSepolicyDirs, $(BOARD_PLAT_PRIVATE_SEPOLICY_DIR))
Tri Vo82d1c882018-03-25 19:58:03 -0700156
Dan Willemseneaacf5b2018-03-13 00:04:48 -0700157_contents := $(_contents) "VendorVars": {$(newline)
158$(foreach namespace,$(SOONG_CONFIG_NAMESPACES),\
159 $(eval _contents := $$(_contents) "$(namespace)": {$$(newline)) \
160 $(foreach key,$(SOONG_CONFIG_$(namespace)),\
161 $(eval _contents := $$(_contents) "$(key)": "$(SOONG_CONFIG_$(namespace)_$(key))",$$(newline)))\
162 $(eval _contents := $$(_contents)$(if $(strip $(SOONG_CONFIG_$(namespace))),__SV_END) },$$(newline)))
163_contents := $(_contents)$(if $(strip $(SOONG_CONFIG_NAMESPACES)),__SV_END) },$(newline)
164
165_contents := $(subst $(comma)$(newline)__SV_END,$(newline),$(_contents)__SV_END}$(newline))
Dan Willemsen7ad03052017-10-12 15:26:29 -0700166
167$(file >$(SOONG_VARIABLES).tmp,$(_contents))
168
169$(shell if ! cmp -s $(SOONG_VARIABLES).tmp $(SOONG_VARIABLES); then \
170 mv $(SOONG_VARIABLES).tmp $(SOONG_VARIABLES); \
Dan Willemsen04f53ed2016-11-09 17:22:15 -0800171 else \
Dan Willemsen7ad03052017-10-12 15:26:29 -0700172 rm $(SOONG_VARIABLES).tmp; \
173 fi)
174
175_json_list :=
176json_list :=
177csv_to_json_list :=
178add_json_val :=
179add_json_str :=
180add_json_list :=
181add_json_csv :=
182add_json_bool :=
183invert_bool :=
184_contents :=
185
186endif # CONFIGURE_SOONG