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,TARGET_DYNAMIC_64_32_MEDIASERVER) 30$(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_DRMSERVER) 31$(call add_soong_config_var,ANDROID,TARGET_ENABLE_MEDIADRM_64) 32$(call add_soong_config_var,ANDROID,IS_TARGET_MIXED_SEPOLICY) 33ifeq ($(IS_TARGET_MIXED_SEPOLICY),true) 34$(call add_soong_config_var_value,ANDROID,MIXED_SEPOLICY_VERSION,$(BOARD_SEPOLICY_VERS)) 35endif 36$(call add_soong_config_var,ANDROID,BOARD_USES_ODMIMAGE) 37$(call add_soong_config_var,ANDROID,BOARD_USES_RECOVERY_AS_BOOT) 38$(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT) 39 40# Default behavior for the tree wrt building modules or using prebuilts. This 41# can always be overridden by setting the environment variable 42# MODULE_BUILD_FROM_SOURCE. 43BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false 44 45ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),) 46 # Always use sources when building the framework with Java coverage or 47 # sanitized builds as they both require purpose built prebuilts which we do 48 # not provide. 49 BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true 50endif 51 52ifneq ($(CLANG_COVERAGE)$(NATIVE_COVERAGE_PATHS),) 53 # Always use sources when building with clang coverage and native coverage. 54 # It is possible that there are certain situations when building with coverage 55 # would work with prebuilts, e.g. when the coverage is not being applied to 56 # modules for which we provide prebuilts. Unfortunately, determining that 57 # would require embedding knowledge of which coverage paths affect which 58 # modules here. That would duplicate a lot of information, add yet another 59 # location module authors have to update and complicate the logic here. 60 # For nowe we will just always build from sources when doing coverage builds. 61 BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true 62endif 63 64# ART does not provide linux_bionic variants needed for products that 65# set HOST_CROSS_OS=linux_bionic. 66ifeq (linux_bionic,${HOST_CROSS_OS}) 67 BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true 68endif 69 70# ART does not provide host side arm64 variants needed for products that 71# set HOST_CROSS_ARCH=arm64. 72ifeq (arm64,${HOST_CROSS_ARCH}) 73 BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true 74endif 75 76# TV based devices do not seem to work with prebuilts, so build from source 77# for now and fix in a follow up. 78ifneq (,$(filter tv,$(subst $(comma),$(space),${PRODUCT_CHARACTERISTICS}))) 79 BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true 80endif 81 82# ATV based devices do not seem to work with prebuilts, so build from source 83# for now and fix in a follow up. 84ifneq (,${PRODUCT_IS_ATV}) 85 BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true 86endif 87 88ifneq (,$(MODULE_BUILD_FROM_SOURCE)) 89 # Keep an explicit setting. 90else ifeq (,$(filter docs sdk win_sdk sdk_addon,$(MAKECMDGOALS))$(findstring com.google.android.conscrypt,$(PRODUCT_PACKAGES))$(findstring com.google.android.go.conscrypt,$(PRODUCT_PACKAGES))) 91 # Prebuilt module SDKs require prebuilt modules to work, and currently 92 # prebuilt modules are only provided for com.google.android(.go)?.xxx. If we can't 93 # find one of them in PRODUCT_PACKAGES then assume com.android.xxx are in use, 94 # and disable prebuilt SDKs. In particular this applies to AOSP builds. 95 # 96 # However, docs/sdk/win_sdk/sdk_addon builds might not include com.google.android.xxx 97 # packages, so for those we respect the default behavior. 98 MODULE_BUILD_FROM_SOURCE := true 99else ifneq (,$(PRODUCT_MODULE_BUILD_FROM_SOURCE)) 100 # Let products override the branch default. 101 MODULE_BUILD_FROM_SOURCE := $(PRODUCT_MODULE_BUILD_FROM_SOURCE) 102else 103 MODULE_BUILD_FROM_SOURCE := $(BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE) 104endif 105 106ifneq (,$(ART_MODULE_BUILD_FROM_SOURCE)) 107 # Keep an explicit setting. 108else ifneq (,$(findstring .android.art,$(TARGET_BUILD_APPS))) 109 # Build ART modules from source if they are listed in TARGET_BUILD_APPS. 110 ART_MODULE_BUILD_FROM_SOURCE := true 111else 112 # Do the same as other modules by default. 113 ART_MODULE_BUILD_FROM_SOURCE := $(MODULE_BUILD_FROM_SOURCE) 114endif 115 116$(call soong_config_set,art_module,source_build,$(ART_MODULE_BUILD_FROM_SOURCE)) 117 118ifdef TARGET_BOARD_AUTO 119 $(call add_soong_config_var_value, ANDROID, target_board_auto, $(TARGET_BOARD_AUTO)) 120endif 121 122# Ensure that those mainline modules who have individually toggleable prebuilts 123# are controlled by the MODULE_BUILD_FROM_SOURCE environment variable by 124# default. 125INDIVIDUALLY_TOGGLEABLE_PREBUILT_MODULES := \ 126 btservices \ 127 permission \ 128 rkpd \ 129 uwb \ 130 wifi \ 131 132$(foreach m, $(INDIVIDUALLY_TOGGLEABLE_PREBUILT_MODULES),\ 133 $(if $(call soong_config_get,$(m)_module,source_build),,\ 134 $(call soong_config_set,$(m)_module,source_build,$(MODULE_BUILD_FROM_SOURCE)))) 135 136# Apex build mode variables 137ifdef APEX_BUILD_FOR_PRE_S_DEVICES 138$(call add_soong_config_var_value,ANDROID,library_linking_strategy,prefer_static) 139else 140ifdef KEEP_APEX_INHERIT 141$(call add_soong_config_var_value,ANDROID,library_linking_strategy,prefer_static) 142endif 143endif 144 145ifeq (true,$(MODULE_BUILD_FROM_SOURCE)) 146$(call add_soong_config_var_value,ANDROID,module_build_from_source,true) 147endif 148 149# Messaging app vars 150ifeq (eng,$(TARGET_BUILD_VARIANT)) 151$(call soong_config_set,messaging,build_variant_eng,true) 152endif 153 154# Enable SystemUI optimizations by default unless explicitly set. 155SYSTEMUI_OPTIMIZE_JAVA ?= true 156$(call add_soong_config_var,ANDROID,SYSTEMUI_OPTIMIZE_JAVA) 157 158# Disable Compose in SystemUI by default. 159SYSTEMUI_USE_COMPOSE ?= false 160$(call add_soong_config_var,ANDROID,SYSTEMUI_USE_COMPOSE) 161 162ifdef PRODUCT_AVF_ENABLED 163$(call add_soong_config_var_value,ANDROID,avf_enabled,$(PRODUCT_AVF_ENABLED)) 164endif 165 166# Enable system_server optimizations by default unless explicitly set or if 167# there may be dependent runtime jars. 168# TODO(b/240588226): Remove the off-by-default exceptions after handling 169# system_server jars automatically w/ R8. 170ifeq (true,$(PRODUCT_BROKEN_SUBOPTIMAL_ORDER_OF_SYSTEM_SERVER_JARS)) 171 # If system_server jar ordering is broken, don't assume services.jar can be 172 # safely optimized in isolation, as there may be dependent jars. 173 SYSTEM_OPTIMIZE_JAVA ?= false 174else ifneq (platform:services,$(lastword $(PRODUCT_SYSTEM_SERVER_JARS))) 175 # If services is not the final jar in the dependency ordering, don't assume 176 # it can be safely optimized in isolation, as there may be dependent jars. 177 SYSTEM_OPTIMIZE_JAVA ?= false 178else 179 SYSTEM_OPTIMIZE_JAVA ?= true 180endif 181$(call add_soong_config_var,ANDROID,SYSTEM_OPTIMIZE_JAVA) 182 183# Check for SupplementalApi module. 184ifeq ($(wildcard packages/modules/SupplementalApi),) 185$(call add_soong_config_var_value,ANDROID,include_nonpublic_framework_api,false) 186else 187$(call add_soong_config_var_value,ANDROID,include_nonpublic_framework_api,true) 188endif 189 190