2019-02-11 23:21:24 +01:00
// Copyright 2019 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package java
import (
"path/filepath"
"strings"
"android/soong/android"
"android/soong/dexpreopt"
2023-12-13 01:06:32 +01:00
"github.com/google/blueprint"
2019-02-11 23:21:24 +01:00
"github.com/google/blueprint/proptools"
)
2021-01-20 18:44:53 +01:00
// =================================================================================================
// WIP - see http://b/177892522 for details
//
// The build support for boot images is currently being migrated away from singleton to modules so
// the documentation may not be strictly accurate. Rather than update the documentation at every
// step which will create a lot of churn the changes that have been made will be listed here and the
// documentation will be updated once it is closer to the final result.
//
// Changes:
// 1) dex_bootjars is now a singleton module and not a plain singleton.
2021-01-20 16:16:56 +01:00
// 2) Boot images are now represented by the boot_image module type.
// 3) The art boot image is called "art-boot-image", the framework boot image is called
// "framework-boot-image".
// 4) They are defined in art/build/boot/Android.bp and frameworks/base/boot/Android.bp
// respectively.
// 5) Each boot_image retrieves the appropriate boot image configuration from the map returned by
// genBootImageConfigs() using the image_name specified in the boot_image module.
2021-01-20 18:44:53 +01:00
// =================================================================================================
2020-11-20 18:28:51 +01:00
// This comment describes:
// 1. ART boot images in general (their types, structure, file layout, etc.)
// 2. build system support for boot images
//
// 1. ART boot images
// ------------------
//
// A boot image in ART is a set of files that contain AOT-compiled native code and a heap snapshot
// of AOT-initialized classes for the bootclasspath Java libraries. A boot image is compiled from a
// set of DEX jars by the dex2oat compiler. A boot image is used for two purposes: 1) it is
// installed on device and loaded at runtime, and 2) other Java libraries and apps are compiled
// against it (compilation may take place either on host, known as "dexpreopt", or on device, known
// as "dexopt").
//
// A boot image is not a single file, but a collection of interrelated files. Each boot image has a
// number of components that correspond to the Java libraries that constitute it. For each component
// there are multiple files:
// - *.oat or *.odex file with native code (architecture-specific, one per instruction set)
// - *.art file with pre-initialized Java classes (architecture-specific, one per instruction set)
// - *.vdex file with verification metadata for the DEX bytecode (architecture independent)
//
// *.vdex files for the boot images do not contain the DEX bytecode itself, because the
// bootclasspath DEX files are stored on disk in uncompressed and aligned form. Consequently a boot
// image is not self-contained and cannot be used without its DEX files. To simplify the management
// of boot image files, ART uses a certain naming scheme and associates the following metadata with
// each boot image:
// - A stem, which is a symbolic name that is prepended to boot image file names.
// - A location (on-device path to the boot image files).
// - A list of boot image locations (on-device paths to dependency boot images).
// - A set of DEX locations (on-device paths to the DEX files, one location for one DEX file used
// to compile the boot image).
//
// There are two kinds of boot images:
// - primary boot images
// - boot image extensions
//
// 1.1. Primary boot images
// ------------------------
//
// A primary boot image is compiled for a core subset of bootclasspath Java libraries. It does not
// depend on any other images, and other boot images may depend on it.
//
// For example, assuming that the stem is "boot", the location is /apex/com.android.art/javalib/,
// the set of core bootclasspath libraries is A B C, and the boot image is compiled for ARM targets
// (32 and 64 bits), it will have three components with the following files:
// - /apex/com.android.art/javalib/{arm,arm64}/boot.{art,oat,vdex}
// - /apex/com.android.art/javalib/{arm,arm64}/boot-B.{art,oat,vdex}
// - /apex/com.android.art/javalib/{arm,arm64}/boot-C.{art,oat,vdex}
//
// The files of the first component are special: they do not have the component name appended after
// the stem. This naming convention dates back to the times when the boot image was not split into
// components, and there were just boot.oat and boot.art. The decision to split was motivated by
// licensing reasons for one of the bootclasspath libraries.
//
// As of November 2020 the only primary boot image in Android is the image in the ART APEX
// com.android.art. The primary ART boot image contains the Core libraries that are part of the ART
// module. When the ART module gets updated, the primary boot image will be updated with it, and all
// dependent images will get invalidated (the checksum of the primary image stored in dependent
// images will not match), unless they are updated in sync with the ART module.
//
// 1.2. Boot image extensions
// --------------------------
//
// A boot image extension is compiled for a subset of bootclasspath Java libraries (in particular,
// this subset does not include the Core bootclasspath libraries that go into the primary boot
// image). A boot image extension depends on the primary boot image and optionally some other boot
// image extensions. Other images may depend on it. In other words, boot image extensions can form
// acyclic dependency graphs.
//
// The motivation for boot image extensions comes from the Mainline project. Consider a situation
// when the list of bootclasspath libraries is A B C, and both A and B are parts of the Android
// platform, but C is part of an updatable APEX com.android.C. When the APEX is updated, the Java
// code for C might have changed compared to the code that was used to compile the boot image.
// Consequently, the whole boot image is obsolete and invalidated (even though the code for A and B
// that does not depend on C is up to date). To avoid this, the original monolithic boot image is
// split in two parts: the primary boot image that contains A B, and the boot image extension that
// contains C and depends on the primary boot image (extends it).
//
// For example, assuming that the stem is "boot", the location is /system/framework, the set of
// bootclasspath libraries is D E (where D is part of the platform and is located in
// /system/framework, and E is part of a non-updatable APEX com.android.E and is located in
// /apex/com.android.E/javalib), and the boot image is compiled for ARM targets (32 and 64 bits),
// it will have two components with the following files:
// - /system/framework/{arm,arm64}/boot-D.{art,oat,vdex}
// - /system/framework/{arm,arm64}/boot-E.{art,oat,vdex}
//
// As of November 2020 the only boot image extension in Android is the Framework boot image
// extension. It extends the primary ART boot image and contains Framework libraries and other
// bootclasspath libraries from the platform and non-updatable APEXes that are not included in the
// ART image. The Framework boot image extension is updated together with the platform. In the
// future other boot image extensions may be added for some updatable modules.
//
//
// 2. Build system support for boot images
// ---------------------------------------
//
// The primary ART boot image needs to be compiled with one dex2oat invocation that depends on DEX
// jars for the core libraries. Framework boot image extension needs to be compiled with one dex2oat
// invocation that depends on the primary ART boot image and all bootclasspath DEX jars except the
2021-01-20 18:44:53 +01:00
// core libraries as they are already part of the primary ART boot image.
2020-11-20 18:28:51 +01:00
//
// 2.1. Libraries that go in the boot images
// -----------------------------------------
//
// The contents of each boot image are determined by the PRODUCT variables. The primary ART APEX
// boot image contains libraries listed in the ART_APEX_JARS variable in the AOSP makefiles. The
// Framework boot image extension contains libraries specified in the PRODUCT_BOOT_JARS and
// PRODUCT_BOOT_JARS_EXTRA variables. The AOSP makefiles specify some common Framework libraries,
// but more product-specific libraries can be added in the product makefiles.
//
2021-07-05 21:33:42 +02:00
// Each component of the PRODUCT_BOOT_JARS and PRODUCT_BOOT_JARS_EXTRA variables is a
// colon-separated pair <apex>:<library>, where <apex> is the variant name of a non-updatable APEX,
// "platform" if the library is a part of the platform in the system partition, or "system_ext" if
// it's in the system_ext partition.
//
// In these variables APEXes are identified by their "variant names", i.e. the names they get
// mounted as in /apex on device. In Soong modules that is the name set in the "apex_name"
// properties, which default to the "name" values. For example, many APEXes have both
// com.android.xxx and com.google.android.xxx modules in Soong, but take the same place
// /apex/com.android.xxx at runtime. In these cases the variant name is always com.android.xxx,
// regardless which APEX goes into the product. See also android.ApexInfo.ApexVariationName and
// apex.apexBundleProperties.Apex_name.
2020-11-20 18:28:51 +01:00
//
2021-07-21 15:23:52 +02:00
// A related variable PRODUCT_APEX_BOOT_JARS contains bootclasspath libraries that are in APEXes.
// They are not included in the boot image. The only exception here are ART jars and core-icu4j.jar
// that have been historically part of the boot image and are now in apexes; they are in boot images
// and core-icu4j.jar is generally treated as being part of PRODUCT_BOOT_JARS.
2020-11-20 18:28:51 +01:00
//
// One exception to the above rules are "coverage" builds (a special build flavor which requires
// setting environment variable EMMA_INSTRUMENT_FRAMEWORK=true). In coverage builds the Java code in
// boot image libraries is instrumented, which means that the instrumentation library (jacocoagent)
// needs to be added to the list of bootclasspath DEX jars.
//
// In general, there is a requirement that the source code for a boot image library must be
// available at build time (e.g. it cannot be a stub that has a separate implementation library).
//
// 2.2. Static configs
// -------------------
//
// Because boot images are used to dexpreopt other Java modules, the paths to boot image files must
// be known by the time dexpreopt build rules for the dependent modules are generated. Boot image
// configs are constructed very early during the build, before build rule generation. The configs
// provide predefined paths to boot image files (these paths depend only on static build
// configuration, such as PRODUCT variables, and use hard-coded directory names).
//
// 2.3. Singleton
// --------------
//
// Build rules for the boot images are generated with a Soong singleton. Because a singleton has no
// dependencies on other modules, it has to find the modules for the DEX jars using VisitAllModules.
// Soong loops through all modules and compares each module against a list of bootclasspath library
// names. Then it generates build rules that copy DEX jars from their intermediate module-specific
// locations to the hard-coded locations predefined in the boot image configs.
//
// It would be possible to use a module with proper dependencies instead, but that would require
// changes in the way Soong generates variables for Make: a singleton can use one MakeVars() method
// that writes variables to out/soong/make_vars-*.mk, which is included early by the main makefile,
// but module(s) would have to use out/soong/Android-*.mk which has a group of LOCAL_* variables
// for each module, and is included later.
//
// 2.4. Install rules
// ------------------
//
// The primary boot image and the Framework extension are installed in different ways. The primary
// boot image is part of the ART APEX: it is copied into the APEX intermediate files, packaged
// together with other APEX contents, extracted and mounted on device. The Framework boot image
// extension is installed by the rules defined in makefiles (make/core/dex_preopt_libart.mk). Soong
// writes out a few DEXPREOPT_IMAGE_* variables for Make; these variables contain boot image names,
// paths and so on.
//
2021-02-16 20:55:58 +01:00
var artApexNames = [ ] string {
"com.android.art" ,
"com.android.art.debug" ,
2021-03-24 15:23:57 +01:00
"com.android.art.testing" ,
2021-02-16 20:55:58 +01:00
"com.google.android.art" ,
"com.google.android.art.debug" ,
"com.google.android.art.testing" ,
}
2023-07-13 12:03:38 +02:00
var (
2023-12-13 01:06:32 +01:00
dexpreoptBootJarDepTag = bootclasspathDependencyTag { name : "dexpreopt-boot-jar" }
dexBootJarsFragmentsKey = android . NewOnceKey ( "dexBootJarsFragments" )
apexContributionsMetadataDepTag = dependencyTag { name : "all_apex_contributions" }
2023-07-13 12:03:38 +02:00
)
2019-02-11 23:21:24 +01:00
func init ( ) {
2020-01-13 16:18:16 +01:00
RegisterDexpreoptBootJarsComponents ( android . InitRegistrationContext )
2019-02-11 23:21:24 +01:00
}
2020-11-20 18:28:51 +01:00
// Target-independent description of a boot image.
2022-10-04 16:21:47 +02:00
//
// WARNING: All fields in this struct should be initialized in the genBootImageConfigs function.
// Failure to do so can lead to data races if there is no synchronization enforced ordering between
2024-01-17 21:14:44 +01:00
// the writer and the reader.
2019-02-16 08:06:46 +01:00
type bootImageConfig struct {
2020-03-26 12:10:45 +01:00
// If this image is an extension, the image that it extends.
extends * bootImageConfig
2019-11-08 11:54:21 +01:00
// Image name (used in directory names and ninja rule names).
name string
2023-07-13 12:03:38 +02:00
// If the module with the given name exists, this config is enabled.
enabledIfExists string
2019-11-08 11:54:21 +01:00
// Basename of the image: the resulting filenames are <stem>[-<jar>].{art,oat,vdex}.
stem string
// Output directory for the image files.
dir android . OutputPath
// Output directory for the image files with debug symbols.
symbolsDir android . OutputPath
2023-05-10 18:04:53 +02:00
// The relative location where the image files are installed. On host, the location is relative to
// $ANDROID_PRODUCT_OUT.
//
// Only the configs that are built by platform_bootclasspath are installable on device. On device,
// the location is relative to "/".
installDir string
2021-04-27 16:56:44 +02:00
2020-07-01 15:31:13 +02:00
// A list of (location, jar) pairs for the Java modules in this image.
modules android . ConfiguredJarList
2019-02-16 08:06:46 +01:00
2019-11-08 11:54:21 +01:00
// File paths to jars.
dexPaths android . WritablePaths // for this image
dexPathsDeps android . WritablePaths // for the dependency images and in this image
2021-06-02 18:24:22 +02:00
// Map from module name (without prebuilt_ prefix) to the predefined build path.
dexPathsByModule map [ string ] android . WritablePath
2019-11-08 11:54:21 +01:00
// File path to a zip archive with all image files (or nil, if not needed).
zip android . WritablePath
2020-02-18 21:43:06 +01:00
// Target-dependent fields.
variants [ ] * bootImageVariant
2022-03-14 16:31:47 +01:00
// Path of the preloaded classes file.
preloadedClassesFile string
2023-02-23 18:50:46 +01:00
// The "--compiler-filter" argument.
compilerFilter string
2023-03-06 20:16:48 +01:00
// The "--single-image" argument.
singleImage bool
2023-05-10 19:38:34 +02:00
2023-07-13 12:03:38 +02:00
// Profiles imported from APEXes, in addition to the profile at the default path. Each entry must
// be the name of an APEX module.
profileImports [ ] string
2020-02-18 21:43:06 +01:00
}
2020-11-20 18:28:51 +01:00
// Target-dependent description of a boot image.
2022-10-04 16:21:47 +02:00
//
// WARNING: The warning comment on bootImageConfig applies here too.
2020-02-18 21:43:06 +01:00
type bootImageVariant struct {
* bootImageConfig
// Target for which the image is generated.
target android . Target
2020-03-30 18:24:13 +02:00
// The "locations" of jars.
dexLocations [ ] string // for this image
dexLocationsDeps [ ] string // for the dependency images and in this image
2020-02-18 21:43:06 +01:00
// Paths to image files.
2021-06-04 18:25:28 +02:00
imagePathOnHost android . OutputPath // first image file path on host
imagePathOnDevice string // first image file path on device
2020-02-18 21:43:06 +01:00
2021-06-04 18:25:28 +02:00
// All the files that constitute this image variant, i.e. .art, .oat and .vdex files.
imagesDeps android . OutputPaths
2023-02-23 18:37:16 +01:00
// The path to the base image variant's imagePathOnHost field, where base image variant
2021-06-04 18:25:28 +02:00
// means the image variant that this extends.
//
// This is only set for a variant of an image that extends another image.
2023-02-23 18:37:16 +01:00
baseImages android . OutputPaths
2020-02-18 21:43:06 +01:00
2023-02-23 18:37:16 +01:00
// The paths to the base image variant's imagesDeps field, where base image variant
2021-06-04 18:25:28 +02:00
// means the image variant that this extends.
//
// This is only set for a variant of an image that extends another image.
2023-02-23 18:37:16 +01:00
baseImagesDeps android . Paths
2021-06-04 18:25:28 +02:00
2022-01-12 18:56:19 +01:00
// Rules which should be used in make to install the outputs on host.
2022-10-04 16:21:47 +02:00
//
// Deprecated: Not initialized correctly, see struct comment.
installs android . RuleBuilderInstalls
// Rules which should be used in make to install the vdex outputs on host.
//
// Deprecated: Not initialized correctly, see struct comment.
vdexInstalls android . RuleBuilderInstalls
// Rules which should be used in make to install the unstripped outputs on host.
//
// Deprecated: Not initialized correctly, see struct comment.
2020-02-18 21:43:06 +01:00
unstrippedInstalls android . RuleBuilderInstalls
2022-01-12 18:56:19 +01:00
2022-03-16 01:49:24 +01:00
// Path to the license metadata file for the module that built the image.
2022-10-04 16:21:47 +02:00
//
// Deprecated: Not initialized correctly, see struct comment.
2022-03-16 01:49:24 +01:00
licenseMetadataFile android . OptionalPath
2020-02-18 21:43:06 +01:00
}
2020-11-20 18:28:51 +01:00
// Get target-specific boot image variant for the given boot image config and target.
2020-02-18 21:43:06 +01:00
func ( image bootImageConfig ) getVariant ( target android . Target ) * bootImageVariant {
for _ , variant := range image . variants {
if variant . target . Os == target . Os && variant . target . Arch . ArchType == target . Arch . ArchType {
return variant
}
}
return nil
2019-11-08 11:54:21 +01:00
}
2020-11-20 18:28:51 +01:00
// Return any (the first) variant which is for the device (as opposed to for the host).
2020-03-30 18:24:13 +02:00
func ( image bootImageConfig ) getAnyAndroidVariant ( ) * bootImageVariant {
for _ , variant := range image . variants {
if variant . target . Os == android . Android {
return variant
}
}
return nil
}
2020-11-20 18:28:51 +01:00
// Return the name of a boot image module given a boot image config and a component (module) index.
// A module name is a combination of the Java library name, and the boot image stem (that is stored
// in the config).
2020-05-11 19:06:15 +02:00
func ( image bootImageConfig ) moduleName ( ctx android . PathContext , idx int ) string {
2020-11-20 18:28:51 +01:00
// The first module of the primary boot image is special: its module name has only the stem, but
// not the library name. All other module names are of the form <stem>-<library name>
2020-07-01 15:31:13 +02:00
m := image . modules . Jar ( idx )
2019-11-08 11:54:21 +01:00
name := image . stem
2020-03-26 12:10:45 +01:00
if idx != 0 || image . extends != nil {
2023-07-12 17:51:48 +02:00
name += "-" + android . ModuleStem ( ctx . Config ( ) , image . modules . Apex ( idx ) , m )
2019-11-08 11:54:21 +01:00
}
return name
}
2019-06-13 23:44:53 +02:00
2020-11-20 18:28:51 +01:00
// Return the name of the first boot image module, or stem if the list of modules is empty.
2020-05-11 19:06:15 +02:00
func ( image bootImageConfig ) firstModuleNameOrStem ( ctx android . PathContext ) string {
2020-07-01 15:31:13 +02:00
if image . modules . Len ( ) > 0 {
2020-05-11 19:06:15 +02:00
return image . moduleName ( ctx , 0 )
2019-11-08 11:54:21 +01:00
} else {
return image . stem
}
}
2020-11-20 18:28:51 +01:00
// Return filenames for the given boot image component, given the output directory and a list of
// extensions.
2019-11-08 11:54:21 +01:00
func ( image bootImageConfig ) moduleFiles ( ctx android . PathContext , dir android . OutputPath , exts ... string ) android . OutputPaths {
2020-07-01 15:31:13 +02:00
ret := make ( android . OutputPaths , 0 , image . modules . Len ( ) * len ( exts ) )
for i := 0 ; i < image . modules . Len ( ) ; i ++ {
2020-05-11 19:06:15 +02:00
name := image . moduleName ( ctx , i )
2019-06-13 23:44:53 +02:00
for _ , ext := range exts {
ret = append ( ret , dir . Join ( ctx , name + ext ) )
}
2023-03-06 20:16:48 +01:00
if image . singleImage {
break
}
2019-06-13 23:44:53 +02:00
}
return ret
}
2021-06-07 11:25:31 +02:00
// apexVariants returns a list of all *bootImageVariant that could be included in an apex.
func ( image * bootImageConfig ) apexVariants ( ) [ ] * bootImageVariant {
variants := [ ] * bootImageVariant { }
for _ , variant := range image . variants {
// We also generate boot images for host (for testing), but we don't need those in the apex.
// TODO(b/177892522) - consider changing this to check Os.OsClass = android.Device
if variant . target . Os == android . Android {
variants = append ( variants , variant )
}
}
return variants
}
2020-11-20 18:28:51 +01:00
// Return boot image locations (as a list of symbolic paths).
//
2020-03-26 12:10:45 +01:00
// The image "location" is a symbolic path that, with multiarchitecture support, doesn't really
// exist on the device. Typically it is /apex/com.android.art/javalib/boot.art and should be the
// same for all supported architectures on the device. The concrete architecture specific files
// actually end up in architecture-specific sub-directory such as arm, arm64, x86, or x86_64.
//
2020-11-20 18:28:51 +01:00
// For example a physical file /apex/com.android.art/javalib/x86/boot.art has "image location"
// /apex/com.android.art/javalib/boot.art (which is not an actual file).
//
// For a primary boot image the list of locations has a single element.
//
// For a boot image extension the list of locations contains a location for all dependency images
// (including the primary image) and the location of the extension itself. For example, for the
// Framework boot image extension that depends on the primary ART boot image the list contains two
// elements.
2020-03-26 12:10:45 +01:00
//
// The location is passed as an argument to the ART tools like dex2oat instead of the real path.
// ART tools will then reconstruct the architecture-specific real path.
2021-04-27 16:56:44 +02:00
func ( image * bootImageVariant ) imageLocations ( ) ( imageLocationsOnHost [ ] string , imageLocationsOnDevice [ ] string ) {
2020-03-26 12:10:45 +01:00
if image . extends != nil {
2021-04-27 16:56:44 +02:00
imageLocationsOnHost , imageLocationsOnDevice = image . extends . getVariant ( image . target ) . imageLocations ( )
2020-03-26 12:10:45 +01:00
}
2021-04-27 16:56:44 +02:00
return append ( imageLocationsOnHost , dexpreopt . PathToLocation ( image . imagePathOnHost , image . target . Arch . ArchType ) ) ,
append ( imageLocationsOnDevice , dexpreopt . PathStringToLocation ( image . imagePathOnDevice , image . target . Arch . ArchType ) )
2020-03-26 12:10:45 +01:00
}
2023-02-23 18:50:46 +01:00
func ( image * bootImageConfig ) isProfileGuided ( ) bool {
return image . compilerFilter == "speed-profile"
}
2023-07-13 12:03:38 +02:00
func ( image * bootImageConfig ) isEnabled ( ctx android . BaseModuleContext ) bool {
return ctx . OtherModuleExists ( image . enabledIfExists )
}
2021-01-20 18:44:53 +01:00
func dexpreoptBootJarsFactory ( ) android . SingletonModule {
m := & dexpreoptBootJars { }
2023-07-13 12:03:38 +02:00
android . InitAndroidArchModule ( m , android . DeviceSupported , android . MultilibCommon )
2021-01-20 18:44:53 +01:00
return m
2019-02-11 23:21:24 +01:00
}
2020-01-13 16:18:16 +01:00
func RegisterDexpreoptBootJarsComponents ( ctx android . RegistrationContext ) {
2023-05-16 02:58:37 +02:00
ctx . RegisterParallelSingletonModuleType ( "dex_bootjars" , dexpreoptBootJarsFactory )
2023-07-13 12:03:38 +02:00
ctx . FinalDepsMutators ( func ( ctx android . RegisterMutatorsContext ) {
ctx . BottomUp ( "dex_bootjars_deps" , DexpreoptBootJarsMutator ) . Parallel ( )
} )
2020-01-13 16:18:16 +01:00
}
2021-01-15 19:40:04 +01:00
func SkipDexpreoptBootJars ( ctx android . PathContext ) bool {
2023-07-13 12:03:38 +02:00
global := dexpreopt . GetGlobalConfig ( ctx )
return global . DisablePreoptBootImages || ! shouldBuildBootImages ( ctx . Config ( ) , global )
2019-02-11 23:21:24 +01:00
}
2021-01-20 18:44:53 +01:00
// Singleton module for generating boot image build rules.
2019-02-16 08:06:46 +01:00
type dexpreoptBootJars struct {
2021-01-20 18:44:53 +01:00
android . SingletonModuleBase
2020-11-20 18:28:51 +01:00
// Default boot image config (currently always the Framework boot image extension). It should be
// noted that JIT-Zygote builds use ART APEX image instead of the Framework boot image extension,
// but the switch is handled not here, but in the makefiles (triggered with
// DEXPREOPT_USE_ART_IMAGE=true).
2020-02-18 21:43:06 +01:00
defaultBootImage * bootImageConfig
2019-05-10 06:50:00 +02:00
2020-11-20 18:28:51 +01:00
// Other boot image configs (currently the list contains only the primary ART APEX image. It
// used to contain an experimental JIT-Zygote image (now replaced with the ART APEX image). In
// the future other boot image extensions may be added.
otherImages [ ] * bootImageConfig
// Build path to a config file that Soong writes for Make (to be used in makefiles that install
// the default boot image).
2019-05-10 06:50:00 +02:00
dexpreoptConfigForMake android . WritablePath
2019-02-16 08:06:46 +01:00
}
2019-02-11 23:21:24 +01:00
2023-12-13 01:06:32 +01:00
func ( dbj * dexpreoptBootJars ) DepsMutator ( ctx android . BottomUpMutatorContext ) {
// Create a dependency on all_apex_contributions to determine the selected mainline module
ctx . AddDependency ( ctx . Module ( ) , apexContributionsMetadataDepTag , "all_apex_contributions" )
}
2023-07-13 12:03:38 +02:00
func DexpreoptBootJarsMutator ( ctx android . BottomUpMutatorContext ) {
if _ , ok := ctx . Module ( ) . ( * dexpreoptBootJars ) ; ! ok {
2020-01-31 18:10:36 +01:00
return
}
2019-05-10 06:50:00 +02:00
2023-07-13 12:03:38 +02:00
if dexpreopt . IsDex2oatNeeded ( ctx ) {
// Add a dependency onto the dex2oat tool which is needed for creating the boot image. The
// path is retrieved from the dependency by GetGlobalSoongConfig(ctx).
dexpreopt . RegisterToolDeps ( ctx )
2019-02-11 23:21:24 +01:00
}
2023-02-23 18:37:16 +01:00
imageConfigs := genBootImageConfigs ( ctx )
for _ , config := range imageConfigs {
2023-07-13 12:03:38 +02:00
if ! config . isEnabled ( ctx ) {
continue
}
// For accessing the boot jars.
addDependenciesOntoBootImageModules ( ctx , config . modules , dexpreoptBootJarDepTag )
2023-12-13 01:06:32 +01:00
// Create a dependency on the apex selected using RELEASE_APEX_CONTRIBUTIONS_*
// TODO: b/308174306 - Remove the direct depedendency edge to the java_library (source/prebuilt) once all mainline modules
// have been flagged using RELEASE_APEX_CONTRIBUTIONS_*
apexes := [ ] string { }
for i := 0 ; i < config . modules . Len ( ) ; i ++ {
apexes = append ( apexes , config . modules . Apex ( i ) )
}
addDependenciesOntoSelectedBootImageApexes ( ctx , android . FirstUniqueStrings ( apexes ) ... )
2023-07-13 12:03:38 +02:00
}
if ctx . OtherModuleExists ( "platform-bootclasspath" ) {
// For accessing all bootclasspath fragments.
addDependencyOntoApexModulePair ( ctx , "platform" , "platform-bootclasspath" , platformBootclasspathDepTag )
} else if ctx . OtherModuleExists ( "art-bootclasspath-fragment" ) {
// For accessing the ART bootclasspath fragment on a thin manifest (e.g., master-art) where
// platform-bootclasspath doesn't exist.
addDependencyOntoApexModulePair ( ctx , "com.android.art" , "art-bootclasspath-fragment" , bootclasspathFragmentDepTag )
}
}
2023-12-13 01:06:32 +01:00
// Create a dependency from dex_bootjars to the specific apexes selected using all_apex_contributions
// This dependency will be used to get the path to the deapexed dex boot jars and profile (via a provider)
func addDependenciesOntoSelectedBootImageApexes ( ctx android . BottomUpMutatorContext , apexes ... string ) {
psi := android . PrebuiltSelectionInfoMap { }
ctx . VisitDirectDepsWithTag ( apexContributionsMetadataDepTag , func ( am android . Module ) {
2023-12-20 02:27:29 +01:00
if info , exists := android . OtherModuleProvider ( ctx , am , android . PrebuiltSelectionInfoProvider ) ; exists {
psi = info
2023-12-13 01:06:32 +01:00
}
} )
for _ , apex := range apexes {
for _ , selected := range psi . GetSelectedModulesForApiDomain ( apex ) {
// We need to add a dep on only the apex listed in `contents` of the selected apex_contributions module
// This is not available in a structured format in `apex_contributions`, so this hack adds a dep on all `contents`
// (some modules like art.module.public.api do not have an apex variation since it is a pure stub module that does not get installed)
apexVariationOfSelected := append ( ctx . Target ( ) . Variations ( ) , blueprint . Variation { Mutator : "apex" , Variation : apex } )
if ctx . OtherModuleDependencyVariantExists ( apexVariationOfSelected , selected ) {
ctx . AddFarVariationDependencies ( apexVariationOfSelected , dexpreoptBootJarDepTag , selected )
}
}
}
}
2023-07-13 12:03:38 +02:00
func gatherBootclasspathFragments ( ctx android . ModuleContext ) map [ string ] android . Module {
return ctx . Config ( ) . Once ( dexBootJarsFragmentsKey , func ( ) interface { } {
fragments := make ( map [ string ] android . Module )
ctx . WalkDeps ( func ( child , parent android . Module ) bool {
2024-04-12 02:43:00 +02:00
if ! isActiveModule ( ctx , child ) {
2023-07-13 12:03:38 +02:00
return false
}
tag := ctx . OtherModuleDependencyTag ( child )
if tag == platformBootclasspathDepTag {
return true
}
if tag == bootclasspathFragmentDepTag {
2023-12-13 22:47:44 +01:00
apexInfo , _ := android . OtherModuleProvider ( ctx , child , android . ApexInfoProvider )
2023-07-13 12:03:38 +02:00
for _ , apex := range apexInfo . InApexVariants {
fragments [ apex ] = child
}
return false
}
return false
} )
return fragments
} ) . ( map [ string ] android . Module )
}
func getBootclasspathFragmentByApex ( ctx android . ModuleContext , apexName string ) android . Module {
return gatherBootclasspathFragments ( ctx ) [ apexName ]
}
// GenerateAndroidBuildActions generates the build rules for boot images.
func ( d * dexpreoptBootJars ) GenerateAndroidBuildActions ( ctx android . ModuleContext ) {
imageConfigs := genBootImageConfigs ( ctx )
d . defaultBootImage = defaultBootImageConfig ( ctx )
d . otherImages = make ( [ ] * bootImageConfig , 0 , len ( imageConfigs ) - 1 )
2024-01-17 21:14:44 +01:00
var profileInstalls android . RuleBuilderInstalls
2023-07-13 12:03:38 +02:00
for _ , name := range getImageNames ( ) {
config := imageConfigs [ name ]
if config != d . defaultBootImage {
2023-02-23 18:37:16 +01:00
d . otherImages = append ( d . otherImages , config )
}
2023-07-13 12:03:38 +02:00
if ! config . isEnabled ( ctx ) {
continue
}
2024-01-17 21:14:44 +01:00
installs := generateBootImage ( ctx , config )
profileInstalls = append ( profileInstalls , installs ... )
2023-07-13 12:03:38 +02:00
if config == d . defaultBootImage {
2024-01-17 21:14:44 +01:00
_ , installs := bootFrameworkProfileRule ( ctx , config )
profileInstalls = append ( profileInstalls , installs ... )
2023-07-13 12:03:38 +02:00
}
2023-02-23 18:37:16 +01:00
}
2024-01-17 21:14:44 +01:00
if len ( profileInstalls ) > 0 {
android . SetProvider ( ctx , profileInstallInfoProvider , profileInstallInfo {
profileInstalls : profileInstalls ,
profileLicenseMetadataFile : android . OptionalPathForPath ( ctx . LicenseMetadataFile ( ) ) ,
} )
}
2019-02-16 08:06:46 +01:00
}
2023-07-13 12:03:38 +02:00
// GenerateSingletonBuildActions generates build rules for the dexpreopt config for Make.
func ( d * dexpreoptBootJars ) GenerateSingletonBuildActions ( ctx android . SingletonContext ) {
2024-01-18 18:27:42 +01:00
d . dexpreoptConfigForMake =
android . PathForOutput ( ctx , dexpreopt . GetDexpreoptDirName ( ctx ) , "dexpreopt.config" )
2023-07-13 12:03:38 +02:00
writeGlobalConfigForMake ( ctx , d . dexpreoptConfigForMake )
}
2021-04-26 17:44:00 +02:00
// shouldBuildBootImages determines whether boot images should be built.
func shouldBuildBootImages ( config android . Config , global * dexpreopt . GlobalConfig ) bool {
// Skip recompiling the boot image for the second sanitization phase. We'll get separate paths
// and invalidate first-stage artifacts which are crucial to SANITIZE_LITE builds.
// Note: this is technically incorrect. Compiled code contains stack checks which may depend
// on ASAN settings.
if len ( config . SanitizeDevice ( ) ) == 1 && config . SanitizeDevice ( ) [ 0 ] == "address" && global . SanitizeLite {
return false
}
return true
}
2024-01-17 21:14:44 +01:00
func generateBootImage ( ctx android . ModuleContext , imageConfig * bootImageConfig ) android . RuleBuilderInstalls {
2023-07-13 12:03:38 +02:00
apexJarModulePairs := getModulesForImage ( ctx , imageConfig )
// Copy module dex jars to their predefined locations.
bootDexJarsByModule := extractEncodedDexJarsFromModulesOrBootclasspathFragments ( ctx , apexJarModulePairs )
copyBootJarsToPredefinedLocations ( ctx , bootDexJarsByModule , imageConfig . dexPathsByModule )
// Build a profile for the image config from the profile at the default path. The profile will
// then be used along with profiles imported from APEXes to build the boot image.
2024-01-17 21:14:44 +01:00
profile , profileInstalls := bootImageProfileRule ( ctx , imageConfig )
2023-07-13 12:03:38 +02:00
// If dexpreopt of boot image jars should be skipped, stop after generating a profile.
2023-11-09 17:47:04 +01:00
global := dexpreopt . GetGlobalConfig ( ctx )
if SkipDexpreoptBootJars ( ctx ) || ( global . OnlyPreoptArtBootImage && imageConfig . name != "art" ) {
2024-01-17 21:14:44 +01:00
return profileInstalls
2023-07-13 12:03:38 +02:00
}
// Build boot image files for the android variants.
androidBootImageFiles := buildBootImageVariantsForAndroidOs ( ctx , imageConfig , profile )
// Zip the android variant boot image files up.
buildBootImageZipInPredefinedLocation ( ctx , imageConfig , androidBootImageFiles . byArch )
// Build boot image files for the host variants. There are use directly by ART host side tests.
buildBootImageVariantsForBuildOs ( ctx , imageConfig , profile )
// Create a `dump-oat-<image-name>` rule that runs `oatdump` for debugging purposes.
dumpOatRules ( ctx , imageConfig )
2024-01-17 21:14:44 +01:00
return profileInstalls
2023-07-13 12:03:38 +02:00
}
type apexJarModulePair struct {
2023-10-19 02:38:40 +02:00
apex string
2023-07-13 12:03:38 +02:00
jarModule android . Module
}
func getModulesForImage ( ctx android . ModuleContext , imageConfig * bootImageConfig ) [ ] apexJarModulePair {
modules := make ( [ ] apexJarModulePair , 0 , imageConfig . modules . Len ( ) )
for i := 0 ; i < imageConfig . modules . Len ( ) ; i ++ {
found := false
for _ , module := range gatherApexModulePairDepsWithTag ( ctx , dexpreoptBootJarDepTag ) {
name := android . RemoveOptionalPrebuiltPrefix ( module . Name ( ) )
if name == imageConfig . modules . Jar ( i ) {
modules = append ( modules , apexJarModulePair {
2023-10-19 02:38:40 +02:00
apex : imageConfig . modules . Apex ( i ) ,
2023-07-13 12:03:38 +02:00
jarModule : module ,
} )
found = true
break
}
}
if ! found && ! ctx . Config ( ) . AllowMissingDependencies ( ) {
ctx . ModuleErrorf (
"Boot image '%s' module '%s' not added as a dependency of dex_bootjars" ,
imageConfig . name ,
imageConfig . modules . Jar ( i ) )
return [ ] apexJarModulePair { }
}
}
return modules
}
// extractEncodedDexJarsFromModulesOrBootclasspathFragments gets the hidden API encoded dex jars for
// the given modules.
func extractEncodedDexJarsFromModulesOrBootclasspathFragments ( ctx android . ModuleContext , apexJarModulePairs [ ] apexJarModulePair ) bootDexJarByModule {
Use the correct bootjars for hiddneapi when multiple prebuilts exist
hiddenapi processing require boot jars from apexes to determine the full
set of methods available at runtime.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares platform_bootclasspath to select the right
deapexerd .jar files when mutliple prebuilts exist.
Implementation details
- Create a dependency edge from platform_bootclasspath to
all_apex_contributions (DepsMutator)
- For every boot jar, query all_apex_contributions to get the path to
dexjar file (GenerateAndroidBuildActions)
Some other important details
- This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped
- This CL has a functional change when building with source apexes. At
ToT, the unecoded hiddenapi dex jar is used for package check and
generating the monolithic stub file. After this change, the hiddenapi
encoded file will be used for these operations.
This should be fine since the
package and dex signature do not change across the encoded and
unencoded dex file. In fact, we already have a split today. When
building with prebuilts, we use the encoded dex file. When building
with source, we use the unecoded dex file.
Test: Added a unit test
Test: Manual testing in internal described below
- lunch cf_x86_64_phone-next-userdebug
- flagged com.google.android.adservices using apex_contributions
- aninja -t commands out/soong/hiddenapi/hiddenapi-stubs-flags.txt # no
diff before and after
Bug: 308790777
Change-Id: I72c70f0ae1b587679203ea254c9c12a48e7aa782
2023-12-20 21:13:34 +01:00
apexNameToApexExportInfoMap := getApexNameToApexExportsInfoMap ( ctx )
2023-07-13 12:03:38 +02:00
encodedDexJarsByModuleName := bootDexJarByModule { }
for _ , pair := range apexJarModulePairs {
Use the correct bootjars for hiddneapi when multiple prebuilts exist
hiddenapi processing require boot jars from apexes to determine the full
set of methods available at runtime.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares platform_bootclasspath to select the right
deapexerd .jar files when mutliple prebuilts exist.
Implementation details
- Create a dependency edge from platform_bootclasspath to
all_apex_contributions (DepsMutator)
- For every boot jar, query all_apex_contributions to get the path to
dexjar file (GenerateAndroidBuildActions)
Some other important details
- This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped
- This CL has a functional change when building with source apexes. At
ToT, the unecoded hiddenapi dex jar is used for package check and
generating the monolithic stub file. After this change, the hiddenapi
encoded file will be used for these operations.
This should be fine since the
package and dex signature do not change across the encoded and
unencoded dex file. In fact, we already have a split today. When
building with prebuilts, we use the encoded dex file. When building
with source, we use the unecoded dex file.
Test: Added a unit test
Test: Manual testing in internal described below
- lunch cf_x86_64_phone-next-userdebug
- flagged com.google.android.adservices using apex_contributions
- aninja -t commands out/soong/hiddenapi/hiddenapi-stubs-flags.txt # no
diff before and after
Bug: 308790777
Change-Id: I72c70f0ae1b587679203ea254c9c12a48e7aa782
2023-12-20 21:13:34 +01:00
dexJarPath := getDexJarForApex ( ctx , pair , apexNameToApexExportInfoMap )
2023-12-13 01:06:32 +01:00
encodedDexJarsByModuleName . addPath ( pair . jarModule , dexJarPath )
}
return encodedDexJarsByModuleName
}
Use the correct bootjars for hiddneapi when multiple prebuilts exist
hiddenapi processing require boot jars from apexes to determine the full
set of methods available at runtime.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares platform_bootclasspath to select the right
deapexerd .jar files when mutliple prebuilts exist.
Implementation details
- Create a dependency edge from platform_bootclasspath to
all_apex_contributions (DepsMutator)
- For every boot jar, query all_apex_contributions to get the path to
dexjar file (GenerateAndroidBuildActions)
Some other important details
- This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped
- This CL has a functional change when building with source apexes. At
ToT, the unecoded hiddenapi dex jar is used for package check and
generating the monolithic stub file. After this change, the hiddenapi
encoded file will be used for these operations.
This should be fine since the
package and dex signature do not change across the encoded and
unencoded dex file. In fact, we already have a split today. When
building with prebuilts, we use the encoded dex file. When building
with source, we use the unecoded dex file.
Test: Added a unit test
Test: Manual testing in internal described below
- lunch cf_x86_64_phone-next-userdebug
- flagged com.google.android.adservices using apex_contributions
- aninja -t commands out/soong/hiddenapi/hiddenapi-stubs-flags.txt # no
diff before and after
Bug: 308790777
Change-Id: I72c70f0ae1b587679203ea254c9c12a48e7aa782
2023-12-20 21:13:34 +01:00
type apexNameToApexExportsInfoMap map [ string ] android . ApexExportsInfo
// javaLibraryPathOnHost returns the path to the java library which is exported by the apex for hiddenapi and dexpreopt and a boolean indicating whether the java library exists
// For prebuilt apexes, this is created by deapexing the prebuilt apex
func ( m * apexNameToApexExportsInfoMap ) javaLibraryDexPathOnHost ( ctx android . ModuleContext , apex string , javalib string ) ( android . Path , bool ) {
if info , exists := ( * m ) [ apex ] ; exists {
if dex , exists := info . LibraryNameToDexJarPathOnHost [ javalib ] ; exists {
return dex , true
} else {
ctx . ModuleErrorf ( "Apex %s does not provide a dex boot jar for library %s\n" , apex , javalib )
}
}
// An apex entry could not be found. Return false.
// TODO: b/308174306 - When all the mainline modules have been flagged, make this a hard error
return nil , false
}
Use source_module_name to determine the contents of prebuilt apexes
There are a couple of instances in apex/ and java/ that rely on the naming
convention that the jars exported by prebuilt apexes follow the name of
the java_sdk_library_import, minus the prebuilt_ prefix. With muliple
module sdk prebuilts in trunk stable, this naming convention might not
be valid. Use `source_module_name` instead.
```
prebuilt_sscp_fragment {name: "", contents: ["service-foo.v2"]}
java_import {name: "service-foo.v2", source_module_name: "service-foo"},
```
We should use service-foo and not service-foo.v2 because
1. The prebuilt apex contains service-foo.dex
2. PRODUCT_*JARS will contain service-foo and not service-foo.v2
For clarity, this CL does not drop the current mechanism where prebuilt bcp
fragments create a dependency edge to prebuilt java or java_sdk_library
imports. There is still some discussion around whether we can remove
that completely (b/320711431). If we were to do that, then the
Android.bp files will become
```
prebuilt_sscp_fragment {name: "", contents: ["service-foo"]}
```
Bug: 322175508
Test: Added a unit test
Test: In internal, lunch cf_x86_64_only_phone-next-userdebug && m
nothing # .ninja files identical
Test: In internal, created a parallel set of v2 prebuilts of
java_sdk_library_import and prebuilt_bcp_fragments for adservices && m
nothing # build passes
Change-Id: Ia899d75e826fa1a559368d706eaa65835f748d40
2024-01-19 01:22:22 +01:00
// Returns the stem of an artifact inside a prebuilt apex
func ModuleStemForDeapexing ( m android . Module ) string {
bmn , _ := m . ( interface { BaseModuleName ( ) string } )
return bmn . BaseModuleName ( )
}
2023-12-13 01:06:32 +01:00
// Returns the java libraries exported by the apex for hiddenapi and dexpreopt
// This information can come from two mechanisms
// 1. New: Direct deps to _selected_ apexes. The apexes return a ApexExportsInfo
// 2. Legacy: An edge to java_library or java_import (java_sdk_library) module. For prebuilt apexes, this serves as a hook and is populated by deapexers of prebuilt apxes
// TODO: b/308174306 - Once all mainline modules have been flagged, drop (2)
Use the correct bootjars for hiddneapi when multiple prebuilts exist
hiddenapi processing require boot jars from apexes to determine the full
set of methods available at runtime.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares platform_bootclasspath to select the right
deapexerd .jar files when mutliple prebuilts exist.
Implementation details
- Create a dependency edge from platform_bootclasspath to
all_apex_contributions (DepsMutator)
- For every boot jar, query all_apex_contributions to get the path to
dexjar file (GenerateAndroidBuildActions)
Some other important details
- This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped
- This CL has a functional change when building with source apexes. At
ToT, the unecoded hiddenapi dex jar is used for package check and
generating the monolithic stub file. After this change, the hiddenapi
encoded file will be used for these operations.
This should be fine since the
package and dex signature do not change across the encoded and
unencoded dex file. In fact, we already have a split today. When
building with prebuilts, we use the encoded dex file. When building
with source, we use the unecoded dex file.
Test: Added a unit test
Test: Manual testing in internal described below
- lunch cf_x86_64_phone-next-userdebug
- flagged com.google.android.adservices using apex_contributions
- aninja -t commands out/soong/hiddenapi/hiddenapi-stubs-flags.txt # no
diff before and after
Bug: 308790777
Change-Id: I72c70f0ae1b587679203ea254c9c12a48e7aa782
2023-12-20 21:13:34 +01:00
func getDexJarForApex ( ctx android . ModuleContext , pair apexJarModulePair , apexNameToApexExportsInfoMap apexNameToApexExportsInfoMap ) android . Path {
Use source_module_name to determine the contents of prebuilt apexes
There are a couple of instances in apex/ and java/ that rely on the naming
convention that the jars exported by prebuilt apexes follow the name of
the java_sdk_library_import, minus the prebuilt_ prefix. With muliple
module sdk prebuilts in trunk stable, this naming convention might not
be valid. Use `source_module_name` instead.
```
prebuilt_sscp_fragment {name: "", contents: ["service-foo.v2"]}
java_import {name: "service-foo.v2", source_module_name: "service-foo"},
```
We should use service-foo and not service-foo.v2 because
1. The prebuilt apex contains service-foo.dex
2. PRODUCT_*JARS will contain service-foo and not service-foo.v2
For clarity, this CL does not drop the current mechanism where prebuilt bcp
fragments create a dependency edge to prebuilt java or java_sdk_library
imports. There is still some discussion around whether we can remove
that completely (b/320711431). If we were to do that, then the
Android.bp files will become
```
prebuilt_sscp_fragment {name: "", contents: ["service-foo"]}
```
Bug: 322175508
Test: Added a unit test
Test: In internal, lunch cf_x86_64_only_phone-next-userdebug && m
nothing # .ninja files identical
Test: In internal, created a parallel set of v2 prebuilts of
java_sdk_library_import and prebuilt_bcp_fragments for adservices && m
nothing # build passes
Change-Id: Ia899d75e826fa1a559368d706eaa65835f748d40
2024-01-19 01:22:22 +01:00
if dex , found := apexNameToApexExportsInfoMap . javaLibraryDexPathOnHost ( ctx , pair . apex , ModuleStemForDeapexing ( pair . jarModule ) ) ; found {
Use the correct bootjars for hiddneapi when multiple prebuilts exist
hiddenapi processing require boot jars from apexes to determine the full
set of methods available at runtime.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares platform_bootclasspath to select the right
deapexerd .jar files when mutliple prebuilts exist.
Implementation details
- Create a dependency edge from platform_bootclasspath to
all_apex_contributions (DepsMutator)
- For every boot jar, query all_apex_contributions to get the path to
dexjar file (GenerateAndroidBuildActions)
Some other important details
- This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped
- This CL has a functional change when building with source apexes. At
ToT, the unecoded hiddenapi dex jar is used for package check and
generating the monolithic stub file. After this change, the hiddenapi
encoded file will be used for these operations.
This should be fine since the
package and dex signature do not change across the encoded and
unencoded dex file. In fact, we already have a split today. When
building with prebuilts, we use the encoded dex file. When building
with source, we use the unecoded dex file.
Test: Added a unit test
Test: Manual testing in internal described below
- lunch cf_x86_64_phone-next-userdebug
- flagged com.google.android.adservices using apex_contributions
- aninja -t commands out/soong/hiddenapi/hiddenapi-stubs-flags.txt # no
diff before and after
Bug: 308790777
Change-Id: I72c70f0ae1b587679203ea254c9c12a48e7aa782
2023-12-20 21:13:34 +01:00
return dex
2023-07-13 12:03:38 +02:00
}
2023-12-13 01:06:32 +01:00
// TODO: b/308174306 - Remove the legacy mechanism
if android . IsConfiguredJarForPlatform ( pair . apex ) || android . IsModulePrebuilt ( pair . jarModule ) {
// This gives us the dex jar with the hidden API flags encoded from the monolithic hidden API
// files or the dex jar extracted from a prebuilt APEX. We can't use this for a boot jar for
// a source APEX because there is no guarantee that it is the same as the jar packed into the
// APEX. In practice, they are the same when we are building from a full source tree, but they
// are different when we are building from a thin manifest (e.g., master-art), where there is
// no monolithic hidden API files at all.
return retrieveEncodedBootDexJarFromModule ( ctx , pair . jarModule )
} else {
// Use exactly the same jar that is packed into the APEX.
fragment := getBootclasspathFragmentByApex ( ctx , pair . apex )
if fragment == nil {
ctx . ModuleErrorf ( "Boot jar '%[1]s' is from APEX '%[2]s', but a bootclasspath_fragment for " +
"APEX '%[2]s' doesn't exist or is not added as a dependency of dex_bootjars" ,
pair . jarModule . Name ( ) ,
pair . apex )
}
bootclasspathFragmentInfo , _ := android . OtherModuleProvider ( ctx , fragment , BootclasspathFragmentApexContentInfoProvider )
jar , err := bootclasspathFragmentInfo . DexBootJarPathForContentModule ( pair . jarModule )
if err != nil {
ctx . ModuleErrorf ( "%s" , err )
}
return jar
}
return nil
2023-07-13 12:03:38 +02:00
}
2021-06-02 18:24:22 +02:00
// copyBootJarsToPredefinedLocations generates commands that will copy boot jars to predefined
// paths in the global config.
func copyBootJarsToPredefinedLocations ( ctx android . ModuleContext , srcBootDexJarsByModule bootDexJarByModule , dstBootJarsByModule map [ string ] android . WritablePath ) {
// Create the super set of module names.
names := [ ] string { }
2023-03-01 01:02:16 +01:00
names = append ( names , android . SortedKeys ( srcBootDexJarsByModule ) ... )
names = append ( names , android . SortedKeys ( dstBootJarsByModule ) ... )
2021-06-02 18:24:22 +02:00
names = android . SortedUniqueStrings ( names )
for _ , name := range names {
src := srcBootDexJarsByModule [ name ]
dst := dstBootJarsByModule [ name ]
if src == nil {
2021-12-08 17:26:07 +01:00
// A dex boot jar should be provided by the source java module. It needs to be installable or
// have compile_dex=true - cf. assignments to java.Module.dexJarFile.
//
// However, the source java module may be either replaced or overridden (using prefer:true) by
// a prebuilt java module with the same name. In that case the dex boot jar needs to be
// provided by the corresponding prebuilt APEX module. That APEX is the one that refers
// through a exported_(boot|systemserver)classpath_fragments property to a
// prebuilt_(boot|systemserver)classpath_fragment module, which in turn lists the prebuilt
// java module in the contents property. If that chain is broken then this dependency will
// fail.
2021-08-20 21:18:16 +02:00
if ! ctx . Config ( ) . AllowMissingDependencies ( ) {
2021-12-08 17:26:07 +01:00
ctx . ModuleErrorf ( "module %s does not provide a dex boot jar (see comment next to this message in Soong for details)" , name )
2021-08-20 21:18:16 +02:00
} else {
ctx . AddMissingDependencies ( [ ] string { name } )
}
2021-06-02 18:24:22 +02:00
} else if dst == nil {
ctx . ModuleErrorf ( "module %s is not part of the boot configuration" , name )
2021-04-26 14:24:42 +02:00
} else {
ctx . Build ( pctx , android . BuildParams {
Rule : android . Cp ,
2021-06-02 18:24:22 +02:00
Input : src ,
Output : dst ,
2021-04-26 14:24:42 +02:00
} )
}
2019-02-11 23:21:24 +01:00
}
2021-03-22 13:37:10 +01:00
}
2021-07-02 14:00:43 +02:00
// buildBootImageVariantsForAndroidOs generates rules to build the boot image variants for the
// android.Android OsType and returns a map from the architectures to the paths of the generated
// boot image files.
//
// The paths are returned because they are needed elsewhere in Soong, e.g. for populating an APEX.
2022-10-04 16:36:44 +02:00
func buildBootImageVariantsForAndroidOs ( ctx android . ModuleContext , image * bootImageConfig , profile android . WritablePath ) bootImageOutputs {
2021-07-02 14:00:43 +02:00
return buildBootImageForOsType ( ctx , image , profile , android . Android )
}
// buildBootImageVariantsForBuildOs generates rules to build the boot image variants for the
2021-07-20 18:47:41 +02:00
// config.BuildOS OsType, i.e. the type of OS on which the build is being running.
2021-07-02 14:00:43 +02:00
//
// The files need to be generated into their predefined location because they are used from there
// both within Soong and outside, e.g. for ART based host side testing and also for use by some
// cloud based tools. However, they are not needed by callers of this function and so the paths do
// not need to be returned from this func, unlike the buildBootImageVariantsForAndroidOs func.
func buildBootImageVariantsForBuildOs ( ctx android . ModuleContext , image * bootImageConfig , profile android . WritablePath ) {
2021-07-20 18:47:41 +02:00
buildBootImageForOsType ( ctx , image , profile , ctx . Config ( ) . BuildOS )
2021-07-02 14:00:43 +02:00
}
2023-05-10 17:40:18 +02:00
// bootImageFilesByArch is a map from android.ArchType to the paths to the boot image files.
//
// The paths include the .art, .oat and .vdex files, one for each of the modules from which the boot
// image is created.
type bootImageFilesByArch map [ android . ArchType ] android . Paths
2022-10-04 16:36:44 +02:00
// bootImageOutputs encapsulates information about boot images that were created/obtained by
// commonBootclasspathFragment.produceBootImageFiles.
type bootImageOutputs struct {
// Map from arch to the paths to the boot image files created/obtained for that arch.
byArch bootImageFilesByArch
2022-10-04 17:39:18 +02:00
variants [ ] bootImageVariantOutputs
2022-10-04 16:36:44 +02:00
// The path to the profile file created/obtained for the boot image.
profile android . WritablePath
}
2021-07-02 14:00:43 +02:00
// buildBootImageForOsType takes a bootImageConfig, a profile file and an android.OsType
// boot image files are required for and it creates rules to build the boot image
// files for all the required architectures for them.
2021-07-01 23:04:22 +02:00
//
// It returns a map from android.ArchType to the predefined paths of the boot image files.
2022-10-04 16:36:44 +02:00
func buildBootImageForOsType ( ctx android . ModuleContext , image * bootImageConfig , profile android . WritablePath , requiredOsType android . OsType ) bootImageOutputs {
2021-07-01 23:04:22 +02:00
filesByArch := bootImageFilesByArch { }
2022-10-04 17:39:18 +02:00
imageOutputs := bootImageOutputs {
byArch : filesByArch ,
profile : profile ,
}
2020-02-18 21:43:06 +01:00
for _ , variant := range image . variants {
2021-07-02 14:00:43 +02:00
if variant . target . Os == requiredOsType {
2022-10-04 17:39:18 +02:00
variantOutputs := buildBootImageVariant ( ctx , variant , profile )
imageOutputs . variants = append ( imageOutputs . variants , variantOutputs )
2021-07-01 23:04:22 +02:00
filesByArch [ variant . target . Arch . ArchType ] = variant . imagesDeps . Paths ( )
2020-06-10 16:44:25 +02:00
}
2019-02-11 23:21:24 +01:00
}
2019-02-16 08:06:46 +01:00
2022-10-04 17:39:18 +02:00
return imageOutputs
2021-07-01 23:04:22 +02:00
}
// buildBootImageZipInPredefinedLocation generates a zip file containing all the boot image files.
//
// The supplied filesByArch is nil when the boot image files have not been generated. Otherwise, it
// is a map from android.ArchType to the predefined locations.
func buildBootImageZipInPredefinedLocation ( ctx android . ModuleContext , image * bootImageConfig , filesByArch bootImageFilesByArch ) {
if filesByArch == nil {
return
}
2019-04-10 00:29:41 +02:00
2021-07-01 23:04:22 +02:00
// Compute the list of files from all the architectures.
zipFiles := android . Paths { }
for _ , archType := range android . ArchTypeList ( ) {
zipFiles = append ( zipFiles , filesByArch [ archType ] ... )
2019-04-10 00:29:41 +02:00
}
2021-07-01 23:04:22 +02:00
rule := android . NewRuleBuilder ( pctx , ctx )
rule . Command ( ) .
BuiltTool ( "soong_zip" ) .
FlagWithOutput ( "-o " , image . zip ) .
FlagWithArg ( "-C " , image . dir . Join ( ctx , android . Android . String ( ) ) . String ( ) ) .
FlagWithInputList ( "-f " , zipFiles , " -f " )
rule . Build ( "zip_" + image . name , "zip " + image . name + " image" )
2019-02-11 23:21:24 +01:00
}
2022-10-04 17:39:18 +02:00
type bootImageVariantOutputs struct {
2023-05-10 17:40:18 +02:00
config * bootImageVariant
2022-10-04 17:39:18 +02:00
}
2023-12-13 01:06:32 +01:00
// Returns the profile file for an apex
// This information can come from two mechanisms
// 1. New: Direct deps to _selected_ apexes. The apexes return a BootclasspathFragmentApexContentInfo
// 2. Legacy: An edge to bootclasspath_fragment module. For prebuilt apexes, this serves as a hook and is populated by deapexers of prebuilt apxes
// TODO: b/308174306 - Once all mainline modules have been flagged, drop (2)
func getProfilePathForApex ( ctx android . ModuleContext , apexName string , apexNameToBcpInfoMap map [ string ] android . ApexExportsInfo ) android . Path {
if info , exists := apexNameToBcpInfoMap [ apexName ] ; exists {
return info . ProfilePathOnHost
}
// TODO: b/308174306 - Remove the legacy mechanism
fragment := getBootclasspathFragmentByApex ( ctx , apexName )
if fragment == nil {
ctx . ModuleErrorf ( "Boot image config imports profile from '%[2]s', but a " +
"bootclasspath_fragment for APEX '%[2]s' doesn't exist or is not added as a " +
"dependency of dex_bootjars" ,
apexName )
return nil
}
return fragment . ( commonBootclasspathFragment ) . getProfilePath ( )
}
Use the correct bootjars for hiddneapi when multiple prebuilts exist
hiddenapi processing require boot jars from apexes to determine the full
set of methods available at runtime.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares platform_bootclasspath to select the right
deapexerd .jar files when mutliple prebuilts exist.
Implementation details
- Create a dependency edge from platform_bootclasspath to
all_apex_contributions (DepsMutator)
- For every boot jar, query all_apex_contributions to get the path to
dexjar file (GenerateAndroidBuildActions)
Some other important details
- This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped
- This CL has a functional change when building with source apexes. At
ToT, the unecoded hiddenapi dex jar is used for package check and
generating the monolithic stub file. After this change, the hiddenapi
encoded file will be used for these operations.
This should be fine since the
package and dex signature do not change across the encoded and
unencoded dex file. In fact, we already have a split today. When
building with prebuilts, we use the encoded dex file. When building
with source, we use the unecoded dex file.
Test: Added a unit test
Test: Manual testing in internal described below
- lunch cf_x86_64_phone-next-userdebug
- flagged com.google.android.adservices using apex_contributions
- aninja -t commands out/soong/hiddenapi/hiddenapi-stubs-flags.txt # no
diff before and after
Bug: 308790777
Change-Id: I72c70f0ae1b587679203ea254c9c12a48e7aa782
2023-12-20 21:13:34 +01:00
func getApexNameToApexExportsInfoMap ( ctx android . ModuleContext ) apexNameToApexExportsInfoMap {
apexNameToApexExportsInfoMap := apexNameToApexExportsInfoMap { }
2023-12-13 01:06:32 +01:00
ctx . VisitDirectDepsWithTag ( dexpreoptBootJarDepTag , func ( am android . Module ) {
if info , exists := android . OtherModuleProvider ( ctx , am , android . ApexExportsInfoProvider ) ; exists {
Use the correct bootjars for hiddneapi when multiple prebuilts exist
hiddenapi processing require boot jars from apexes to determine the full
set of methods available at runtime.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares platform_bootclasspath to select the right
deapexerd .jar files when mutliple prebuilts exist.
Implementation details
- Create a dependency edge from platform_bootclasspath to
all_apex_contributions (DepsMutator)
- For every boot jar, query all_apex_contributions to get the path to
dexjar file (GenerateAndroidBuildActions)
Some other important details
- This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped
- This CL has a functional change when building with source apexes. At
ToT, the unecoded hiddenapi dex jar is used for package check and
generating the monolithic stub file. After this change, the hiddenapi
encoded file will be used for these operations.
This should be fine since the
package and dex signature do not change across the encoded and
unencoded dex file. In fact, we already have a split today. When
building with prebuilts, we use the encoded dex file. When building
with source, we use the unecoded dex file.
Test: Added a unit test
Test: Manual testing in internal described below
- lunch cf_x86_64_phone-next-userdebug
- flagged com.google.android.adservices using apex_contributions
- aninja -t commands out/soong/hiddenapi/hiddenapi-stubs-flags.txt # no
diff before and after
Bug: 308790777
Change-Id: I72c70f0ae1b587679203ea254c9c12a48e7aa782
2023-12-20 21:13:34 +01:00
apexNameToApexExportsInfoMap [ info . ApexName ] = info
2023-12-13 01:06:32 +01:00
}
} )
Use the correct bootjars for hiddneapi when multiple prebuilts exist
hiddenapi processing require boot jars from apexes to determine the full
set of methods available at runtime.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares platform_bootclasspath to select the right
deapexerd .jar files when mutliple prebuilts exist.
Implementation details
- Create a dependency edge from platform_bootclasspath to
all_apex_contributions (DepsMutator)
- For every boot jar, query all_apex_contributions to get the path to
dexjar file (GenerateAndroidBuildActions)
Some other important details
- This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped
- This CL has a functional change when building with source apexes. At
ToT, the unecoded hiddenapi dex jar is used for package check and
generating the monolithic stub file. After this change, the hiddenapi
encoded file will be used for these operations.
This should be fine since the
package and dex signature do not change across the encoded and
unencoded dex file. In fact, we already have a split today. When
building with prebuilts, we use the encoded dex file. When building
with source, we use the unecoded dex file.
Test: Added a unit test
Test: Manual testing in internal described below
- lunch cf_x86_64_phone-next-userdebug
- flagged com.google.android.adservices using apex_contributions
- aninja -t commands out/soong/hiddenapi/hiddenapi-stubs-flags.txt # no
diff before and after
Bug: 308790777
Change-Id: I72c70f0ae1b587679203ea254c9c12a48e7aa782
2023-12-20 21:13:34 +01:00
return apexNameToApexExportsInfoMap
2023-12-13 01:06:32 +01:00
}
2020-11-20 18:28:51 +01:00
// Generate boot image build rules for a specific target.
2022-10-04 17:39:18 +02:00
func buildBootImageVariant ( ctx android . ModuleContext , image * bootImageVariant , profile android . Path ) bootImageVariantOutputs {
2019-02-11 23:21:24 +01:00
2021-07-06 11:55:35 +02:00
globalSoong := dexpreopt . GetGlobalSoongConfig ( ctx )
2020-01-20 19:12:23 +01:00
global := dexpreopt . GetGlobalConfig ( ctx )
2019-02-16 08:06:46 +01:00
2020-02-18 21:43:06 +01:00
arch := image . target . Arch . ArchType
2020-02-13 17:00:45 +01:00
os := image . target . Os . String ( ) // We need to distinguish host-x86 and device-x86.
2023-05-10 18:04:53 +02:00
symbolsDir := image . symbolsDir . Join ( ctx , os , image . installDir , arch . String ( ) )
2019-11-08 11:51:01 +01:00
symbolsFile := symbolsDir . Join ( ctx , image . stem + ".oat" )
2023-05-10 18:04:53 +02:00
outputDir := image . dir . Join ( ctx , os , image . installDir , arch . String ( ) )
2019-11-08 11:54:21 +01:00
outputPath := outputDir . Join ( ctx , image . stem + ".oat" )
oatLocation := dexpreopt . PathToLocation ( outputPath , arch )
imagePath := outputPath . ReplaceExtension ( ctx , "art" )
2019-02-11 23:21:24 +01:00
2020-11-17 02:32:30 +01:00
rule := android . NewRuleBuilder ( pctx , ctx )
2019-02-11 23:21:24 +01:00
rule . Command ( ) . Text ( "mkdir" ) . Flag ( "-p" ) . Flag ( symbolsDir . String ( ) )
rule . Command ( ) . Text ( "rm" ) . Flag ( "-f" ) .
Flag ( symbolsDir . Join ( ctx , "*.art" ) . String ( ) ) .
Flag ( symbolsDir . Join ( ctx , "*.oat" ) . String ( ) ) .
2023-07-13 12:03:38 +02:00
Flag ( symbolsDir . Join ( ctx , "*.vdex" ) . String ( ) ) .
2019-02-11 23:21:24 +01:00
Flag ( symbolsDir . Join ( ctx , "*.invocation" ) . String ( ) )
rule . Command ( ) . Text ( "rm" ) . Flag ( "-f" ) .
Flag ( outputDir . Join ( ctx , "*.art" ) . String ( ) ) .
Flag ( outputDir . Join ( ctx , "*.oat" ) . String ( ) ) .
2023-07-13 12:03:38 +02:00
Flag ( outputDir . Join ( ctx , "*.vdex" ) . String ( ) ) .
2019-02-11 23:21:24 +01:00
Flag ( outputDir . Join ( ctx , "*.invocation" ) . String ( ) )
cmd := rule . Command ( )
extraFlags := ctx . Config ( ) . Getenv ( "ART_BOOT_IMAGE_EXTRA_ARGS" )
if extraFlags == "" {
// Use ANDROID_LOG_TAGS to suppress most logging by default...
cmd . Text ( ` ANDROID_LOG_TAGS="*:e" ` )
} else {
// ...unless the boot image is generated specifically for testing, then allow all logging.
cmd . Text ( ` ANDROID_LOG_TAGS="*:v" ` )
}
invocationPath := outputPath . ReplaceExtension ( ctx , "invocation" )
Use the correct bootjars for hiddneapi when multiple prebuilts exist
hiddenapi processing require boot jars from apexes to determine the full
set of methods available at runtime.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares platform_bootclasspath to select the right
deapexerd .jar files when mutliple prebuilts exist.
Implementation details
- Create a dependency edge from platform_bootclasspath to
all_apex_contributions (DepsMutator)
- For every boot jar, query all_apex_contributions to get the path to
dexjar file (GenerateAndroidBuildActions)
Some other important details
- This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped
- This CL has a functional change when building with source apexes. At
ToT, the unecoded hiddenapi dex jar is used for package check and
generating the monolithic stub file. After this change, the hiddenapi
encoded file will be used for these operations.
This should be fine since the
package and dex signature do not change across the encoded and
unencoded dex file. In fact, we already have a split today. When
building with prebuilts, we use the encoded dex file. When building
with source, we use the unecoded dex file.
Test: Added a unit test
Test: Manual testing in internal described below
- lunch cf_x86_64_phone-next-userdebug
- flagged com.google.android.adservices using apex_contributions
- aninja -t commands out/soong/hiddenapi/hiddenapi-stubs-flags.txt # no
diff before and after
Bug: 308790777
Change-Id: I72c70f0ae1b587679203ea254c9c12a48e7aa782
2023-12-20 21:13:34 +01:00
apexNameToApexExportsInfoMap := getApexNameToApexExportsInfoMap ( ctx )
2023-12-13 01:06:32 +01:00
2020-01-10 21:32:59 +01:00
cmd . Tool ( globalSoong . Dex2oat ) .
2019-02-11 23:21:24 +01:00
Flag ( "--avoid-storing-invocation" ) .
2019-02-15 19:39:37 +01:00
FlagWithOutput ( "--write-invocation-to=" , invocationPath ) . ImplicitOutput ( invocationPath ) .
2019-02-16 08:06:46 +01:00
Flag ( "--runtime-arg" ) . FlagWithArg ( "-Xms" , global . Dex2oatImageXms ) .
Flag ( "--runtime-arg" ) . FlagWithArg ( "-Xmx" , global . Dex2oatImageXmx )
2019-02-11 23:21:24 +01:00
2023-07-13 12:03:38 +02:00
if image . isProfileGuided ( ) && ! global . DisableGenerateProfile {
if profile != nil {
cmd . FlagWithInput ( "--profile-file=" , profile )
2023-05-10 19:38:34 +02:00
}
2023-07-13 12:03:38 +02:00
for _ , apex := range image . profileImports {
Use the correct bootjars for hiddneapi when multiple prebuilts exist
hiddenapi processing require boot jars from apexes to determine the full
set of methods available at runtime.
When building with prebuilts, this comes via
java_import/java_sdk_library_import, which acts as a hook for
prebuilt_apex/apex_set. If we have multiple apexes in the tree, this
hook becomes 1:many. This CL prepares platform_bootclasspath to select the right
deapexerd .jar files when mutliple prebuilts exist.
Implementation details
- Create a dependency edge from platform_bootclasspath to
all_apex_contributions (DepsMutator)
- For every boot jar, query all_apex_contributions to get the path to
dexjar file (GenerateAndroidBuildActions)
Some other important details
- This CL does not drop the old mechanism to get the dex file (i.e. by
creating a dep on java_library). Once all mainline
modules have been flagged using apex_contributions, the old mechanism
will be dropped
- This CL has a functional change when building with source apexes. At
ToT, the unecoded hiddenapi dex jar is used for package check and
generating the monolithic stub file. After this change, the hiddenapi
encoded file will be used for these operations.
This should be fine since the
package and dex signature do not change across the encoded and
unencoded dex file. In fact, we already have a split today. When
building with prebuilts, we use the encoded dex file. When building
with source, we use the unecoded dex file.
Test: Added a unit test
Test: Manual testing in internal described below
- lunch cf_x86_64_phone-next-userdebug
- flagged com.google.android.adservices using apex_contributions
- aninja -t commands out/soong/hiddenapi/hiddenapi-stubs-flags.txt # no
diff before and after
Bug: 308790777
Change-Id: I72c70f0ae1b587679203ea254c9c12a48e7aa782
2023-12-20 21:13:34 +01:00
importedProfile := getProfilePathForApex ( ctx , apex , apexNameToApexExportsInfoMap )
2023-07-13 12:03:38 +02:00
if importedProfile == nil {
ctx . ModuleErrorf ( "Boot image config '%[1]s' imports profile from '%[2]s', but '%[2]s' " +
"doesn't provide a profile" ,
image . name ,
apex )
return bootImageVariantOutputs { }
}
cmd . FlagWithInput ( "--profile-file=" , importedProfile )
2023-05-10 19:38:34 +02:00
}
}
2021-01-20 15:30:40 +01:00
dirtyImageFile := "frameworks/base/config/dirty-image-objects"
dirtyImagePath := android . ExistentPathForSource ( ctx , dirtyImageFile )
if dirtyImagePath . Valid ( ) {
cmd . FlagWithInput ( "--dirty-image-objects=" , dirtyImagePath . Path ( ) )
2019-02-11 23:21:24 +01:00
}
2020-03-26 12:10:45 +01:00
if image . extends != nil {
2023-02-23 18:37:16 +01:00
// It is a boot image extension, so it needs the boot images that it depends on.
baseImageLocations := make ( [ ] string , 0 , len ( image . baseImages ) )
for _ , image := range image . baseImages {
baseImageLocations = append ( baseImageLocations , dexpreopt . PathToLocation ( image , arch ) )
}
2019-11-08 11:54:21 +01:00
cmd .
Flag ( "--runtime-arg" ) . FlagWithInputList ( "-Xbootclasspath:" , image . dexPathsDeps . Paths ( ) , ":" ) .
Flag ( "--runtime-arg" ) . FlagWithList ( "-Xbootclasspath-locations:" , image . dexLocationsDeps , ":" ) .
2021-06-04 18:25:28 +02:00
// Add the path to the first file in the boot image with the arch specific directory removed,
// dex2oat will reconstruct the path to the actual file when it needs it. As the actual path
// to the file cannot be passed to the command make sure to add the actual path as an Implicit
// dependency to ensure that it is built before the command runs.
2023-02-23 18:37:16 +01:00
FlagWithList ( "--boot-image=" , baseImageLocations , ":" ) . Implicits ( image . baseImages . Paths ( ) ) .
2021-06-04 18:25:28 +02:00
// Similarly, the dex2oat tool will automatically find the paths to other files in the base
// boot image so make sure to add them as implicit dependencies to ensure that they are built
// before this command is run.
2023-02-23 18:37:16 +01:00
Implicits ( image . baseImagesDeps )
2019-11-08 11:54:21 +01:00
} else {
2020-11-20 18:28:51 +01:00
// It is a primary image, so it needs a base address.
2019-11-08 11:54:21 +01:00
cmd . FlagWithArg ( "--base=" , ctx . Config ( ) . LibartImgDeviceBaseAddress ( ) )
}
2023-02-23 18:50:46 +01:00
if len ( image . preloadedClassesFile ) > 0 {
// We always expect a preloaded classes file to be available. However, if we cannot find it, it's
// OK to not pass the flag to dex2oat.
preloadedClassesPath := android . ExistentPathForSource ( ctx , image . preloadedClassesFile )
if preloadedClassesPath . Valid ( ) {
cmd . FlagWithInput ( "--preloaded-classes=" , preloadedClassesPath . Path ( ) )
}
2022-03-14 16:31:47 +01:00
}
2019-02-11 23:21:24 +01:00
cmd .
2019-02-16 08:06:46 +01:00
FlagForEachInput ( "--dex-file=" , image . dexPaths . Paths ( ) ) .
FlagForEachArg ( "--dex-location=" , image . dexLocations ) .
2019-02-11 23:21:24 +01:00
Flag ( "--generate-debug-info" ) .
Flag ( "--generate-build-id" ) .
2019-07-26 22:50:04 +02:00
Flag ( "--image-format=lz4hc" ) .
2019-11-08 11:54:21 +01:00
FlagWithArg ( "--oat-symbols=" , symbolsFile . String ( ) ) .
FlagWithArg ( "--oat-file=" , outputPath . String ( ) ) .
2019-02-11 23:21:24 +01:00
FlagWithArg ( "--oat-location=" , oatLocation ) .
2019-11-08 11:54:21 +01:00
FlagWithArg ( "--image=" , imagePath . String ( ) ) .
2019-02-11 23:21:24 +01:00
FlagWithArg ( "--instruction-set=" , arch . String ( ) ) .
2019-02-16 08:06:46 +01:00
FlagWithArg ( "--android-root=" , global . EmptyDirectory ) .
2019-02-11 23:21:24 +01:00
FlagWithArg ( "--no-inline-from=" , "core-oj.jar" ) .
2020-03-09 13:46:06 +01:00
Flag ( "--force-determinism" ) .
2023-02-28 16:13:44 +01:00
Flag ( "--abort-on-hard-verifier-error" )
2023-06-28 22:34:44 +02:00
// We don't strip on host to make perf tools work.
if image . target . Os == android . Android {
cmd . Flag ( "--strip" )
}
2023-02-28 16:13:44 +01:00
// If the image is profile-guided but the profile is disabled, we omit "--compiler-filter" to
// leave the decision to dex2oat to pick the compiler filter.
if ! ( image . isProfileGuided ( ) && global . DisableGenerateProfile ) {
cmd . FlagWithArg ( "--compiler-filter=" , image . compilerFilter )
}
2019-02-11 23:21:24 +01:00
2023-03-06 20:16:48 +01:00
if image . singleImage {
cmd . Flag ( "--single-image" )
}
2020-02-13 17:00:45 +01:00
// Use the default variant/features for host builds.
// The map below contains only device CPU info (which might be x86 on some devices).
if image . target . Os == android . Android {
cmd . FlagWithArg ( "--instruction-set-variant=" , global . CpuVariant [ arch ] )
cmd . FlagWithArg ( "--instruction-set-features=" , global . InstructionSetFeatures [ arch ] )
}
2024-01-18 18:27:42 +01:00
if image . target . Os == android . Android {
cmd . Text ( "$(cat" ) . Input ( globalSoong . UffdGcFlag ) . Text ( ")" )
2022-11-16 12:50:59 +01:00
}
2019-02-16 08:06:46 +01:00
if global . BootFlags != "" {
cmd . Flag ( global . BootFlags )
2019-02-11 23:21:24 +01:00
}
if extraFlags != "" {
cmd . Flag ( extraFlags )
}
2019-02-28 20:00:01 +01:00
cmd . Textf ( ` || ( echo %s ; false ) ` , proptools . ShellEscape ( failureMessage ) )
2019-02-11 23:21:24 +01:00
2023-05-10 18:04:53 +02:00
installDir := filepath . Dir ( image . imagePathOnDevice )
2019-02-11 23:21:24 +01:00
var vdexInstalls android . RuleBuilderInstalls
var unstrippedInstalls android . RuleBuilderInstalls
2019-06-13 23:44:53 +02:00
for _ , artOrOat := range image . moduleFiles ( ctx , outputDir , ".art" , ".oat" ) {
cmd . ImplicitOutput ( artOrOat )
2019-02-11 23:21:24 +01:00
2019-06-13 23:44:53 +02:00
// Install the .oat and .art files
rule . Install ( artOrOat , filepath . Join ( installDir , artOrOat . Base ( ) ) )
}
2019-04-10 00:29:41 +02:00
2019-06-13 23:44:53 +02:00
for _ , vdex := range image . moduleFiles ( ctx , outputDir , ".vdex" ) {
cmd . ImplicitOutput ( vdex )
2019-02-11 23:21:24 +01:00
2020-02-13 17:00:45 +01:00
// Note that the vdex files are identical between architectures.
// Make rules will create symlinks to share them between architectures.
2019-02-11 23:21:24 +01:00
vdexInstalls = append ( vdexInstalls ,
2020-02-13 17:00:45 +01:00
android . RuleBuilderInstall { vdex , filepath . Join ( installDir , vdex . Base ( ) ) } )
2019-06-13 23:44:53 +02:00
}
for _ , unstrippedOat := range image . moduleFiles ( ctx , symbolsDir , ".oat" ) {
cmd . ImplicitOutput ( unstrippedOat )
2019-02-11 23:21:24 +01:00
// Install the unstripped oat files. The Make rules will put these in $(TARGET_OUT_UNSTRIPPED)
unstrippedInstalls = append ( unstrippedInstalls ,
2019-02-15 19:39:37 +01:00
android . RuleBuilderInstall { unstrippedOat , filepath . Join ( installDir , unstrippedOat . Base ( ) ) } )
2019-02-11 23:21:24 +01:00
}
2020-11-17 02:32:30 +01:00
rule . Build ( image . name + "JarsDexpreopt_" + image . target . String ( ) , "dexpreopt " + image . name + " jars " + arch . String ( ) )
2019-02-11 23:21:24 +01:00
// save output and installed files for makevars
2022-10-04 21:01:04 +02:00
// TODO - these are always the same and so should be initialized in genBootImageConfigs
2020-02-18 21:43:06 +01:00
image . installs = rule . Installs ( )
image . vdexInstalls = vdexInstalls
image . unstrippedInstalls = unstrippedInstalls
2022-10-04 21:01:04 +02:00
// Only set the licenseMetadataFile from the active module.
2024-04-12 02:43:00 +02:00
if isActiveModule ( ctx , ctx . Module ( ) ) {
2022-10-04 21:01:04 +02:00
image . licenseMetadataFile = android . OptionalPathForPath ( ctx . LicenseMetadataFile ( ) )
}
2022-10-04 17:39:18 +02:00
return bootImageVariantOutputs {
image ,
}
2019-02-11 23:21:24 +01:00
}
const failureMessage = ` ERROR : Dex2oat failed to compile a boot image .
It is likely that the boot classpath is inconsistent .
Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS = "--runtime-arg -verbose:verifier" to see verification errors . `
2023-07-11 16:13:35 +02:00
func bootImageProfileRuleCommon ( ctx android . ModuleContext , name string , dexFiles android . Paths , dexLocations [ ] string ) android . WritablePath {
2021-07-06 11:55:35 +02:00
globalSoong := dexpreopt . GetGlobalSoongConfig ( ctx )
2020-01-20 19:12:23 +01:00
global := dexpreopt . GetGlobalConfig ( ctx )
2019-02-11 23:21:24 +01:00
2021-01-15 19:40:04 +01:00
if global . DisableGenerateProfile {
2019-02-24 17:04:52 +01:00
return nil
}
2019-02-11 23:21:24 +01:00
2021-04-26 13:51:07 +02:00
defaultProfile := "frameworks/base/config/boot-image-profile.txt"
2022-07-11 15:59:14 +02:00
extraProfile := "frameworks/base/config/boot-image-profile-extra.txt"
2019-02-11 23:21:24 +01:00
2021-04-26 13:51:07 +02:00
rule := android . NewRuleBuilder ( pctx , ctx )
2019-02-11 23:21:24 +01:00
2022-07-11 15:59:14 +02:00
var profiles android . Paths
if len ( global . BootImageProfiles ) > 0 {
profiles = append ( profiles , global . BootImageProfiles ... )
2021-04-26 13:51:07 +02:00
} else if path := android . ExistentPathForSource ( ctx , defaultProfile ) ; path . Valid ( ) {
2022-07-11 15:59:14 +02:00
profiles = append ( profiles , path . Path ( ) )
2021-04-26 13:51:07 +02:00
} else {
// No profile (not even a default one, which is the case on some branches
// like master-art-host that don't have frameworks/base).
// Return nil and continue without profile.
return nil
}
2022-07-11 15:59:14 +02:00
if path := android . ExistentPathForSource ( ctx , extraProfile ) ; path . Valid ( ) {
profiles = append ( profiles , path . Path ( ) )
}
2023-07-11 16:13:35 +02:00
bootImageProfile := android . PathForModuleOut ( ctx , name , "boot-image-profile.txt" )
2022-07-11 15:59:14 +02:00
rule . Command ( ) . Text ( "cat" ) . Inputs ( profiles ) . Text ( ">" ) . Output ( bootImageProfile )
2019-02-11 23:21:24 +01:00
2023-07-11 16:13:35 +02:00
profile := android . PathForModuleOut ( ctx , name , "boot.prof" )
2019-02-11 23:21:24 +01:00
2021-04-26 13:51:07 +02:00
rule . Command ( ) .
Text ( ` ANDROID_LOG_TAGS="*:e" ` ) .
Tool ( globalSoong . Profman ) .
Flag ( "--output-profile-type=boot" ) .
FlagWithInput ( "--create-profile-from=" , bootImageProfile ) .
2023-07-11 16:13:35 +02:00
FlagForEachInput ( "--apk=" , dexFiles ) .
FlagForEachArg ( "--dex-location=" , dexLocations ) .
2021-04-26 13:51:07 +02:00
FlagWithOutput ( "--reference-profile-file=" , profile )
2019-02-11 23:21:24 +01:00
2023-07-11 16:13:35 +02:00
rule . Build ( "bootJarsProfile_" + name , "profile boot jars " + name )
return profile
}
2024-01-17 21:14:44 +01:00
type profileInstallInfo struct {
// Rules which should be used in make to install the outputs.
profileInstalls android . RuleBuilderInstalls
// Path to the license metadata file for the module that built the profile.
profileLicenseMetadataFile android . OptionalPath
}
var profileInstallInfoProvider = blueprint . NewProvider [ profileInstallInfo ] ( )
func bootImageProfileRule ( ctx android . ModuleContext , image * bootImageConfig ) ( android . WritablePath , android . RuleBuilderInstalls ) {
2023-07-11 16:13:35 +02:00
if ! image . isProfileGuided ( ) {
2024-01-17 21:14:44 +01:00
return nil , nil
2023-07-11 16:13:35 +02:00
}
profile := bootImageProfileRuleCommon ( ctx , image . name , image . dexPathsDeps . Paths ( ) , image . getAnyAndroidVariant ( ) . dexLocationsDeps )
2021-11-26 19:09:27 +01:00
if image == defaultBootImageConfig ( ctx ) {
2023-07-11 16:13:35 +02:00
rule := android . NewRuleBuilder ( pctx , ctx )
2021-11-26 19:09:27 +01:00
rule . Install ( profile , "/system/etc/boot-image.prof" )
2024-01-17 21:14:44 +01:00
return profile , rule . Installs ( )
2021-11-26 19:09:27 +01:00
}
2024-01-17 21:14:44 +01:00
return profile , nil
2021-04-26 13:51:07 +02:00
}
2019-02-22 16:34:40 +01:00
2021-04-26 17:44:00 +02:00
// bootFrameworkProfileRule generates the rule to create the boot framework profile and
// returns a path to the generated file.
2024-01-17 21:14:44 +01:00
func bootFrameworkProfileRule ( ctx android . ModuleContext , image * bootImageConfig ) ( android . WritablePath , android . RuleBuilderInstalls ) {
2021-04-26 17:44:00 +02:00
globalSoong := dexpreopt . GetGlobalSoongConfig ( ctx )
2020-01-20 19:12:23 +01:00
global := dexpreopt . GetGlobalConfig ( ctx )
2019-07-24 14:19:29 +02:00
2020-05-29 00:28:00 +02:00
if global . DisableGenerateProfile || ctx . Config ( ) . UnbundledBuild ( ) {
2024-01-17 21:14:44 +01:00
return nil , nil
2019-07-24 14:19:29 +02:00
}
2021-04-26 13:51:07 +02:00
defaultProfile := "frameworks/base/config/boot-profile.txt"
2021-04-26 18:08:38 +02:00
bootFrameworkProfile := android . PathForSource ( ctx , defaultProfile )
2019-07-24 14:19:29 +02:00
2021-04-26 13:51:07 +02:00
profile := image . dir . Join ( ctx , "boot.bprof" )
2019-07-24 14:19:29 +02:00
2021-04-26 13:51:07 +02:00
rule := android . NewRuleBuilder ( pctx , ctx )
rule . Command ( ) .
Text ( ` ANDROID_LOG_TAGS="*:e" ` ) .
Tool ( globalSoong . Profman ) .
Flag ( "--output-profile-type=bprof" ) .
FlagWithInput ( "--create-profile-from=" , bootFrameworkProfile ) .
FlagForEachInput ( "--apk=" , image . dexPathsDeps . Paths ( ) ) .
FlagForEachArg ( "--dex-location=" , image . getAnyAndroidVariant ( ) . dexLocationsDeps ) .
FlagWithOutput ( "--reference-profile-file=" , profile )
rule . Install ( profile , "/system/etc/boot-image.bprof" )
rule . Build ( "bootFrameworkProfile" , "profile boot framework jars" )
2024-01-17 21:14:44 +01:00
return profile , rule . Installs ( )
2021-04-26 13:51:07 +02:00
}
2019-07-24 14:19:29 +02:00
2021-04-27 00:09:15 +02:00
func dumpOatRules ( ctx android . ModuleContext , image * bootImageConfig ) {
2019-02-27 06:13:48 +01:00
var allPhonies android . Paths
2023-07-11 15:53:12 +02:00
name := image . name
2024-01-18 18:27:42 +01:00
globalSoong := dexpreopt . GetGlobalSoongConfig ( ctx )
2020-02-18 21:43:06 +01:00
for _ , image := range image . variants {
arch := image . target . Arch . ArchType
2020-03-16 14:27:55 +01:00
suffix := arch . String ( )
// Host and target might both use x86 arch. We need to ensure the names are unique.
if image . target . Os . Class == android . Host {
suffix = "host-" + suffix
}
2019-02-27 06:13:48 +01:00
// Create a rule to call oatdump.
2023-07-11 15:53:12 +02:00
output := android . PathForOutput ( ctx , name + "." + suffix + ".oatdump.txt" )
2020-11-17 02:32:30 +01:00
rule := android . NewRuleBuilder ( pctx , ctx )
2021-04-27 16:56:44 +02:00
imageLocationsOnHost , _ := image . imageLocations ( )
2024-01-18 18:27:42 +01:00
2023-07-11 15:53:12 +02:00
cmd := rule . Command ( ) .
2021-05-18 18:39:56 +02:00
BuiltTool ( "oatdump" ) .
2019-11-08 11:54:21 +01:00
FlagWithInputList ( "--runtime-arg -Xbootclasspath:" , image . dexPathsDeps . Paths ( ) , ":" ) .
FlagWithList ( "--runtime-arg -Xbootclasspath-locations:" , image . dexLocationsDeps , ":" ) .
2021-04-27 16:56:44 +02:00
FlagWithArg ( "--image=" , strings . Join ( imageLocationsOnHost , ":" ) ) . Implicits ( image . imagesDeps . Paths ( ) ) .
2019-02-27 06:13:48 +01:00
FlagWithOutput ( "--output=" , output ) .
FlagWithArg ( "--instruction-set=" , arch . String ( ) )
2024-01-18 18:27:42 +01:00
if image . target . Os == android . Android {
cmd . Text ( "$(cat" ) . Input ( globalSoong . UffdGcFlag ) . Text ( ")" )
2023-07-11 15:53:12 +02:00
}
rule . Build ( "dump-oat-" + name + "-" + suffix , "dump oat " + name + " " + arch . String ( ) )
2019-02-27 06:13:48 +01:00
// Create a phony rule that depends on the output file and prints the path.
2023-07-11 15:53:12 +02:00
phony := android . PathForPhony ( ctx , "dump-oat-" + name + "-" + suffix )
2020-11-17 02:32:30 +01:00
rule = android . NewRuleBuilder ( pctx , ctx )
2019-02-27 06:13:48 +01:00
rule . Command ( ) .
Implicit ( output ) .
ImplicitOutput ( phony ) .
Text ( "echo" ) . FlagWithArg ( "Output in " , output . String ( ) )
2023-07-11 15:53:12 +02:00
rule . Build ( "phony-dump-oat-" + name + "-" + suffix , "dump oat " + name + " " + arch . String ( ) )
2019-02-27 06:13:48 +01:00
2020-03-26 12:10:45 +01:00
allPhonies = append ( allPhonies , phony )
2019-02-27 06:13:48 +01:00
}
2023-07-11 15:53:12 +02:00
phony := android . PathForPhony ( ctx , "dump-oat-" + name )
2019-02-27 06:13:48 +01:00
ctx . Build ( pctx , android . BuildParams {
Rule : android . Phony ,
Output : phony ,
Inputs : allPhonies ,
2023-10-19 02:38:40 +02:00
Description : "dump-oat-" + name ,
2019-02-27 06:13:48 +01:00
} )
}
2019-05-10 06:50:00 +02:00
func writeGlobalConfigForMake ( ctx android . SingletonContext , path android . WritablePath ) {
2020-01-20 19:12:23 +01:00
data := dexpreopt . GetGlobalConfigRawData ( ctx )
2019-05-10 06:50:00 +02:00
2020-11-13 20:48:42 +01:00
android . WriteFileRule ( ctx , path , string ( data ) )
2019-05-10 06:50:00 +02:00
}
2020-11-20 18:28:51 +01:00
// Define Make variables for boot image names, paths, etc. These variables are used in makefiles
// (make/core/dex_preopt_libart.mk) to generate install rules that copy boot image files to the
// correct output directories.
2019-02-16 08:06:46 +01:00
func ( d * dexpreoptBootJars ) MakeVars ( ctx android . MakeVarsContext ) {
2023-05-08 18:28:38 +02:00
if d . dexpreoptConfigForMake != nil && ! SkipDexpreoptBootJars ( ctx ) {
2019-05-10 06:50:00 +02:00
ctx . Strict ( "DEX_PREOPT_CONFIG_FOR_MAKE" , d . dexpreoptConfigForMake . String ( ) )
2020-01-07 00:11:37 +01:00
ctx . Strict ( "DEX_PREOPT_SOONG_CONFIG_FOR_MAKE" , android . PathForOutput ( ctx , "dexpreopt_soong.config" ) . String ( ) )
2019-05-10 06:50:00 +02:00
}
2019-02-16 08:06:46 +01:00
image := d . defaultBootImage
if image != nil {
2024-01-17 21:14:44 +01:00
if profileInstallInfo , ok := android . SingletonModuleProvider ( ctx , d , profileInstallInfoProvider ) ; ok {
ctx . Strict ( "DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED" , profileInstallInfo . profileInstalls . String ( ) )
if profileInstallInfo . profileLicenseMetadataFile . Valid ( ) {
ctx . Strict ( "DEXPREOPT_IMAGE_PROFILE_LICENSE_METADATA" , profileInstallInfo . profileLicenseMetadataFile . String ( ) )
}
2022-03-16 01:49:24 +01:00
}
2021-03-22 17:02:28 +01:00
2023-05-08 18:28:38 +02:00
if SkipDexpreoptBootJars ( ctx ) {
return
}
2021-03-22 17:02:28 +01:00
global := dexpreopt . GetGlobalConfig ( ctx )
dexPaths , dexLocations := bcpForDexpreopt ( ctx , global . PreoptWithUpdatableBcp )
ctx . Strict ( "DEXPREOPT_BOOTCLASSPATH_DEX_FILES" , strings . Join ( dexPaths . Strings ( ) , " " ) )
ctx . Strict ( "DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS" , strings . Join ( dexLocations , " " ) )
2019-02-22 16:34:40 +01:00
2022-04-20 11:53:26 +02:00
// The primary ART boot image is exposed to Make for testing (gtests) and benchmarking
// (golem) purposes.
2019-02-22 16:34:40 +01:00
for _ , current := range append ( d . otherImages , image ) {
2020-03-26 12:10:45 +01:00
for _ , variant := range current . variants {
2020-02-13 17:00:45 +01:00
suffix := ""
2020-03-26 12:10:45 +01:00
if variant . target . Os . Class == android . Host {
2020-02-13 17:00:45 +01:00
suffix = "_host"
}
2020-03-26 12:10:45 +01:00
sfx := variant . name + suffix + "_" + variant . target . Arch . ArchType . String ( )
ctx . Strict ( "DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_" + sfx , variant . vdexInstalls . String ( ) )
2021-05-07 11:53:21 +02:00
ctx . Strict ( "DEXPREOPT_IMAGE_" + sfx , variant . imagePathOnHost . String ( ) )
2020-03-26 12:10:45 +01:00
ctx . Strict ( "DEXPREOPT_IMAGE_DEPS_" + sfx , strings . Join ( variant . imagesDeps . Strings ( ) , " " ) )
ctx . Strict ( "DEXPREOPT_IMAGE_BUILT_INSTALLED_" + sfx , variant . installs . String ( ) )
ctx . Strict ( "DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_" + sfx , variant . unstrippedInstalls . String ( ) )
2022-03-16 01:49:24 +01:00
if variant . licenseMetadataFile . Valid ( ) {
ctx . Strict ( "DEXPREOPT_IMAGE_LICENSE_METADATA_" + sfx , variant . licenseMetadataFile . String ( ) )
}
2019-02-22 16:34:40 +01:00
}
2021-06-23 16:18:50 +02:00
imageLocationsOnHost , imageLocationsOnDevice := current . getAnyAndroidVariant ( ) . imageLocations ( )
ctx . Strict ( "DEXPREOPT_IMAGE_LOCATIONS_ON_HOST" + current . name , strings . Join ( imageLocationsOnHost , ":" ) )
ctx . Strict ( "DEXPREOPT_IMAGE_LOCATIONS_ON_DEVICE" + current . name , strings . Join ( imageLocationsOnDevice , ":" ) )
2019-12-04 22:16:01 +01:00
ctx . Strict ( "DEXPREOPT_IMAGE_ZIP_" + current . name , current . zip . String ( ) )
2019-02-22 16:34:40 +01:00
}
2023-07-13 12:03:38 +02:00
ctx . Strict ( "DEXPREOPT_IMAGE_NAMES" , strings . Join ( getImageNames ( ) , " " ) )
2019-02-11 23:21:24 +01:00
}
}