2021-01-20 16:16:56 +01:00
|
|
|
// Copyright (C) 2021 The Android Open Source Project
|
|
|
|
//
|
|
|
|
// 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 (
|
2021-01-21 19:13:43 +01:00
|
|
|
"fmt"
|
2021-04-19 14:23:53 +02:00
|
|
|
"path/filepath"
|
2019-11-19 20:44:10 +01:00
|
|
|
"reflect"
|
2021-01-20 16:16:56 +01:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"android/soong/android"
|
2021-01-21 19:13:43 +01:00
|
|
|
"android/soong/dexpreopt"
|
2021-05-26 03:16:02 +02:00
|
|
|
|
2021-03-24 00:21:59 +01:00
|
|
|
"github.com/google/blueprint/proptools"
|
2021-03-17 01:26:25 +01:00
|
|
|
|
2021-01-20 16:16:56 +01:00
|
|
|
"github.com/google/blueprint"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-04-23 15:25:28 +02:00
|
|
|
registerBootclasspathFragmentBuildComponents(android.InitRegistrationContext)
|
2021-03-10 16:00:46 +01:00
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
android.RegisterSdkMemberType(&bootclasspathFragmentMemberType{
|
2021-03-29 12:02:53 +02:00
|
|
|
SdkMemberTypeBase: android.SdkMemberTypeBase{
|
2021-05-06 13:02:27 +02:00
|
|
|
PropertyName: "bootclasspath_fragments",
|
|
|
|
SupportsSdk: true,
|
2021-03-29 12:02:53 +02:00
|
|
|
},
|
|
|
|
})
|
2021-01-20 16:16:56 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func registerBootclasspathFragmentBuildComponents(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("bootclasspath_fragment", bootclasspathFragmentFactory)
|
|
|
|
ctx.RegisterModuleType("prebuilt_bootclasspath_fragment", prebuiltBootclasspathFragmentFactory)
|
2021-01-20 16:16:56 +01:00
|
|
|
}
|
|
|
|
|
2021-04-20 23:47:03 +02:00
|
|
|
type bootclasspathFragmentContentDependencyTag struct {
|
2021-03-24 00:21:59 +01:00
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
// Avoid having to make bootclasspath_fragment content visible to the bootclasspath_fragment.
|
2021-03-24 00:21:59 +01:00
|
|
|
//
|
2021-04-23 15:25:28 +02:00
|
|
|
// This is a temporary workaround to make it easier to migrate to bootclasspath_fragment modules
|
|
|
|
// with proper dependencies.
|
2021-03-24 00:21:59 +01:00
|
|
|
// TODO(b/177892522): Remove this and add needed visibility.
|
2021-04-20 23:47:03 +02:00
|
|
|
func (b bootclasspathFragmentContentDependencyTag) ExcludeFromVisibilityEnforcement() {
|
|
|
|
}
|
|
|
|
|
|
|
|
// The bootclasspath_fragment contents must never depend on prebuilts.
|
|
|
|
func (b bootclasspathFragmentContentDependencyTag) ReplaceSourceWithPrebuilt() bool {
|
|
|
|
return false
|
2021-03-24 00:21:59 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 21:41:23 +02:00
|
|
|
// SdkMemberType causes dependencies added with this tag to be automatically added to the sdk as if
|
2021-05-12 14:46:54 +02:00
|
|
|
// they were specified using java_boot_libs or java_sdk_libs.
|
|
|
|
func (b bootclasspathFragmentContentDependencyTag) SdkMemberType(child android.Module) android.SdkMemberType {
|
|
|
|
// If the module is a java_sdk_library then treat it as if it was specified in the java_sdk_libs
|
|
|
|
// property, otherwise treat if it was specified in the java_boot_libs property.
|
|
|
|
if javaSdkLibrarySdkMemberType.IsInstance(child) {
|
|
|
|
return javaSdkLibrarySdkMemberType
|
|
|
|
}
|
|
|
|
|
2021-04-23 21:41:23 +02:00
|
|
|
return javaBootLibsSdkMemberType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b bootclasspathFragmentContentDependencyTag) ExportMember() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2021-05-26 03:16:02 +02:00
|
|
|
// Contents of bootclasspath fragments in an apex are considered to be directly in the apex, as if
|
|
|
|
// they were listed in java_libs.
|
|
|
|
func (b bootclasspathFragmentContentDependencyTag) CopyDirectlyInAnyApex() {}
|
|
|
|
|
2021-06-17 15:56:05 +02:00
|
|
|
// Contents of bootclasspath fragments require files from prebuilt apex files.
|
|
|
|
func (b bootclasspathFragmentContentDependencyTag) RequiresFilesFromPrebuiltApex() {}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
// The tag used for the dependency between the bootclasspath_fragment module and its contents.
|
2021-04-20 23:47:03 +02:00
|
|
|
var bootclasspathFragmentContentDepTag = bootclasspathFragmentContentDependencyTag{}
|
2021-03-24 00:21:59 +01:00
|
|
|
|
2021-04-20 23:47:03 +02:00
|
|
|
var _ android.ExcludeFromVisibilityEnforcementTag = bootclasspathFragmentContentDepTag
|
|
|
|
var _ android.ReplaceSourceWithPrebuilt = bootclasspathFragmentContentDepTag
|
2021-09-02 15:29:21 +02:00
|
|
|
var _ android.SdkMemberDependencyTag = bootclasspathFragmentContentDepTag
|
2021-05-26 03:16:02 +02:00
|
|
|
var _ android.CopyDirectlyInAnyApexTag = bootclasspathFragmentContentDepTag
|
2021-06-17 15:56:05 +02:00
|
|
|
var _ android.RequiresFilesFromPrebuiltApexTag = bootclasspathFragmentContentDepTag
|
2021-03-24 00:21:59 +01:00
|
|
|
|
2021-04-20 23:47:03 +02:00
|
|
|
func IsBootclasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool {
|
|
|
|
return tag == bootclasspathFragmentContentDepTag
|
2021-03-24 16:42:20 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 14:55:49 +02:00
|
|
|
// Properties that can be different when coverage is enabled.
|
|
|
|
type BootclasspathFragmentCoverageAffectedProperties struct {
|
|
|
|
// The contents of this bootclasspath_fragment, could be either java_library, or java_sdk_library.
|
|
|
|
//
|
2021-05-13 22:25:05 +02:00
|
|
|
// A java_sdk_library specified here will also be treated as if it was specified on the stub_libs
|
|
|
|
// property.
|
|
|
|
//
|
2021-04-23 14:55:49 +02:00
|
|
|
// The order of this list matters as it is the order that is used in the bootclasspath.
|
|
|
|
Contents []string
|
2021-04-25 11:13:54 +02:00
|
|
|
|
|
|
|
// The properties for specifying the API stubs provided by this fragment.
|
|
|
|
BootclasspathAPIProperties
|
2021-04-23 14:55:49 +02:00
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
type bootclasspathFragmentProperties struct {
|
2021-01-20 16:16:56 +01:00
|
|
|
// The name of the image this represents.
|
|
|
|
//
|
2021-03-24 02:34:57 +01:00
|
|
|
// If specified then it must be one of "art" or "boot".
|
2021-03-24 00:06:38 +01:00
|
|
|
Image_name *string
|
2021-03-24 00:21:59 +01:00
|
|
|
|
2021-04-23 14:55:49 +02:00
|
|
|
// Properties whose values need to differ with and without coverage.
|
|
|
|
BootclasspathFragmentCoverageAffectedProperties
|
|
|
|
Coverage BootclasspathFragmentCoverageAffectedProperties
|
2021-04-09 00:01:37 +02:00
|
|
|
|
2021-06-18 19:14:25 +02:00
|
|
|
// Hidden API related properties.
|
2021-04-09 00:01:37 +02:00
|
|
|
Hidden_api HiddenAPIFlagFileProperties
|
2021-05-15 10:10:42 +02:00
|
|
|
|
2021-05-26 11:16:01 +02:00
|
|
|
// The list of additional stub libraries which this fragment's contents use but which are not
|
|
|
|
// provided by another bootclasspath_fragment.
|
|
|
|
//
|
|
|
|
// Note, "android-non-updatable" is treated specially. While no such module exists it is treated
|
|
|
|
// as if it was a java_sdk_library. So, when public API stubs are needed then it will be replaced
|
|
|
|
// with "android-non-updatable.stubs", with "androidn-non-updatable.system.stubs" when the system
|
|
|
|
// stubs are needed and so on.
|
|
|
|
Additional_stubs []string
|
|
|
|
|
2021-05-15 10:10:42 +02:00
|
|
|
// Properties that allow a fragment to depend on other fragments. This is needed for hidden API
|
|
|
|
// processing as it needs access to all the classes used by a fragment including those provided
|
|
|
|
// by other fragments.
|
|
|
|
BootclasspathFragmentsDepsProperties
|
2021-01-20 16:16:56 +01:00
|
|
|
}
|
|
|
|
|
2021-08-03 16:42:27 +02:00
|
|
|
type SourceOnlyBootclasspathProperties struct {
|
|
|
|
Hidden_api struct {
|
|
|
|
// Contains prefixes of a package hierarchy that is provided solely by this
|
|
|
|
// bootclasspath_fragment.
|
|
|
|
//
|
|
|
|
// This affects the signature patterns file that is used to select the subset of monolithic
|
|
|
|
// hidden API flags. See split_packages property for more details.
|
|
|
|
Package_prefixes []string
|
|
|
|
|
|
|
|
// The list of split packages provided by this bootclasspath_fragment.
|
|
|
|
//
|
|
|
|
// A split package is one that contains classes which are provided by multiple
|
|
|
|
// bootclasspath_fragment modules.
|
|
|
|
//
|
|
|
|
// This defaults to "*" - which treats all packages as being split. A module that has no split
|
|
|
|
// packages must specify an empty list.
|
|
|
|
//
|
|
|
|
// This affects the signature patterns file that is generated by a bootclasspath_fragment and
|
|
|
|
// used to select the subset of monolithic hidden API flags against which the flags generated
|
|
|
|
// by the bootclasspath_fragment are compared.
|
|
|
|
//
|
|
|
|
// The signature patterns file selects the subset of monolithic hidden API flags using a number
|
|
|
|
// of patterns, i.e.:
|
|
|
|
// * The qualified name (including package) of an outermost class, e.g. java/lang/Character.
|
|
|
|
// This selects all the flags for all the members of this class and any nested classes.
|
|
|
|
// * A package wildcard, e.g. java/lang/*. This selects all the flags for all the members of all
|
|
|
|
// the classes in this package (but not in sub-packages).
|
|
|
|
// * A recursive package wildcard, e.g. java/**. This selects all the flags for all the members
|
|
|
|
// of all the classes in this package and sub-packages.
|
|
|
|
//
|
|
|
|
// The signature patterns file is constructed as follows:
|
|
|
|
// * All the signatures are retrieved from the all-flags.csv file.
|
|
|
|
// * The member and inner class names are removed.
|
|
|
|
// * If a class is in a split package then that is kept, otherwise the class part is removed
|
|
|
|
// and replaced with a wildcard, i.e. *.
|
|
|
|
// * If a package matches a package prefix then the package is removed.
|
|
|
|
// * All the package prefixes are added with a recursive wildcard appended to each, i.e. **.
|
|
|
|
// * The resulting patterns are sorted.
|
|
|
|
//
|
|
|
|
// So, by default (i.e. without specifying any package_prefixes or split_packages) the signature
|
|
|
|
// patterns is a list of class names, because there are no package packages and all packages are
|
|
|
|
// assumed to be split.
|
|
|
|
//
|
|
|
|
// If any split packages are specified then only those packages are treated as split and all
|
|
|
|
// other packages are treated as belonging solely to the bootclasspath_fragment and so they use
|
|
|
|
// wildcard package patterns.
|
|
|
|
//
|
|
|
|
// So, if an empty list of split packages is specified then the signature patterns file just
|
|
|
|
// includes a wildcard package pattern for every package provided by the bootclasspath_fragment.
|
|
|
|
//
|
|
|
|
// If split_packages are specified and a package that is split is not listed then it could lead
|
|
|
|
// to build failures as it will select monolithic flags that are generated by another
|
|
|
|
// bootclasspath_fragment to compare against the flags provided by this fragment. The latter
|
|
|
|
// will obviously not contain those flags and that can cause the comparison and build to fail.
|
|
|
|
//
|
|
|
|
// If any package prefixes are specified then any matching packages are removed from the
|
|
|
|
// signature patterns and replaced with a single recursive package pattern.
|
|
|
|
//
|
|
|
|
// It is not strictly necessary to specify either package_prefixes or split_packages as the
|
|
|
|
// defaults will produce a valid set of signature patterns. However, those patterns may include
|
|
|
|
// implementation details, e.g. names of implementation classes or packages, which will be
|
|
|
|
// exported to the sdk snapshot in the signature patterns file. That is something that should be
|
|
|
|
// avoided where possible. Specifying package_prefixes and split_packages allows those
|
|
|
|
// implementation details to be excluded from the snapshot.
|
|
|
|
Split_packages []string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
type BootclasspathFragmentModule struct {
|
2021-01-20 16:16:56 +01:00
|
|
|
android.ModuleBase
|
2021-01-21 19:13:43 +01:00
|
|
|
android.ApexModuleBase
|
2021-03-10 16:00:46 +01:00
|
|
|
android.SdkBase
|
2021-05-07 00:59:58 +02:00
|
|
|
ClasspathFragmentBase
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
properties bootclasspathFragmentProperties
|
2021-06-07 16:49:13 +02:00
|
|
|
|
2021-08-03 16:42:27 +02:00
|
|
|
sourceOnlyProperties SourceOnlyBootclasspathProperties
|
|
|
|
|
2021-06-07 16:49:13 +02:00
|
|
|
// Collect the module directory for IDE info in java/jdeps.go.
|
|
|
|
modulePaths []string
|
2022-01-12 18:56:19 +01:00
|
|
|
|
|
|
|
// Installs for on-device boot image files. This list has entries only if the installs should be
|
|
|
|
// handled by Make (e.g., the boot image should be installed on the system partition, rather than
|
|
|
|
// in the APEX).
|
|
|
|
bootImageDeviceInstalls []dexpreopterInstall
|
2021-01-20 16:16:56 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 14:32:00 +02:00
|
|
|
// commonBootclasspathFragment defines the methods that are implemented by both source and prebuilt
|
|
|
|
// bootclasspath fragment modules.
|
|
|
|
type commonBootclasspathFragment interface {
|
2021-06-07 14:28:19 +02:00
|
|
|
// produceHiddenAPIOutput produces the all-flags.csv and intermediate files and encodes the flags
|
|
|
|
// into dex files.
|
2021-04-15 14:32:00 +02:00
|
|
|
//
|
2021-06-07 14:28:19 +02:00
|
|
|
// Returns a *HiddenAPIOutput containing the paths for the generated files. Returns nil if the
|
|
|
|
// module cannot contribute to hidden API processing, e.g. because it is a prebuilt module in a
|
|
|
|
// versioned sdk.
|
|
|
|
produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput
|
2021-06-07 11:25:31 +02:00
|
|
|
|
2021-07-01 23:04:22 +02:00
|
|
|
// produceBootImageFiles will attempt to produce rules to create the boot image files at the paths
|
|
|
|
// predefined in the bootImageConfig.
|
2021-06-07 11:25:31 +02:00
|
|
|
//
|
2021-07-01 23:04:22 +02:00
|
|
|
// If it could not create the files then it will return nil. Otherwise, it will return a map from
|
|
|
|
// android.ArchType to the predefined paths of the boot image files.
|
|
|
|
produceBootImageFiles(ctx android.ModuleContext, imageConfig *bootImageConfig) bootImageFilesByArch
|
2021-04-15 14:32:00 +02:00
|
|
|
}
|
|
|
|
|
2021-05-21 17:15:31 +02:00
|
|
|
var _ commonBootclasspathFragment = (*BootclasspathFragmentModule)(nil)
|
|
|
|
|
2021-06-07 11:25:31 +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
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func bootclasspathFragmentFactory() android.Module {
|
|
|
|
m := &BootclasspathFragmentModule{}
|
2021-08-03 16:42:27 +02:00
|
|
|
m.AddProperties(&m.properties, &m.sourceOnlyProperties)
|
2021-01-21 19:13:43 +01:00
|
|
|
android.InitApexModule(m)
|
2021-03-10 16:00:46 +01:00
|
|
|
android.InitSdkAwareModule(m)
|
2021-05-07 00:59:58 +02:00
|
|
|
initClasspathFragment(m, BOOTCLASSPATH)
|
2021-03-17 01:26:25 +01:00
|
|
|
android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon)
|
2021-03-24 00:21:59 +01:00
|
|
|
|
|
|
|
android.AddLoadHook(m, func(ctx android.LoadHookContext) {
|
2021-04-23 14:55:49 +02:00
|
|
|
// If code coverage has been enabled for the framework then append the properties with
|
|
|
|
// coverage specific properties.
|
|
|
|
if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
|
|
|
|
err := proptools.AppendProperties(&m.properties.BootclasspathFragmentCoverageAffectedProperties, &m.properties.Coverage, nil)
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("coverage", "error trying to append coverage specific properties: %s", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the contents property from the image_name.
|
2021-04-23 15:25:28 +02:00
|
|
|
bootclasspathFragmentInitContentsFromImage(ctx, m)
|
2021-03-24 00:21:59 +01:00
|
|
|
})
|
2021-01-20 16:16:56 +01:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
// bootclasspathFragmentInitContentsFromImage will initialize the contents property from the image_name if
|
|
|
|
// necessary.
|
|
|
|
func bootclasspathFragmentInitContentsFromImage(ctx android.EarlyModuleContext, m *BootclasspathFragmentModule) {
|
2021-03-24 02:34:57 +01:00
|
|
|
contents := m.properties.Contents
|
2021-05-21 20:28:09 +02:00
|
|
|
if len(contents) == 0 {
|
|
|
|
ctx.PropertyErrorf("contents", "required property is missing")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if m.properties.Image_name == nil {
|
|
|
|
// Nothing to do.
|
|
|
|
return
|
2021-03-24 02:34:57 +01:00
|
|
|
}
|
2019-11-19 20:44:10 +01:00
|
|
|
|
2021-03-24 00:21:59 +01:00
|
|
|
imageName := proptools.String(m.properties.Image_name)
|
2021-05-21 20:28:09 +02:00
|
|
|
if imageName != "art" {
|
|
|
|
ctx.PropertyErrorf("image_name", `unknown image name %q, expected "art"`, imageName)
|
|
|
|
return
|
|
|
|
}
|
2021-04-22 02:45:29 +02:00
|
|
|
|
2021-05-21 20:28:09 +02:00
|
|
|
// TODO(b/177892522): Prebuilts (versioned or not) should not use the image_name property.
|
|
|
|
if android.IsModuleInVersionedSdk(m) {
|
|
|
|
// The module is a versioned prebuilt so ignore it. This is done for a couple of reasons:
|
|
|
|
// 1. There is no way to use this at the moment so ignoring it is safe.
|
|
|
|
// 2. Attempting to initialize the contents property from the configuration will end up having
|
|
|
|
// the versioned prebuilt depending on the unversioned prebuilt. That will cause problems
|
|
|
|
// as the unversioned prebuilt could end up with an APEX variant created for the source
|
|
|
|
// APEX which will prevent it from having an APEX variant for the prebuilt APEX which in
|
|
|
|
// turn will prevent it from accessing the dex implementation jar from that which will
|
|
|
|
// break hidden API processing, amongst others.
|
|
|
|
return
|
|
|
|
}
|
2021-03-24 00:21:59 +01:00
|
|
|
|
2021-05-21 20:28:09 +02:00
|
|
|
// Get the configuration for the art apex jars. Do not use getImageConfig(ctx) here as this is
|
|
|
|
// too early in the Soong processing for that to work.
|
|
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
|
|
|
modules := global.ArtApexJars
|
|
|
|
|
|
|
|
// Make sure that the apex specified in the configuration is consistent and is one for which
|
|
|
|
// this boot image is available.
|
|
|
|
commonApex := ""
|
|
|
|
for i := 0; i < modules.Len(); i++ {
|
|
|
|
apex := modules.Apex(i)
|
|
|
|
jar := modules.Jar(i)
|
|
|
|
if apex == "platform" {
|
|
|
|
ctx.ModuleErrorf("ArtApexJars is invalid as it requests a platform variant of %q", jar)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if !m.AvailableFor(apex) {
|
|
|
|
ctx.ModuleErrorf("ArtApexJars configuration incompatible with this module, ArtApexJars expects this to be in apex %q but this is only in apexes %q",
|
|
|
|
apex, m.ApexAvailable())
|
|
|
|
continue
|
2021-04-27 13:42:20 +02:00
|
|
|
}
|
2021-05-21 20:28:09 +02:00
|
|
|
if commonApex == "" {
|
|
|
|
commonApex = apex
|
|
|
|
} else if commonApex != apex {
|
|
|
|
ctx.ModuleErrorf("ArtApexJars configuration is inconsistent, expected all jars to be in the same apex but it specifies apex %q and %q",
|
|
|
|
commonApex, apex)
|
|
|
|
}
|
|
|
|
}
|
2019-11-19 20:44:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// bootclasspathImageNameContentsConsistencyCheck checks that the configuration that applies to this
|
|
|
|
// module (if any) matches the contents.
|
|
|
|
//
|
|
|
|
// This should be a noop as if image_name="art" then the contents will be set from the ArtApexJars
|
|
|
|
// config by bootclasspathFragmentInitContentsFromImage so it will be guaranteed to match. However,
|
|
|
|
// in future this will not be the case.
|
|
|
|
func (b *BootclasspathFragmentModule) bootclasspathImageNameContentsConsistencyCheck(ctx android.BaseModuleContext) {
|
|
|
|
imageName := proptools.String(b.properties.Image_name)
|
|
|
|
if imageName == "art" {
|
|
|
|
// TODO(b/177892522): Prebuilts (versioned or not) should not use the image_name property.
|
2021-04-28 01:39:52 +02:00
|
|
|
if android.IsModuleInVersionedSdk(b) {
|
2019-11-19 20:44:10 +01:00
|
|
|
// The module is a versioned prebuilt so ignore it. This is done for a couple of reasons:
|
|
|
|
// 1. There is no way to use this at the moment so ignoring it is safe.
|
|
|
|
// 2. Attempting to initialize the contents property from the configuration will end up having
|
|
|
|
// the versioned prebuilt depending on the unversioned prebuilt. That will cause problems
|
|
|
|
// as the unversioned prebuilt could end up with an APEX variant created for the source
|
|
|
|
// APEX which will prevent it from having an APEX variant for the prebuilt APEX which in
|
|
|
|
// turn will prevent it from accessing the dex implementation jar from that which will
|
|
|
|
// break hidden API processing, amongst others.
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the configuration for the art apex jars.
|
|
|
|
modules := b.getImageConfig(ctx).modules
|
|
|
|
configuredJars := modules.CopyOfJars()
|
|
|
|
|
|
|
|
// Skip the check if the configured jars list is empty as that is a common configuration when
|
|
|
|
// building targets that do not result in a system image.
|
|
|
|
if len(configuredJars) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
contents := b.properties.Contents
|
|
|
|
if !reflect.DeepEqual(configuredJars, contents) {
|
|
|
|
ctx.ModuleErrorf("inconsistency in specification of contents. ArtApexJars configuration specifies %#v, contents property specifies %#v",
|
|
|
|
configuredJars, contents)
|
|
|
|
}
|
2021-03-24 00:21:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 00:04:00 +02:00
|
|
|
var BootclasspathFragmentApexContentInfoProvider = blueprint.NewProvider(BootclasspathFragmentApexContentInfo{})
|
2021-01-20 16:16:56 +01:00
|
|
|
|
2021-04-26 00:04:00 +02:00
|
|
|
// BootclasspathFragmentApexContentInfo contains the bootclasspath_fragments contributions to the
|
|
|
|
// apex contents.
|
|
|
|
type BootclasspathFragmentApexContentInfo struct {
|
2021-05-21 20:27:58 +02:00
|
|
|
// The configured modules, will be empty if this is from a bootclasspath_fragment that does not
|
|
|
|
// set image_name: "art".
|
|
|
|
modules android.ConfiguredJarList
|
|
|
|
|
|
|
|
// Map from arch type to the boot image files.
|
2021-06-07 11:25:31 +02:00
|
|
|
bootImageFilesByArch bootImageFilesByArch
|
2021-05-15 13:39:23 +02:00
|
|
|
|
2022-01-12 18:56:19 +01:00
|
|
|
// True if the boot image should be installed in the APEX.
|
|
|
|
shouldInstallBootImageInApex bool
|
|
|
|
|
2021-06-07 14:28:19 +02:00
|
|
|
// Map from the base module name (without prebuilt_ prefix) of a fragment's contents module to the
|
|
|
|
// hidden API encoded dex jar path.
|
|
|
|
contentModuleDexJarPaths bootDexJarByModule
|
2021-11-26 19:09:27 +01:00
|
|
|
|
|
|
|
// Path to the image profile file on host (or empty, if profile is not generated).
|
|
|
|
profilePathOnHost android.Path
|
|
|
|
|
|
|
|
// Install path of the boot image profile if it needs to be installed in the APEX, or empty if not
|
|
|
|
// needed.
|
|
|
|
profileInstallPathInApex string
|
2021-01-20 16:16:56 +01:00
|
|
|
}
|
|
|
|
|
2021-04-26 00:04:00 +02:00
|
|
|
func (i BootclasspathFragmentApexContentInfo) Modules() android.ConfiguredJarList {
|
2021-05-21 20:27:58 +02:00
|
|
|
return i.modules
|
2021-01-20 16:16:56 +01:00
|
|
|
}
|
|
|
|
|
2021-01-21 19:13:43 +01:00
|
|
|
// Get a map from ArchType to the associated boot image's contents for Android.
|
|
|
|
//
|
|
|
|
// Extension boot images only return their own files, not the files of the boot images they extend.
|
2021-06-07 11:25:31 +02:00
|
|
|
func (i BootclasspathFragmentApexContentInfo) AndroidBootImageFilesByArchType() bootImageFilesByArch {
|
2021-05-21 20:27:58 +02:00
|
|
|
return i.bootImageFilesByArch
|
2021-01-21 19:13:43 +01:00
|
|
|
}
|
|
|
|
|
2022-01-12 18:56:19 +01:00
|
|
|
// Return true if the boot image should be installed in the APEX.
|
|
|
|
func (i *BootclasspathFragmentApexContentInfo) ShouldInstallBootImageInApex() bool {
|
|
|
|
return i.shouldInstallBootImageInApex
|
|
|
|
}
|
|
|
|
|
2021-04-26 11:33:59 +02:00
|
|
|
// DexBootJarPathForContentModule returns the path to the dex boot jar for specified module.
|
|
|
|
//
|
|
|
|
// The dex boot jar is one which has had hidden API encoding performed on it.
|
2021-05-15 13:39:23 +02:00
|
|
|
func (i BootclasspathFragmentApexContentInfo) DexBootJarPathForContentModule(module android.Module) (android.Path, error) {
|
2021-06-07 14:28:19 +02:00
|
|
|
// A bootclasspath_fragment cannot use a prebuilt library so Name() will return the base name
|
|
|
|
// without a prebuilt_ prefix so is safe to use as the key for the contentModuleDexJarPaths.
|
2021-05-15 13:39:23 +02:00
|
|
|
name := module.Name()
|
|
|
|
if dexJar, ok := i.contentModuleDexJarPaths[name]; ok {
|
|
|
|
return dexJar, nil
|
|
|
|
} else {
|
|
|
|
return nil, fmt.Errorf("unknown bootclasspath_fragment content module %s, expected one of %s",
|
|
|
|
name, strings.Join(android.SortedStringKeys(i.contentModuleDexJarPaths), ", "))
|
|
|
|
}
|
2021-04-26 11:33:59 +02:00
|
|
|
}
|
|
|
|
|
2021-11-26 19:09:27 +01:00
|
|
|
func (i BootclasspathFragmentApexContentInfo) ProfilePathOnHost() android.Path {
|
|
|
|
return i.profilePathOnHost
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i BootclasspathFragmentApexContentInfo) ProfileInstallPathInApex() string {
|
|
|
|
return i.profileInstallPathInApex
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *BootclasspathFragmentModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
2021-01-21 19:13:43 +01:00
|
|
|
tag := ctx.OtherModuleDependencyTag(dep)
|
2021-04-20 23:47:03 +02:00
|
|
|
if IsBootclasspathFragmentContentDepTag(tag) {
|
2021-03-24 16:42:20 +01:00
|
|
|
// Boot image contents are automatically added to apex.
|
|
|
|
return true
|
2021-03-24 00:21:59 +01:00
|
|
|
}
|
2021-02-06 04:59:11 +01:00
|
|
|
if android.IsMetaDependencyTag(tag) {
|
|
|
|
// Cross-cutting metadata dependencies are metadata.
|
|
|
|
return false
|
|
|
|
}
|
2021-01-21 19:13:43 +01:00
|
|
|
panic(fmt.Errorf("boot_image module %q should not have a dependency on %q via tag %s", b, dep, android.PrettyPrintTag(tag)))
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *BootclasspathFragmentModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
2021-01-21 19:13:43 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-20 23:47:03 +02:00
|
|
|
// ComponentDepsMutator adds dependencies onto modules before any prebuilt modules without a
|
|
|
|
// corresponding source module are renamed. This means that adding a dependency using a name without
|
|
|
|
// a prebuilt_ prefix will always resolve to a source module and when using a name with that prefix
|
|
|
|
// it will always resolve to a prebuilt module.
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *BootclasspathFragmentModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
2021-04-20 23:47:03 +02:00
|
|
|
module := ctx.Module()
|
2021-04-23 15:25:28 +02:00
|
|
|
_, isSourceModule := module.(*BootclasspathFragmentModule)
|
2021-04-20 23:47:03 +02:00
|
|
|
|
|
|
|
for _, name := range b.properties.Contents {
|
|
|
|
// A bootclasspath_fragment must depend only on other source modules, while the
|
|
|
|
// prebuilt_bootclasspath_fragment must only depend on other prebuilt modules.
|
2021-04-22 18:25:57 +02:00
|
|
|
//
|
|
|
|
// TODO(b/177892522) - avoid special handling of jacocoagent.
|
|
|
|
if !isSourceModule && name != "jacocoagent" {
|
2021-04-20 23:47:03 +02:00
|
|
|
name = android.PrebuiltNameFromSource(name)
|
|
|
|
}
|
|
|
|
ctx.AddDependency(module, bootclasspathFragmentContentDepTag, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *BootclasspathFragmentModule) DepsMutator(ctx android.BottomUpMutatorContext) {
|
2021-04-25 11:13:54 +02:00
|
|
|
// Add dependencies onto all the modules that provide the API stubs for classes on this
|
|
|
|
// bootclasspath fragment.
|
2021-06-18 19:14:25 +02:00
|
|
|
hiddenAPIAddStubLibDependencies(ctx, b.properties.apiScopeToStubLibs())
|
2021-03-24 00:21:59 +01:00
|
|
|
|
2021-05-26 11:16:01 +02:00
|
|
|
for _, additionalStubModule := range b.properties.Additional_stubs {
|
|
|
|
for _, apiScope := range hiddenAPISdkLibrarySupportedScopes {
|
|
|
|
// Add a dependency onto a possibly scope specific stub library.
|
|
|
|
scopeSpecificDependency := apiScope.scopeSpecificStubModule(ctx, additionalStubModule)
|
|
|
|
tag := hiddenAPIStubsDependencyTag{apiScope: apiScope, fromAdditionalDependency: true}
|
|
|
|
ctx.AddVariationDependencies(nil, tag, scopeSpecificDependency)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-21 19:13:43 +01:00
|
|
|
if SkipDexpreoptBootJars(ctx) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2021-05-17 08:38:47 +02:00
|
|
|
func (b *BootclasspathFragmentModule) BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
// Add dependencies on all the fragments.
|
|
|
|
b.properties.BootclasspathFragmentsDepsProperties.addDependenciesOntoFragments(ctx)
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2019-11-19 20:44:10 +01:00
|
|
|
// Only perform a consistency check if this module is the active module. That will prevent an
|
|
|
|
// unused prebuilt that was created without instrumentation from breaking an instrumentation
|
|
|
|
// build.
|
|
|
|
if isActiveModule(ctx.Module()) {
|
|
|
|
b.bootclasspathImageNameContentsConsistencyCheck(ctx)
|
|
|
|
}
|
|
|
|
|
2021-05-07 00:59:58 +02:00
|
|
|
// Generate classpaths.proto config
|
|
|
|
b.generateClasspathProtoBuildActions(ctx)
|
|
|
|
|
2021-06-07 16:49:13 +02:00
|
|
|
// Collect the module directory for IDE info in java/jdeps.go.
|
|
|
|
b.modulePaths = append(b.modulePaths, ctx.ModuleDir())
|
|
|
|
|
2021-04-27 20:36:57 +02:00
|
|
|
// Gather the bootclasspath fragment's contents.
|
|
|
|
var contents []android.Module
|
|
|
|
ctx.VisitDirectDeps(func(module android.Module) {
|
|
|
|
tag := ctx.OtherModuleDependencyTag(module)
|
|
|
|
if IsBootclasspathFragmentContentDepTag(tag) {
|
2021-05-14 17:14:17 +02:00
|
|
|
contents = append(contents, module)
|
2021-04-27 20:36:57 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-05-17 08:38:47 +02:00
|
|
|
fragments := gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag)
|
|
|
|
|
2021-05-15 13:39:23 +02:00
|
|
|
// Verify that the image_name specified on a bootclasspath_fragment is valid even if this is a
|
|
|
|
// prebuilt which will not use the image config.
|
|
|
|
imageConfig := b.getImageConfig(ctx)
|
|
|
|
|
2021-06-07 14:28:19 +02:00
|
|
|
// A versioned prebuilt_bootclasspath_fragment cannot and does not need to perform hidden API
|
|
|
|
// processing. It cannot do it because it is not part of a prebuilt_apex and so has no access to
|
|
|
|
// the correct dex implementation jar. It does not need to because the platform-bootclasspath
|
|
|
|
// always references the latest bootclasspath_fragments.
|
|
|
|
if !android.IsModuleInVersionedSdk(ctx.Module()) {
|
|
|
|
// Perform hidden API processing.
|
|
|
|
hiddenAPIOutput := b.generateHiddenAPIBuildActions(ctx, contents, fragments)
|
|
|
|
|
2021-06-07 11:25:31 +02:00
|
|
|
var bootImageFilesByArch bootImageFilesByArch
|
2021-06-07 15:33:47 +02:00
|
|
|
if imageConfig != nil {
|
2021-06-07 11:25:31 +02:00
|
|
|
// Delegate the production of the boot image files to a module type specific method.
|
|
|
|
common := ctx.Module().(commonBootclasspathFragment)
|
2021-07-01 23:04:22 +02:00
|
|
|
bootImageFilesByArch = common.produceBootImageFiles(ctx, imageConfig)
|
2021-06-07 11:25:31 +02:00
|
|
|
|
2021-06-07 15:33:47 +02:00
|
|
|
if shouldCopyBootFilesToPredefinedLocations(ctx, imageConfig) {
|
2021-07-01 23:04:22 +02:00
|
|
|
// Zip the boot image files up, if available. This will generate the zip file in a
|
|
|
|
// predefined location.
|
|
|
|
buildBootImageZipInPredefinedLocation(ctx, imageConfig, bootImageFilesByArch)
|
|
|
|
|
2021-06-07 15:33:47 +02:00
|
|
|
// Copy the dex jars of this fragment's content modules to their predefined locations.
|
|
|
|
copyBootJarsToPredefinedLocations(ctx, hiddenAPIOutput.EncodedBootDexFilesByModule, imageConfig.dexPathsByModule)
|
|
|
|
}
|
2022-01-12 18:56:19 +01:00
|
|
|
|
|
|
|
for _, variant := range imageConfig.apexVariants() {
|
|
|
|
arch := variant.target.Arch.ArchType.String()
|
|
|
|
for _, install := range variant.deviceInstalls {
|
|
|
|
// Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.
|
|
|
|
installDir := strings.TrimPrefix(filepath.Dir(install.To), "/")
|
|
|
|
installBase := filepath.Base(install.To)
|
|
|
|
installPath := android.PathForModuleInPartitionInstall(ctx, "", installDir)
|
|
|
|
|
|
|
|
b.bootImageDeviceInstalls = append(b.bootImageDeviceInstalls, dexpreopterInstall{
|
|
|
|
name: arch + "-" + installBase,
|
|
|
|
moduleName: b.Name(),
|
|
|
|
outputPathOnHost: install.From,
|
|
|
|
installDirOnDevice: installPath,
|
|
|
|
installFileOnDevice: installBase,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2021-06-07 15:33:47 +02:00
|
|
|
}
|
|
|
|
|
2021-06-07 14:28:19 +02:00
|
|
|
// A prebuilt fragment cannot contribute to an apex.
|
|
|
|
if !android.IsModulePrebuilt(ctx.Module()) {
|
|
|
|
// Provide the apex content info.
|
2021-06-07 11:25:31 +02:00
|
|
|
b.provideApexContentInfo(ctx, imageConfig, hiddenAPIOutput, bootImageFilesByArch)
|
2021-06-07 14:28:19 +02:00
|
|
|
}
|
2021-05-15 13:39:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-07 15:33:47 +02:00
|
|
|
// shouldCopyBootFilesToPredefinedLocations determines whether the current module should copy boot
|
|
|
|
// files, e.g. boot dex jars or boot image files, to the predefined location expected by the rest
|
|
|
|
// of the build.
|
|
|
|
//
|
|
|
|
// This ensures that only a single module will copy its files to the image configuration.
|
|
|
|
func shouldCopyBootFilesToPredefinedLocations(ctx android.ModuleContext, imageConfig *bootImageConfig) bool {
|
|
|
|
// Bootclasspath fragment modules that are for the platform do not produce boot related files.
|
|
|
|
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
|
|
|
if apexInfo.IsForPlatform() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the image configuration has no modules specified then it means that the build has been
|
|
|
|
// configured to build something other than a boot image, e.g. an sdk, so do not try and copy the
|
|
|
|
// files.
|
|
|
|
if imageConfig.modules.Len() == 0 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only copy files from the module that is preferred.
|
|
|
|
return isActiveModule(ctx.Module())
|
|
|
|
}
|
|
|
|
|
2021-05-15 13:39:23 +02:00
|
|
|
// provideApexContentInfo creates, initializes and stores the apex content info for use by other
|
|
|
|
// modules.
|
2021-06-07 11:25:31 +02:00
|
|
|
func (b *BootclasspathFragmentModule) provideApexContentInfo(ctx android.ModuleContext, imageConfig *bootImageConfig, hiddenAPIOutput *HiddenAPIOutput, bootImageFilesByArch bootImageFilesByArch) {
|
2021-05-15 13:39:23 +02:00
|
|
|
// Construct the apex content info from the config.
|
2021-06-07 14:28:19 +02:00
|
|
|
info := BootclasspathFragmentApexContentInfo{
|
|
|
|
// Populate the apex content info with paths to the dex jars.
|
|
|
|
contentModuleDexJarPaths: hiddenAPIOutput.EncodedBootDexFilesByModule,
|
|
|
|
}
|
2021-05-15 13:39:23 +02:00
|
|
|
|
2021-05-21 20:27:58 +02:00
|
|
|
if imageConfig != nil {
|
|
|
|
info.modules = imageConfig.modules
|
2021-12-08 11:48:35 +01:00
|
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
|
|
|
if !global.DisableGenerateProfile {
|
|
|
|
info.profilePathOnHost = imageConfig.profilePathOnHost
|
|
|
|
info.profileInstallPathInApex = imageConfig.profileInstallPathInApex
|
|
|
|
}
|
2022-01-12 18:56:19 +01:00
|
|
|
|
|
|
|
info.shouldInstallBootImageInApex = imageConfig.shouldInstallInApex()
|
2021-05-15 13:39:23 +02:00
|
|
|
}
|
|
|
|
|
2021-06-07 11:25:31 +02:00
|
|
|
info.bootImageFilesByArch = bootImageFilesByArch
|
|
|
|
|
2021-05-15 13:39:23 +02:00
|
|
|
// Make the apex content info available for other modules.
|
|
|
|
ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, info)
|
|
|
|
}
|
2021-01-20 16:16:56 +01:00
|
|
|
|
2021-05-07 00:59:58 +02:00
|
|
|
// generateClasspathProtoBuildActions generates all required build actions for classpath.proto config
|
|
|
|
func (b *BootclasspathFragmentModule) generateClasspathProtoBuildActions(ctx android.ModuleContext) {
|
|
|
|
var classpathJars []classpathJar
|
2021-06-15 18:49:10 +02:00
|
|
|
configuredJars := b.configuredJars(ctx)
|
2021-05-07 00:59:58 +02:00
|
|
|
if "art" == proptools.String(b.properties.Image_name) {
|
|
|
|
// ART and platform boot jars must have a corresponding entry in DEX2OATBOOTCLASSPATH
|
2021-06-15 18:49:10 +02:00
|
|
|
classpathJars = configuredJarListToClasspathJars(ctx, configuredJars, BOOTCLASSPATH, DEX2OATBOOTCLASSPATH)
|
2021-05-07 00:59:58 +02:00
|
|
|
} else {
|
2021-06-15 18:49:10 +02:00
|
|
|
classpathJars = configuredJarListToClasspathJars(ctx, configuredJars, b.classpathType)
|
2021-05-07 00:59:58 +02:00
|
|
|
}
|
2021-06-15 18:49:10 +02:00
|
|
|
b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars)
|
2021-05-07 00:59:58 +02:00
|
|
|
}
|
|
|
|
|
2021-06-15 17:21:17 +02:00
|
|
|
func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList {
|
2021-05-07 01:10:33 +02:00
|
|
|
if "art" == proptools.String(b.properties.Image_name) {
|
|
|
|
return b.getImageConfig(ctx).modules
|
|
|
|
}
|
|
|
|
|
|
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
|
|
|
|
2021-07-21 15:23:52 +02:00
|
|
|
possibleUpdatableModules := gatherPossibleApexModuleNamesAndStems(ctx, b.properties.Contents, bootclasspathFragmentContentDepTag)
|
2021-08-06 14:20:28 +02:00
|
|
|
jars, unknown := global.ApexBootJars.Filter(possibleUpdatableModules)
|
2021-06-04 19:09:40 +02:00
|
|
|
|
|
|
|
// TODO(satayev): for apex_test we want to include all contents unconditionally to classpaths
|
2021-07-21 15:23:52 +02:00
|
|
|
// config. However, any test specific jars would not be present in ApexBootJars. Instead,
|
2021-06-04 19:09:40 +02:00
|
|
|
// we should check if we are creating a config for apex_test via ApexInfo and amend the values.
|
|
|
|
// This is an exception to support end-to-end test for SdkExtensions, until such support exists.
|
2021-06-29 21:04:45 +02:00
|
|
|
if android.InList("test_framework-sdkextensions", possibleUpdatableModules) {
|
2021-06-04 19:09:40 +02:00
|
|
|
jars = jars.Append("com.android.sdkext", "test_framework-sdkextensions")
|
2021-10-11 23:47:13 +02:00
|
|
|
} else if android.InList("test_framework-apexd", possibleUpdatableModules) {
|
|
|
|
jars = jars.Append("com.android.apex.test_package", "test_framework-apexd")
|
2021-08-06 14:20:28 +02:00
|
|
|
} else if global.ApexBootJars.Len() != 0 && !android.IsModuleInVersionedSdk(ctx.Module()) {
|
|
|
|
unknown = android.RemoveListFromList(unknown, b.properties.Coverage.Contents)
|
|
|
|
_, unknown = android.RemoveFromList("core-icu4j", unknown)
|
|
|
|
if len(unknown) > 0 {
|
|
|
|
ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_BOOT_JARS", unknown)
|
|
|
|
}
|
2021-06-04 19:09:40 +02:00
|
|
|
}
|
|
|
|
return jars
|
2021-05-07 00:59:58 +02:00
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *BootclasspathFragmentModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig {
|
2021-03-24 00:06:38 +01:00
|
|
|
// Get a map of the image configs that are supported.
|
|
|
|
imageConfigs := genBootImageConfigs(ctx)
|
|
|
|
|
|
|
|
// Retrieve the config for this image.
|
|
|
|
imageNamePtr := b.properties.Image_name
|
|
|
|
if imageNamePtr == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
imageName := *imageNamePtr
|
|
|
|
imageConfig := imageConfigs[imageName]
|
|
|
|
if imageConfig == nil {
|
|
|
|
ctx.PropertyErrorf("image_name", "Unknown image name %q, expected one of %s", imageName, strings.Join(android.SortedStringKeys(imageConfigs), ", "))
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return imageConfig
|
|
|
|
}
|
|
|
|
|
2021-04-09 00:01:37 +02:00
|
|
|
// generateHiddenAPIBuildActions generates all the hidden API related build rules.
|
2021-06-07 14:28:19 +02:00
|
|
|
func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, contents []android.Module, fragments []android.Module) *HiddenAPIOutput {
|
2021-04-25 11:13:54 +02:00
|
|
|
|
2021-05-21 23:18:49 +02:00
|
|
|
// Create hidden API input structure.
|
2021-05-17 08:38:47 +02:00
|
|
|
input := b.createHiddenAPIFlagInput(ctx, contents, fragments)
|
2021-04-25 11:13:54 +02:00
|
|
|
|
2021-06-29 12:59:23 +02:00
|
|
|
// Delegate the production of the hidden API all-flags.csv file to a module type specific method.
|
|
|
|
common := ctx.Module().(commonBootclasspathFragment)
|
|
|
|
output := common.produceHiddenAPIOutput(ctx, contents, input)
|
2021-05-21 17:15:31 +02:00
|
|
|
|
2021-07-21 18:38:47 +02:00
|
|
|
// If the source or prebuilts module does not provide a signature patterns file then generate one
|
|
|
|
// from the flags.
|
|
|
|
// TODO(b/192868581): Remove once the source and prebuilts provide a signature patterns file of
|
|
|
|
// their own.
|
|
|
|
if output.SignaturePatternsPath == nil {
|
2021-08-03 16:42:27 +02:00
|
|
|
output.SignaturePatternsPath = buildRuleSignaturePatternsFile(ctx, output.AllFlagsPath, []string{"*"}, nil)
|
2021-07-21 18:38:47 +02:00
|
|
|
}
|
|
|
|
|
2021-05-23 17:55:37 +02:00
|
|
|
// Initialize a HiddenAPIInfo structure.
|
2021-05-21 23:18:56 +02:00
|
|
|
hiddenAPIInfo := HiddenAPIInfo{
|
2021-05-23 17:55:37 +02:00
|
|
|
// The monolithic hidden API processing needs access to the flag files that override the default
|
|
|
|
// flags from all the fragments whether or not they actually perform their own hidden API flag
|
|
|
|
// generation. That is because the monolithic hidden API processing uses those flag files to
|
|
|
|
// perform its own flag generation.
|
2021-05-21 23:18:49 +02:00
|
|
|
FlagFilesByCategory: input.FlagFilesByCategory,
|
2021-05-21 23:46:59 +02:00
|
|
|
|
2021-05-17 08:38:47 +02:00
|
|
|
// Other bootclasspath_fragments that depend on this need the transitive set of stub dex jars
|
|
|
|
// from this to resolve any references from their code to classes provided by this fragment
|
|
|
|
// and the fragments this depends upon.
|
2021-06-18 19:14:25 +02:00
|
|
|
TransitiveStubDexJarsByScope: input.transitiveStubDexJarsByScope(),
|
2021-05-23 17:55:37 +02:00
|
|
|
}
|
2021-04-15 14:32:00 +02:00
|
|
|
|
2021-06-07 14:28:19 +02:00
|
|
|
// The monolithic hidden API processing also needs access to all the output files produced by
|
|
|
|
// hidden API processing of this fragment.
|
2021-07-19 14:23:40 +02:00
|
|
|
hiddenAPIInfo.HiddenAPIFlagOutput = output.HiddenAPIFlagOutput
|
2021-05-23 17:55:37 +02:00
|
|
|
|
|
|
|
// Provide it for use by other modules.
|
2021-05-21 23:18:56 +02:00
|
|
|
ctx.SetProvider(HiddenAPIInfoProvider, hiddenAPIInfo)
|
2021-05-15 09:54:30 +02:00
|
|
|
|
2021-05-21 17:15:31 +02:00
|
|
|
return output
|
2021-04-15 14:32:00 +02:00
|
|
|
}
|
|
|
|
|
2021-06-07 14:28:19 +02:00
|
|
|
// retrieveLegacyEncodedBootDexFiles attempts to retrieve the legacy encoded boot dex jar files.
|
|
|
|
func retrieveLegacyEncodedBootDexFiles(ctx android.ModuleContext, contents []android.Module) bootDexJarByModule {
|
|
|
|
// If the current bootclasspath_fragment is the active module or a source module then retrieve the
|
|
|
|
// encoded dex files, otherwise return an empty map.
|
|
|
|
//
|
|
|
|
// An inactive (i.e. not preferred) bootclasspath_fragment needs to retrieve the encoded dex jars
|
|
|
|
// as they are still needed by an apex. An inactive prebuilt_bootclasspath_fragment does not need
|
|
|
|
// to do so and may not yet have access to dex boot jars from a prebuilt_apex/apex_set.
|
|
|
|
if isActiveModule(ctx.Module()) || !android.IsModulePrebuilt(ctx.Module()) {
|
|
|
|
return extractEncodedDexJarsFromModules(ctx, contents)
|
|
|
|
} else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-21 23:18:49 +02:00
|
|
|
// createHiddenAPIFlagInput creates a HiddenAPIFlagInput struct and initializes it with information derived
|
|
|
|
// from the properties on this module and its dependencies.
|
2021-05-17 08:38:47 +02:00
|
|
|
func (b *BootclasspathFragmentModule) createHiddenAPIFlagInput(ctx android.ModuleContext, contents []android.Module, fragments []android.Module) HiddenAPIFlagInput {
|
|
|
|
// Merge the HiddenAPIInfo from all the fragment dependencies.
|
|
|
|
dependencyHiddenApiInfo := newHiddenAPIInfo()
|
|
|
|
dependencyHiddenApiInfo.mergeFromFragmentDeps(ctx, fragments)
|
|
|
|
|
|
|
|
// Create hidden API flag input structure.
|
2021-05-21 23:18:49 +02:00
|
|
|
input := newHiddenAPIFlagInput()
|
|
|
|
|
|
|
|
// Update the input structure with information obtained from the stub libraries.
|
|
|
|
input.gatherStubLibInfo(ctx, contents)
|
|
|
|
|
|
|
|
// Populate with flag file paths from the properties.
|
|
|
|
input.extractFlagFilesFromProperties(ctx, &b.properties.Hidden_api)
|
|
|
|
|
2021-05-26 11:16:01 +02:00
|
|
|
// Add the stub dex jars from this module's fragment dependencies.
|
2021-06-27 21:28:29 +02:00
|
|
|
input.DependencyStubDexJarsByScope.addStubDexJarsByModule(dependencyHiddenApiInfo.TransitiveStubDexJarsByScope)
|
2021-05-17 08:38:47 +02:00
|
|
|
|
2021-05-21 23:18:49 +02:00
|
|
|
return input
|
|
|
|
}
|
|
|
|
|
2021-06-07 14:28:19 +02:00
|
|
|
// produceHiddenAPIOutput produces the hidden API all-flags.csv file (and supporting files)
|
|
|
|
// for the fragment as well as encoding the flags in the boot dex jars.
|
|
|
|
func (b *BootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput {
|
2021-05-21 23:18:49 +02:00
|
|
|
// Generate the rules to create the hidden API flags and update the supplied hiddenAPIInfo with the
|
2021-04-15 14:32:00 +02:00
|
|
|
// paths to the created files.
|
2021-08-03 16:42:27 +02:00
|
|
|
output := hiddenAPIRulesForBootclasspathFragment(ctx, contents, input)
|
|
|
|
|
|
|
|
// If the module specifies split_packages or package_prefixes then use those to generate the
|
|
|
|
// signature patterns.
|
|
|
|
splitPackages := b.sourceOnlyProperties.Hidden_api.Split_packages
|
|
|
|
packagePrefixes := b.sourceOnlyProperties.Hidden_api.Package_prefixes
|
|
|
|
if splitPackages != nil || packagePrefixes != nil {
|
|
|
|
if splitPackages == nil {
|
|
|
|
splitPackages = []string{"*"}
|
|
|
|
}
|
|
|
|
output.SignaturePatternsPath = buildRuleSignaturePatternsFile(ctx, output.AllFlagsPath, splitPackages, packagePrefixes)
|
|
|
|
}
|
|
|
|
|
|
|
|
return output
|
2021-04-09 00:01:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-07 11:25:31 +02:00
|
|
|
// produceBootImageFiles builds the boot image files from the source if it is required.
|
2021-07-01 23:04:22 +02:00
|
|
|
func (b *BootclasspathFragmentModule) produceBootImageFiles(ctx android.ModuleContext, imageConfig *bootImageConfig) bootImageFilesByArch {
|
2021-06-07 11:25:31 +02:00
|
|
|
if SkipDexpreoptBootJars(ctx) {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only generate the boot image if the configuration does not skip it.
|
2021-07-01 23:04:22 +02:00
|
|
|
return b.generateBootImageBuildActions(ctx, imageConfig)
|
2021-06-07 11:25:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-27 20:36:57 +02:00
|
|
|
// generateBootImageBuildActions generates ninja rules to create the boot image if required for this
|
|
|
|
// module.
|
2021-05-21 20:27:58 +02:00
|
|
|
//
|
2021-07-01 23:04:22 +02:00
|
|
|
// If it could not create the files then it will return nil. Otherwise, it will return a map from
|
|
|
|
// android.ArchType to the predefined paths of the boot image files.
|
|
|
|
func (b *BootclasspathFragmentModule) generateBootImageBuildActions(ctx android.ModuleContext, imageConfig *bootImageConfig) bootImageFilesByArch {
|
2021-04-27 20:36:57 +02:00
|
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
|
|
|
if !shouldBuildBootImages(ctx.Config(), global) {
|
2021-07-01 23:04:22 +02:00
|
|
|
return nil
|
2021-04-27 20:36:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bootclasspath fragment modules that are for the platform do not produce a boot image.
|
|
|
|
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
|
|
|
if apexInfo.IsForPlatform() {
|
2021-07-01 23:04:22 +02:00
|
|
|
return nil
|
2021-04-27 20:36:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bootclasspath fragment modules that are versioned do not produce a boot image.
|
|
|
|
if android.IsModuleInVersionedSdk(ctx.Module()) {
|
2021-07-01 23:04:22 +02:00
|
|
|
return nil
|
2021-04-27 20:36:57 +02:00
|
|
|
}
|
|
|
|
|
2021-04-30 00:36:12 +02:00
|
|
|
// Build a profile for the image config and then use that to build the boot image.
|
|
|
|
profile := bootImageProfileRule(ctx, imageConfig)
|
2021-07-02 14:00:43 +02:00
|
|
|
|
|
|
|
// Build boot image files for the host variants.
|
|
|
|
buildBootImageVariantsForBuildOs(ctx, imageConfig, profile)
|
|
|
|
|
|
|
|
// Build boot image files for the android variants.
|
|
|
|
androidBootImageFilesByArch := buildBootImageVariantsForAndroidOs(ctx, imageConfig, profile)
|
|
|
|
|
|
|
|
// Return the boot image files for the android variants for inclusion in an APEX and to be zipped
|
|
|
|
// up for the dist.
|
|
|
|
return androidBootImageFilesByArch
|
2021-04-27 20:36:57 +02:00
|
|
|
}
|
|
|
|
|
2022-01-12 18:56:19 +01:00
|
|
|
func (b *BootclasspathFragmentModule) AndroidMkEntries() []android.AndroidMkEntries {
|
|
|
|
var entriesList []android.AndroidMkEntries
|
|
|
|
for _, install := range b.bootImageDeviceInstalls {
|
|
|
|
entriesList = append(entriesList, install.ToMakeEntries())
|
|
|
|
}
|
|
|
|
return entriesList
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the names of all Make modules that handle the installation of the boot image.
|
|
|
|
func (b *BootclasspathFragmentModule) BootImageDeviceInstallMakeModules() []string {
|
|
|
|
var makeModules []string
|
|
|
|
for _, install := range b.bootImageDeviceInstalls {
|
|
|
|
makeModules = append(makeModules, install.FullModuleName())
|
|
|
|
}
|
|
|
|
return makeModules
|
|
|
|
}
|
|
|
|
|
2021-06-07 16:49:13 +02:00
|
|
|
// Collect information for opening IDE project files in java/jdeps.go.
|
|
|
|
func (b *BootclasspathFragmentModule) IDEInfo(dpInfo *android.IdeInfo) {
|
|
|
|
dpInfo.Deps = append(dpInfo.Deps, b.properties.Contents...)
|
|
|
|
dpInfo.Paths = append(dpInfo.Paths, b.modulePaths...)
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
type bootclasspathFragmentMemberType struct {
|
2021-03-10 16:00:46 +01:00
|
|
|
android.SdkMemberTypeBase
|
|
|
|
}
|
|
|
|
|
2021-07-14 11:29:36 +02:00
|
|
|
func (b *bootclasspathFragmentMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
|
|
|
ctx.AddVariationDependencies(nil, dependencyTag, names...)
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *bootclasspathFragmentMemberType) IsInstance(module android.Module) bool {
|
|
|
|
_, ok := module.(*BootclasspathFragmentModule)
|
2021-03-10 16:00:46 +01:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *bootclasspathFragmentMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule {
|
2021-03-29 12:02:53 +02:00
|
|
|
if b.PropertyName == "boot_images" {
|
|
|
|
return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_boot_image")
|
|
|
|
} else {
|
|
|
|
return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_bootclasspath_fragment")
|
|
|
|
}
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *bootclasspathFragmentMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {
|
|
|
|
return &bootclasspathFragmentSdkMemberProperties{}
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
type bootclasspathFragmentSdkMemberProperties struct {
|
2021-03-10 16:00:46 +01:00
|
|
|
android.SdkMemberPropertiesBase
|
|
|
|
|
2021-04-19 14:23:06 +02:00
|
|
|
// The image name
|
2021-03-24 00:06:38 +01:00
|
|
|
Image_name *string
|
2021-04-19 14:23:06 +02:00
|
|
|
|
|
|
|
// Contents of the bootclasspath fragment
|
|
|
|
Contents []string
|
2021-04-19 14:23:53 +02:00
|
|
|
|
2021-04-25 14:40:15 +02:00
|
|
|
// Stub_libs properties.
|
|
|
|
Stub_libs []string
|
|
|
|
Core_platform_stub_libs []string
|
|
|
|
|
2021-05-18 13:54:27 +02:00
|
|
|
// Fragment properties
|
|
|
|
Fragments []ApexVariantReference
|
|
|
|
|
2021-04-19 14:23:53 +02:00
|
|
|
// Flag files by *hiddenAPIFlagFileCategory
|
2021-05-21 17:58:23 +02:00
|
|
|
Flag_files_by_category FlagFilesByCategory
|
2021-04-15 14:32:00 +02:00
|
|
|
|
|
|
|
// The path to the generated annotation-flags.csv file.
|
|
|
|
Annotation_flags_path android.OptionalPath
|
|
|
|
|
|
|
|
// The path to the generated metadata.csv file.
|
|
|
|
Metadata_path android.OptionalPath
|
|
|
|
|
|
|
|
// The path to the generated index.csv file.
|
|
|
|
Index_path android.OptionalPath
|
|
|
|
|
2021-10-04 07:28:58 +02:00
|
|
|
// The path to the generated stub-flags.csv file.
|
2021-08-10 17:14:16 +02:00
|
|
|
Stub_flags_path android.OptionalPath `supported_build_releases:"S"`
|
2021-08-10 17:14:16 +02:00
|
|
|
|
2021-10-04 07:28:58 +02:00
|
|
|
// The path to the generated all-flags.csv file.
|
2021-08-10 17:14:16 +02:00
|
|
|
All_flags_path android.OptionalPath `supported_build_releases:"S"`
|
|
|
|
|
|
|
|
// The path to the generated signature-patterns.csv file.
|
|
|
|
Signature_patterns_path android.OptionalPath `supported_build_releases:"T+"`
|
|
|
|
|
|
|
|
// The path to the generated filtered-stub-flags.csv file.
|
|
|
|
Filtered_stub_flags_path android.OptionalPath `supported_build_releases:"T+"`
|
|
|
|
|
|
|
|
// The path to the generated filtered-flags.csv file.
|
|
|
|
Filtered_flags_path android.OptionalPath `supported_build_releases:"T+"`
|
2021-04-15 14:32:00 +02:00
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *bootclasspathFragmentSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
|
|
|
|
module := variant.(*BootclasspathFragmentModule)
|
2021-03-10 16:00:46 +01:00
|
|
|
|
|
|
|
b.Image_name = module.properties.Image_name
|
2021-04-23 17:58:51 +02:00
|
|
|
b.Contents = module.properties.Contents
|
2021-04-19 14:23:53 +02:00
|
|
|
|
2021-05-21 23:18:56 +02:00
|
|
|
// Get the hidden API information from the module.
|
2021-04-19 14:23:53 +02:00
|
|
|
mctx := ctx.SdkModuleContext()
|
2021-05-21 23:18:56 +02:00
|
|
|
hiddenAPIInfo := mctx.OtherModuleProvider(module, HiddenAPIInfoProvider).(HiddenAPIInfo)
|
|
|
|
b.Flag_files_by_category = hiddenAPIInfo.FlagFilesByCategory
|
2021-04-25 14:40:15 +02:00
|
|
|
|
2021-04-15 14:32:00 +02:00
|
|
|
// Copy all the generated file paths.
|
2021-05-21 23:18:56 +02:00
|
|
|
b.Annotation_flags_path = android.OptionalPathForPath(hiddenAPIInfo.AnnotationFlagsPath)
|
|
|
|
b.Metadata_path = android.OptionalPathForPath(hiddenAPIInfo.MetadataPath)
|
|
|
|
b.Index_path = android.OptionalPathForPath(hiddenAPIInfo.IndexPath)
|
2021-07-21 18:38:47 +02:00
|
|
|
|
|
|
|
b.Stub_flags_path = android.OptionalPathForPath(hiddenAPIInfo.StubFlagsPath)
|
2021-05-21 23:18:56 +02:00
|
|
|
b.All_flags_path = android.OptionalPathForPath(hiddenAPIInfo.AllFlagsPath)
|
2021-04-15 14:32:00 +02:00
|
|
|
|
2021-08-10 17:14:16 +02:00
|
|
|
b.Signature_patterns_path = android.OptionalPathForPath(hiddenAPIInfo.SignaturePatternsPath)
|
|
|
|
b.Filtered_stub_flags_path = android.OptionalPathForPath(hiddenAPIInfo.FilteredStubFlagsPath)
|
|
|
|
b.Filtered_flags_path = android.OptionalPathForPath(hiddenAPIInfo.FilteredFlagsPath)
|
|
|
|
|
2021-04-25 14:40:15 +02:00
|
|
|
// Copy stub_libs properties.
|
|
|
|
b.Stub_libs = module.properties.Api.Stub_libs
|
|
|
|
b.Core_platform_stub_libs = module.properties.Core_platform_api.Stub_libs
|
2021-05-18 13:54:27 +02:00
|
|
|
|
|
|
|
// Copy fragment properties.
|
|
|
|
b.Fragments = module.properties.Fragments
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (b *bootclasspathFragmentSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
|
2021-03-24 00:06:38 +01:00
|
|
|
if b.Image_name != nil {
|
|
|
|
propertySet.AddProperty("image_name", *b.Image_name)
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
2021-04-19 14:23:06 +02:00
|
|
|
|
2021-04-25 14:40:15 +02:00
|
|
|
builder := ctx.SnapshotBuilder()
|
|
|
|
requiredMemberDependency := builder.SdkMemberReferencePropertyTag(true)
|
|
|
|
|
2021-04-19 14:23:06 +02:00
|
|
|
if len(b.Contents) > 0 {
|
2021-04-25 14:40:15 +02:00
|
|
|
propertySet.AddPropertyWithTag("contents", b.Contents, requiredMemberDependency)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(b.Stub_libs) > 0 {
|
|
|
|
apiPropertySet := propertySet.AddPropertySet("api")
|
|
|
|
apiPropertySet.AddPropertyWithTag("stub_libs", b.Stub_libs, requiredMemberDependency)
|
|
|
|
}
|
|
|
|
if len(b.Core_platform_stub_libs) > 0 {
|
|
|
|
corePlatformApiPropertySet := propertySet.AddPropertySet("core_platform_api")
|
|
|
|
corePlatformApiPropertySet.AddPropertyWithTag("stub_libs", b.Core_platform_stub_libs, requiredMemberDependency)
|
2021-04-19 14:23:06 +02:00
|
|
|
}
|
2021-05-18 13:54:27 +02:00
|
|
|
if len(b.Fragments) > 0 {
|
|
|
|
propertySet.AddProperty("fragments", b.Fragments)
|
|
|
|
}
|
2021-04-19 14:23:53 +02:00
|
|
|
|
2021-04-15 14:32:00 +02:00
|
|
|
hiddenAPISet := propertySet.AddPropertySet("hidden_api")
|
|
|
|
hiddenAPIDir := "hiddenapi"
|
|
|
|
|
|
|
|
// Copy manually curated flag files specified on the bootclasspath_fragment.
|
2021-04-19 14:23:53 +02:00
|
|
|
if b.Flag_files_by_category != nil {
|
2021-06-09 15:39:28 +02:00
|
|
|
for _, category := range HiddenAPIFlagFileCategories {
|
2021-04-19 14:23:53 +02:00
|
|
|
paths := b.Flag_files_by_category[category]
|
|
|
|
if len(paths) > 0 {
|
|
|
|
dests := []string{}
|
|
|
|
for _, p := range paths {
|
2021-04-15 14:32:00 +02:00
|
|
|
dest := filepath.Join(hiddenAPIDir, p.Base())
|
2021-04-19 14:23:53 +02:00
|
|
|
builder.CopyToSnapshot(p, dest)
|
|
|
|
dests = append(dests, dest)
|
|
|
|
}
|
2021-06-09 15:39:28 +02:00
|
|
|
hiddenAPISet.AddProperty(category.PropertyName, dests)
|
2021-04-19 14:23:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-15 14:32:00 +02:00
|
|
|
|
|
|
|
copyOptionalPath := func(path android.OptionalPath, property string) {
|
|
|
|
if path.Valid() {
|
|
|
|
p := path.Path()
|
|
|
|
dest := filepath.Join(hiddenAPIDir, p.Base())
|
|
|
|
builder.CopyToSnapshot(p, dest)
|
|
|
|
hiddenAPISet.AddProperty(property, dest)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy all the generated files, if available.
|
|
|
|
copyOptionalPath(b.Annotation_flags_path, "annotation_flags")
|
|
|
|
copyOptionalPath(b.Metadata_path, "metadata")
|
|
|
|
copyOptionalPath(b.Index_path, "index")
|
2021-08-10 17:14:16 +02:00
|
|
|
|
2021-07-21 18:38:47 +02:00
|
|
|
copyOptionalPath(b.Stub_flags_path, "stub_flags")
|
2021-04-15 14:32:00 +02:00
|
|
|
copyOptionalPath(b.All_flags_path, "all_flags")
|
2021-08-10 17:14:16 +02:00
|
|
|
|
|
|
|
copyOptionalPath(b.Signature_patterns_path, "signature_patterns")
|
|
|
|
copyOptionalPath(b.Filtered_stub_flags_path, "filtered_stub_flags")
|
|
|
|
copyOptionalPath(b.Filtered_flags_path, "filtered_flags")
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
var _ android.SdkMemberType = (*bootclasspathFragmentMemberType)(nil)
|
2021-03-10 16:00:46 +01:00
|
|
|
|
2021-04-15 14:32:00 +02:00
|
|
|
// prebuiltBootclasspathFragmentProperties contains additional prebuilt_bootclasspath_fragment
|
|
|
|
// specific properties.
|
|
|
|
type prebuiltBootclasspathFragmentProperties struct {
|
|
|
|
Hidden_api struct {
|
|
|
|
// The path to the annotation-flags.csv file created by the bootclasspath_fragment.
|
|
|
|
Annotation_flags *string `android:"path"`
|
|
|
|
|
|
|
|
// The path to the metadata.csv file created by the bootclasspath_fragment.
|
|
|
|
Metadata *string `android:"path"`
|
|
|
|
|
|
|
|
// The path to the index.csv file created by the bootclasspath_fragment.
|
|
|
|
Index *string `android:"path"`
|
|
|
|
|
2021-07-22 13:00:49 +02:00
|
|
|
// The path to the signature-patterns.csv file created by the bootclasspath_fragment.
|
|
|
|
Signature_patterns *string `android:"path"`
|
|
|
|
|
2021-07-21 18:38:47 +02:00
|
|
|
// The path to the stub-flags.csv file created by the bootclasspath_fragment.
|
|
|
|
Stub_flags *string `android:"path"`
|
|
|
|
|
2021-04-15 14:32:00 +02:00
|
|
|
// The path to the all-flags.csv file created by the bootclasspath_fragment.
|
|
|
|
All_flags *string `android:"path"`
|
2021-08-10 17:14:16 +02:00
|
|
|
|
|
|
|
// The path to the filtered-stub-flags.csv file created by the bootclasspath_fragment.
|
|
|
|
Filtered_stub_flags *string `android:"path"`
|
|
|
|
|
|
|
|
// The path to the filtered-flags.csv file created by the bootclasspath_fragment.
|
|
|
|
Filtered_flags *string `android:"path"`
|
2021-04-15 14:32:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
// A prebuilt version of the bootclasspath_fragment module.
|
2021-03-10 16:00:46 +01:00
|
|
|
//
|
2021-04-23 15:25:28 +02:00
|
|
|
// At the moment this is basically just a bootclasspath_fragment module that can be used as a
|
|
|
|
// prebuilt. Eventually as more functionality is migrated into the bootclasspath_fragment module
|
|
|
|
// type from the various singletons then this will diverge.
|
|
|
|
type prebuiltBootclasspathFragmentModule struct {
|
|
|
|
BootclasspathFragmentModule
|
2021-03-10 16:00:46 +01:00
|
|
|
prebuilt android.Prebuilt
|
2021-04-15 14:32:00 +02:00
|
|
|
|
|
|
|
// Additional prebuilt specific properties.
|
|
|
|
prebuiltProperties prebuiltBootclasspathFragmentProperties
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (module *prebuiltBootclasspathFragmentModule) Prebuilt() *android.Prebuilt {
|
2021-03-10 16:00:46 +01:00
|
|
|
return &module.prebuilt
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func (module *prebuiltBootclasspathFragmentModule) Name() string {
|
2021-03-10 16:00:46 +01:00
|
|
|
return module.prebuilt.Name(module.ModuleBase.Name())
|
|
|
|
}
|
|
|
|
|
2021-06-07 14:28:19 +02:00
|
|
|
// produceHiddenAPIOutput returns a path to the prebuilt all-flags.csv or nil if none is specified.
|
|
|
|
func (module *prebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput {
|
2021-08-10 17:14:16 +02:00
|
|
|
pathForOptionalSrc := func(src *string, defaultPath android.Path) android.Path {
|
2021-07-22 13:00:49 +02:00
|
|
|
if src == nil {
|
2021-08-10 17:14:16 +02:00
|
|
|
return defaultPath
|
2021-07-22 13:00:49 +02:00
|
|
|
}
|
|
|
|
return android.PathForModuleSrc(ctx, *src)
|
|
|
|
}
|
2021-07-19 14:23:40 +02:00
|
|
|
pathForSrc := func(property string, src *string) android.Path {
|
2021-04-15 14:32:00 +02:00
|
|
|
if src == nil {
|
2021-07-19 14:23:40 +02:00
|
|
|
ctx.PropertyErrorf(property, "is required but was not specified")
|
|
|
|
return android.PathForModuleSrc(ctx, "missing", property)
|
2021-04-15 14:32:00 +02:00
|
|
|
}
|
2021-05-21 17:15:31 +02:00
|
|
|
return android.PathForModuleSrc(ctx, *src)
|
|
|
|
}
|
|
|
|
|
2021-06-07 14:28:19 +02:00
|
|
|
// Retrieve the dex files directly from the content modules. They in turn should retrieve the
|
|
|
|
// encoded dex jars from the prebuilt .apex files.
|
|
|
|
encodedBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, contents)
|
|
|
|
|
|
|
|
output := HiddenAPIOutput{
|
|
|
|
HiddenAPIFlagOutput: HiddenAPIFlagOutput{
|
2021-07-22 13:00:49 +02:00
|
|
|
AnnotationFlagsPath: pathForSrc("hidden_api.annotation_flags", module.prebuiltProperties.Hidden_api.Annotation_flags),
|
|
|
|
MetadataPath: pathForSrc("hidden_api.metadata", module.prebuiltProperties.Hidden_api.Metadata),
|
|
|
|
IndexPath: pathForSrc("hidden_api.index", module.prebuiltProperties.Hidden_api.Index),
|
2021-08-10 17:14:16 +02:00
|
|
|
SignaturePatternsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Signature_patterns, nil),
|
|
|
|
// TODO: Temporarily handle stub_flags/all_flags properties until prebuilts have been updated.
|
|
|
|
StubFlagsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Stub_flags, nil),
|
|
|
|
AllFlagsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.All_flags, nil),
|
2021-06-07 14:28:19 +02:00
|
|
|
},
|
2021-08-10 17:14:16 +02:00
|
|
|
|
2021-06-07 14:28:19 +02:00
|
|
|
EncodedBootDexFilesByModule: encodedBootDexJarsByModule,
|
2021-04-15 14:32:00 +02:00
|
|
|
}
|
|
|
|
|
2021-08-10 17:14:16 +02:00
|
|
|
// TODO: Temporarily fallback to stub_flags/all_flags properties until prebuilts have been updated.
|
|
|
|
output.FilteredStubFlagsPath = pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Filtered_stub_flags, output.StubFlagsPath)
|
|
|
|
output.FilteredFlagsPath = pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Filtered_flags, output.AllFlagsPath)
|
|
|
|
|
2021-05-21 17:15:31 +02:00
|
|
|
return &output
|
2021-04-15 14:32:00 +02:00
|
|
|
}
|
|
|
|
|
2021-06-07 11:25:31 +02:00
|
|
|
// produceBootImageFiles extracts the boot image files from the APEX if available.
|
2021-07-01 23:04:22 +02:00
|
|
|
func (module *prebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx android.ModuleContext, imageConfig *bootImageConfig) bootImageFilesByArch {
|
2021-06-07 11:25:31 +02:00
|
|
|
if !shouldCopyBootFilesToPredefinedLocations(ctx, imageConfig) {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-09-17 02:44:12 +02:00
|
|
|
di := android.FindDeapexerProviderForModule(ctx)
|
|
|
|
if di == nil {
|
|
|
|
return nil // An error has been reported by FindDeapexerProviderForModule.
|
2021-06-07 11:25:31 +02:00
|
|
|
}
|
|
|
|
|
2021-07-01 23:04:22 +02:00
|
|
|
files := bootImageFilesByArch{}
|
2021-06-07 11:25:31 +02:00
|
|
|
for _, variant := range imageConfig.apexVariants() {
|
|
|
|
arch := variant.target.Arch.ArchType
|
|
|
|
for _, toPath := range variant.imagesDeps {
|
2021-06-17 16:59:07 +02:00
|
|
|
apexRelativePath := apexRootRelativePathToBootImageFile(arch, toPath.Base())
|
2021-06-07 11:25:31 +02:00
|
|
|
// Get the path to the file that the deapexer extracted from the prebuilt apex file.
|
2021-06-17 16:59:07 +02:00
|
|
|
fromPath := di.PrebuiltExportPath(apexRelativePath)
|
2021-06-07 11:25:31 +02:00
|
|
|
|
2021-07-01 23:04:22 +02:00
|
|
|
// Return the toPath as the calling code expects the paths in the returned map to be the
|
|
|
|
// paths predefined in the bootImageConfig.
|
|
|
|
files[arch] = append(files[arch], toPath)
|
|
|
|
|
2021-06-07 11:25:31 +02:00
|
|
|
// Copy the file to the predefined location.
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.Cp,
|
|
|
|
Input: fromPath,
|
|
|
|
Output: toPath,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-02 14:00:43 +02:00
|
|
|
// Build the boot image files for the host variants. These are built from the dex files provided
|
|
|
|
// by the contents of this module as prebuilt versions of the host boot image files are not
|
|
|
|
// available, i.e. there is no host specific prebuilt apex containing them. This has to be built
|
|
|
|
// without a profile as the prebuilt modules do not provide a profile.
|
|
|
|
buildBootImageVariantsForBuildOs(ctx, imageConfig, nil)
|
|
|
|
|
2021-07-01 23:04:22 +02:00
|
|
|
return files
|
2021-06-07 11:25:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-15 14:32:00 +02:00
|
|
|
var _ commonBootclasspathFragment = (*prebuiltBootclasspathFragmentModule)(nil)
|
|
|
|
|
2021-06-07 11:25:31 +02:00
|
|
|
// createBootImageTag creates the tag to uniquely identify the boot image file among all of the
|
|
|
|
// files that a module requires from the prebuilt .apex file.
|
|
|
|
func createBootImageTag(arch android.ArchType, baseName string) string {
|
|
|
|
tag := fmt.Sprintf(".bootimage-%s-%s", arch, baseName)
|
|
|
|
return tag
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequiredFilesFromPrebuiltApex returns the list of all files the prebuilt_bootclasspath_fragment
|
|
|
|
// requires from a prebuilt .apex file.
|
|
|
|
//
|
|
|
|
// If there is no image config associated with this fragment then it returns nil. Otherwise, it
|
|
|
|
// returns the files that are listed in the image config.
|
2021-06-17 16:59:07 +02:00
|
|
|
func (module *prebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) []string {
|
2021-06-07 11:25:31 +02:00
|
|
|
imageConfig := module.getImageConfig(ctx)
|
|
|
|
if imageConfig != nil {
|
|
|
|
// Add the boot image files, e.g. .art, .oat and .vdex files.
|
2021-06-17 16:59:07 +02:00
|
|
|
files := []string{}
|
2021-06-07 11:25:31 +02:00
|
|
|
for _, variant := range imageConfig.apexVariants() {
|
|
|
|
arch := variant.target.Arch.ArchType
|
|
|
|
for _, path := range variant.imagesDeps.Paths() {
|
|
|
|
base := path.Base()
|
2021-06-17 16:59:07 +02:00
|
|
|
files = append(files, apexRootRelativePathToBootImageFile(arch, base))
|
2021-06-07 11:25:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return files
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-06-17 16:59:07 +02:00
|
|
|
func apexRootRelativePathToBootImageFile(arch android.ArchType, base string) string {
|
|
|
|
return filepath.Join("javalib", arch.String(), base)
|
|
|
|
}
|
|
|
|
|
2021-06-07 11:25:31 +02:00
|
|
|
var _ android.RequiredFilesFromPrebuiltApex = (*prebuiltBootclasspathFragmentModule)(nil)
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func prebuiltBootclasspathFragmentFactory() android.Module {
|
|
|
|
m := &prebuiltBootclasspathFragmentModule{}
|
2021-04-15 14:32:00 +02:00
|
|
|
m.AddProperties(&m.properties, &m.prebuiltProperties)
|
2021-03-10 16:00:46 +01:00
|
|
|
// This doesn't actually have any prebuilt files of its own so pass a placeholder for the srcs
|
|
|
|
// array.
|
|
|
|
android.InitPrebuiltModule(m, &[]string{"placeholder"})
|
|
|
|
android.InitApexModule(m)
|
|
|
|
android.InitSdkAwareModule(m)
|
2021-03-17 01:26:25 +01:00
|
|
|
android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibCommon)
|
2021-03-24 00:21:59 +01:00
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
// Initialize the contents property from the image_name.
|
2021-03-24 00:21:59 +01:00
|
|
|
android.AddLoadHook(m, func(ctx android.LoadHookContext) {
|
2021-04-23 15:25:28 +02:00
|
|
|
bootclasspathFragmentInitContentsFromImage(ctx, &m.BootclasspathFragmentModule)
|
2021-03-24 00:21:59 +01:00
|
|
|
})
|
2021-03-10 16:00:46 +01:00
|
|
|
return m
|
|
|
|
}
|