1# Copyright (C) 2020 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# This file defines the Soong Config Variable namespace ANDROID, and also any
16# variables in that namespace.
17
18# The expectation is that no vendor should be using the ANDROID namespace. This
19# check ensures that we don't collide with any existing vendor usage.
20
21ifdef SOONG_CONFIG_ANDROID
22$(error The Soong config namespace ANDROID is reserved.)
23endif
24
25$(call add_soong_config_namespace,ANDROID)
26
27# Add variables to the namespace below:
28
29$(call add_soong_config_var,ANDROID,BOARD_USES_ODMIMAGE)
30$(call add_soong_config_var,ANDROID,BOARD_USES_RECOVERY_AS_BOOT)
31$(call add_soong_config_var,ANDROID,CHECK_DEV_TYPE_VIOLATIONS)
32$(call add_soong_config_var,ANDROID,PLATFORM_SEPOLICY_COMPAT_VERSIONS)
33$(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT)
34$(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_DRMSERVER)
35$(call add_soong_config_var,ANDROID,TARGET_ENABLE_MEDIADRM_64)
36$(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_MEDIASERVER)
37
38# PRODUCT_PRECOMPILED_SEPOLICY defaults to true. Explicitly check if it's "false" or not.
39$(call add_soong_config_var_value,ANDROID,PRODUCT_PRECOMPILED_SEPOLICY,$(if $(filter false,$(PRODUCT_PRECOMPILED_SEPOLICY)),false,true))
40
41ifdef ART_DEBUG_OPT_FLAG
42$(call soong_config_set,art_module,art_debug_opt_flag,$(ART_DEBUG_OPT_FLAG))
43endif
44
45ifdef TARGET_BOARD_AUTO
46  $(call add_soong_config_var_value, ANDROID, target_board_auto, $(TARGET_BOARD_AUTO))
47endif
48
49# Apex build mode variables
50ifdef APEX_BUILD_FOR_PRE_S_DEVICES
51$(call add_soong_config_var_value,ANDROID,library_linking_strategy,prefer_static)
52else
53ifdef KEEP_APEX_INHERIT
54$(call add_soong_config_var_value,ANDROID,library_linking_strategy,prefer_static)
55endif
56endif
57
58# TODO(b/308187800): some internal modules set `prefer` to true on the prebuilt apex module,
59# and set that to false when `ANDROID.module_build_from_source` is true.
60# Set this soong config variable to true for now, and cleanup `prefer` as part of b/308187800
61$(call add_soong_config_var_value,ANDROID,module_build_from_source,true)
62
63# Enable SystemUI optimizations by default unless explicitly set.
64SYSTEMUI_OPTIMIZE_JAVA ?= true
65$(call add_soong_config_var,ANDROID,SYSTEMUI_OPTIMIZE_JAVA)
66
67ifdef PRODUCT_AVF_ENABLED
68$(call add_soong_config_var_value,ANDROID,avf_enabled,$(PRODUCT_AVF_ENABLED))
69endif
70
71# Enable AVF remote attestation according to the flag value if PRODUCT_AVF_REMOTE_ATTESTATION_DISABLED is not
72# set to true explicitly.
73ifneq (true,$(PRODUCT_AVF_REMOTE_ATTESTATION_DISABLED))
74  $(call add_soong_config_var_value,ANDROID,avf_remote_attestation_enabled,$(RELEASE_AVF_ENABLE_REMOTE_ATTESTATION))
75endif
76
77ifdef PRODUCT_AVF_MICRODROID_GUEST_GKI_VERSION
78$(call add_soong_config_var_value,ANDROID,avf_microdroid_guest_gki_version,$(PRODUCT_AVF_MICRODROID_GUEST_GKI_VERSION))
79endif
80
81ifdef PRODUCT_MEMCG_V2_FORCE_ENABLED
82$(call add_soong_config_var_value,ANDROID,memcg_v2_force_enabled,$(PRODUCT_MEMCG_V2_FORCE_ENABLED))
83endif
84
85ifdef PRODUCT_CGROUP_V2_SYS_APP_ISOLATION_ENABLED
86$(call add_soong_config_var_value,ANDROID,cgroup_v2_sys_app_isolation,$(PRODUCT_CGROUP_V2_SYS_APP_ISOLATION_ENABLED))
87endif
88
89$(call add_soong_config_var_value,ANDROID,release_avf_allow_preinstalled_apps,$(RELEASE_AVF_ALLOW_PREINSTALLED_APPS))
90$(call add_soong_config_var_value,ANDROID,release_avf_enable_device_assignment,$(RELEASE_AVF_ENABLE_DEVICE_ASSIGNMENT))
91$(call add_soong_config_var_value,ANDROID,release_avf_enable_dice_changes,$(RELEASE_AVF_ENABLE_DICE_CHANGES))
92$(call add_soong_config_var_value,ANDROID,release_avf_enable_llpvm_changes,$(RELEASE_AVF_ENABLE_LLPVM_CHANGES))
93$(call add_soong_config_var_value,ANDROID,release_avf_enable_multi_tenant_microdroid_vm,$(RELEASE_AVF_ENABLE_MULTI_TENANT_MICRODROID_VM))
94$(call add_soong_config_var_value,ANDROID,release_avf_enable_network,$(RELEASE_AVF_ENABLE_NETWORK))
95# TODO(b/341292601): This flag is needed until the V release. We with clean it up after V together
96# with most of the release_avf_ flags here.
97$(call add_soong_config_var_value,ANDROID,release_avf_enable_remote_attestation,$(RELEASE_AVF_ENABLE_REMOTE_ATTESTATION))
98$(call add_soong_config_var_value,ANDROID,release_avf_enable_vendor_modules,$(RELEASE_AVF_ENABLE_VENDOR_MODULES))
99$(call add_soong_config_var_value,ANDROID,release_avf_enable_virt_cpufreq,$(RELEASE_AVF_ENABLE_VIRT_CPUFREQ))
100$(call add_soong_config_var_value,ANDROID,release_avf_microdroid_kernel_version,$(RELEASE_AVF_MICRODROID_KERNEL_VERSION))
101$(call add_soong_config_var_value,ANDROID,release_avf_support_custom_vm_with_paravirtualized_devices,$(RELEASE_AVF_SUPPORT_CUSTOM_VM_WITH_PARAVIRTUALIZED_DEVICES))
102
103$(call add_soong_config_var_value,ANDROID,release_binder_death_recipient_weak_from_jni,$(RELEASE_BINDER_DEATH_RECIPIENT_WEAK_FROM_JNI))
104
105$(call add_soong_config_var_value,ANDROID,release_libpower_no_lock_binder_txn,$(RELEASE_LIBPOWER_NO_LOCK_BINDER_TXN))
106
107$(call add_soong_config_var_value,ANDROID,release_package_libandroid_runtime_punch_holes,$(RELEASE_PACKAGE_LIBANDROID_RUNTIME_PUNCH_HOLES))
108
109$(call add_soong_config_var_value,ANDROID,release_selinux_data_data_ignore,$(RELEASE_SELINUX_DATA_DATA_IGNORE))
110ifneq (,$(filter eng userdebug,$(TARGET_BUILD_VARIANT)))
111    # write appcompat system properties on userdebug and eng builds
112    $(call add_soong_config_var_value,ANDROID,release_write_appcompat_override_system_properties,true)
113endif
114
115# Enable system_server optimizations by default unless explicitly set or if
116# there may be dependent runtime jars.
117# TODO(b/240588226): Remove the off-by-default exceptions after handling
118# system_server jars automatically w/ R8.
119ifeq (true,$(PRODUCT_BROKEN_SUBOPTIMAL_ORDER_OF_SYSTEM_SERVER_JARS))
120  # If system_server jar ordering is broken, don't assume services.jar can be
121  # safely optimized in isolation, as there may be dependent jars.
122  SYSTEM_OPTIMIZE_JAVA ?= false
123else ifneq (platform:services,$(lastword $(PRODUCT_SYSTEM_SERVER_JARS)))
124  # If services is not the final jar in the dependency ordering, don't assume
125  # it can be safely optimized in isolation, as there may be dependent jars.
126  SYSTEM_OPTIMIZE_JAVA ?= false
127else
128  SYSTEM_OPTIMIZE_JAVA ?= true
129endif
130
131ifeq (true,$(FULL_SYSTEM_OPTIMIZE_JAVA))
132  SYSTEM_OPTIMIZE_JAVA := true
133endif
134
135$(call add_soong_config_var,ANDROID,SYSTEM_OPTIMIZE_JAVA)
136$(call add_soong_config_var,ANDROID,FULL_SYSTEM_OPTIMIZE_JAVA)
137
138# TODO(b/319697968): Remove this build flag support when metalava fully supports flagged api
139$(call soong_config_set,ANDROID,release_hidden_api_exportable_stubs,$(RELEASE_HIDDEN_API_EXPORTABLE_STUBS))
140
141# Check for SupplementalApi module.
142ifeq ($(wildcard packages/modules/SupplementalApi),)
143$(call add_soong_config_var_value,ANDROID,include_nonpublic_framework_api,false)
144else
145$(call add_soong_config_var_value,ANDROID,include_nonpublic_framework_api,true)
146endif
147
148# Add crashrecovery build flag to soong
149$(call soong_config_set,ANDROID,release_crashrecovery_module,$(RELEASE_CRASHRECOVERY_MODULE))
150# Add crashrecovery file move flags to soong, for both platform and module
151ifeq (true,$(RELEASE_CRASHRECOVERY_FILE_MOVE))
152  $(call soong_config_set,ANDROID,crashrecovery_files_in_module,true)
153  $(call soong_config_set,ANDROID,crashrecovery_files_in_platform,false)
154else
155  $(call soong_config_set,ANDROID,crashrecovery_files_in_module,false)
156  $(call soong_config_set,ANDROID,crashrecovery_files_in_platform,true)
157endif
158# Required as platform_bootclasspath is using this namespace
159$(call soong_config_set,bootclasspath,release_crashrecovery_module,$(RELEASE_CRASHRECOVERY_MODULE))
160
161# Enable Profiling module. Also used by platform_bootclasspath.
162$(call soong_config_set,ANDROID,release_package_profiling_module,$(RELEASE_PACKAGE_PROFILING_MODULE))
163$(call soong_config_set,bootclasspath,release_package_profiling_module,$(RELEASE_PACKAGE_PROFILING_MODULE))
164