2019-02-12 06:21:24 +08: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"
|
2020-04-01 20:52:27 +08:00
|
|
|
"sort"
|
2019-02-12 06:21:24 +08:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/dexpreopt"
|
|
|
|
|
|
|
|
"github.com/google/blueprint/proptools"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2020-01-13 23:18:16 +08:00
|
|
|
RegisterDexpreoptBootJarsComponents(android.InitRegistrationContext)
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
|
2020-02-19 04:43:06 +08:00
|
|
|
// Target-independent description of pre-compiled boot image.
|
2019-02-16 15:06:46 +08:00
|
|
|
type bootImageConfig struct {
|
2020-03-26 19:10:45 +08:00
|
|
|
// If this image is an extension, the image that it extends.
|
|
|
|
extends *bootImageConfig
|
2019-11-08 18:54:21 +08:00
|
|
|
|
|
|
|
// Image name (used in directory names and ninja rule names).
|
|
|
|
name string
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
// Subdirectory where the image files are installed.
|
|
|
|
installSubdir string
|
|
|
|
|
|
|
|
// The names of jars that constitute this image.
|
|
|
|
modules []string
|
2019-02-16 15:06:46 +08:00
|
|
|
|
2019-11-08 18:54:21 +08:00
|
|
|
// File paths to jars.
|
|
|
|
dexPaths android.WritablePaths // for this image
|
|
|
|
dexPathsDeps android.WritablePaths // for the dependency images and in this image
|
|
|
|
|
|
|
|
// File path to a zip archive with all image files (or nil, if not needed).
|
|
|
|
zip android.WritablePath
|
2020-02-19 04:43:06 +08:00
|
|
|
|
|
|
|
// Rules which should be used in make to install the outputs.
|
|
|
|
profileInstalls android.RuleBuilderInstalls
|
|
|
|
|
|
|
|
// Target-dependent fields.
|
|
|
|
variants []*bootImageVariant
|
|
|
|
}
|
|
|
|
|
|
|
|
// Target-dependent description of pre-compiled boot image.
|
|
|
|
type bootImageVariant struct {
|
|
|
|
*bootImageConfig
|
|
|
|
|
|
|
|
// Target for which the image is generated.
|
|
|
|
target android.Target
|
|
|
|
|
2020-03-31 00:24:13 +08:00
|
|
|
// The "locations" of jars.
|
|
|
|
dexLocations []string // for this image
|
|
|
|
dexLocationsDeps []string // for the dependency images and in this image
|
|
|
|
|
2020-02-19 04:43:06 +08:00
|
|
|
// Paths to image files.
|
|
|
|
images android.OutputPath // first image file
|
|
|
|
imagesDeps android.OutputPaths // all files
|
|
|
|
|
|
|
|
// Only for extensions, paths to the primary boot images.
|
|
|
|
primaryImages android.OutputPath
|
|
|
|
|
|
|
|
// Rules which should be used in make to install the outputs.
|
|
|
|
installs android.RuleBuilderInstalls
|
|
|
|
vdexInstalls android.RuleBuilderInstalls
|
|
|
|
unstrippedInstalls android.RuleBuilderInstalls
|
|
|
|
}
|
|
|
|
|
|
|
|
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 18:54:21 +08:00
|
|
|
}
|
|
|
|
|
2020-03-31 00:24:13 +08:00
|
|
|
// Return any (the first) variant which is for the device (as opposed to for the host)
|
|
|
|
func (image bootImageConfig) getAnyAndroidVariant() *bootImageVariant {
|
|
|
|
for _, variant := range image.variants {
|
|
|
|
if variant.target.Os == android.Android {
|
|
|
|
return variant
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-08 18:54:21 +08:00
|
|
|
func (image bootImageConfig) moduleName(idx int) string {
|
|
|
|
// Dexpreopt on the boot class path produces multiple files. The first dex file
|
|
|
|
// is converted into 'name'.art (to match the legacy assumption that 'name'.art
|
2019-06-14 05:44:53 +08:00
|
|
|
// exists), and the rest are converted to 'name'-<jar>.art.
|
2019-11-08 18:54:21 +08:00
|
|
|
m := image.modules[idx]
|
|
|
|
name := image.stem
|
2020-03-26 19:10:45 +08:00
|
|
|
if idx != 0 || image.extends != nil {
|
2019-11-08 18:54:21 +08:00
|
|
|
name += "-" + stemOf(m)
|
|
|
|
}
|
|
|
|
return name
|
|
|
|
}
|
2019-06-14 05:44:53 +08:00
|
|
|
|
2019-11-08 18:54:21 +08:00
|
|
|
func (image bootImageConfig) firstModuleNameOrStem() string {
|
|
|
|
if len(image.modules) > 0 {
|
|
|
|
return image.moduleName(0)
|
|
|
|
} else {
|
|
|
|
return image.stem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (image bootImageConfig) moduleFiles(ctx android.PathContext, dir android.OutputPath, exts ...string) android.OutputPaths {
|
|
|
|
ret := make(android.OutputPaths, 0, len(image.modules)*len(exts))
|
|
|
|
for i := range image.modules {
|
|
|
|
name := image.moduleName(i)
|
2019-06-14 05:44:53 +08:00
|
|
|
for _, ext := range exts {
|
|
|
|
ret = append(ret, dir.Join(ctx, name+ext))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2020-03-26 19:10:45 +08: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.
|
|
|
|
//
|
|
|
|
// 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).
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
func (image *bootImageVariant) imageLocations() (imageLocations []string) {
|
|
|
|
if image.extends != nil {
|
|
|
|
imageLocations = image.extends.getVariant(image.target).imageLocations()
|
|
|
|
}
|
|
|
|
return append(imageLocations, dexpreopt.PathToLocation(image.images, image.target.Arch.ArchType))
|
|
|
|
}
|
|
|
|
|
2019-02-12 06:21:24 +08:00
|
|
|
func concat(lists ...[]string) []string {
|
|
|
|
var size int
|
|
|
|
for _, l := range lists {
|
|
|
|
size += len(l)
|
|
|
|
}
|
|
|
|
ret := make([]string, 0, size)
|
|
|
|
for _, l := range lists {
|
|
|
|
ret = append(ret, l...)
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func dexpreoptBootJarsFactory() android.Singleton {
|
2019-02-16 15:06:46 +08:00
|
|
|
return &dexpreoptBootJars{}
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
|
2020-01-13 23:18:16 +08:00
|
|
|
func RegisterDexpreoptBootJarsComponents(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterSingletonType("dex_bootjars", dexpreoptBootJarsFactory)
|
|
|
|
}
|
|
|
|
|
2019-02-12 06:21:24 +08:00
|
|
|
func skipDexpreoptBootJars(ctx android.PathContext) bool {
|
2020-01-21 02:12:23 +08:00
|
|
|
if dexpreopt.GetGlobalConfig(ctx).DisablePreopt {
|
2019-11-02 01:57:29 +08:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2019-02-12 06:21:24 +08:00
|
|
|
if ctx.Config().UnbundledBuild() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-16 15:06:46 +08:00
|
|
|
type dexpreoptBootJars struct {
|
2020-02-19 04:43:06 +08:00
|
|
|
defaultBootImage *bootImageConfig
|
|
|
|
otherImages []*bootImageConfig
|
2019-05-10 12:50:00 +08:00
|
|
|
|
|
|
|
dexpreoptConfigForMake android.WritablePath
|
2019-02-16 15:06:46 +08:00
|
|
|
}
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-11-08 18:51:01 +08:00
|
|
|
// Accessor function for the apex package. Returns nil if dexpreopt is disabled.
|
2020-03-19 02:00:41 +08:00
|
|
|
func DexpreoptedArtApexJars(ctx android.BuilderContext) map[android.ArchType]android.OutputPaths {
|
2020-01-03 21:25:54 +08:00
|
|
|
if skipDexpreoptBootJars(ctx) {
|
2020-03-19 02:00:41 +08:00
|
|
|
return nil
|
2019-11-08 18:51:01 +08:00
|
|
|
}
|
2020-03-19 02:00:41 +08:00
|
|
|
// Include dexpreopt files for the primary boot image.
|
|
|
|
files := map[android.ArchType]android.OutputPaths{}
|
|
|
|
for _, variant := range artBootImageConfig(ctx).variants {
|
2020-02-14 00:00:45 +08:00
|
|
|
// We also generate boot images for host (for testing), but we don't need those in the apex.
|
2020-03-19 02:00:41 +08:00
|
|
|
if variant.target.Os == android.Android {
|
|
|
|
files[variant.target.Arch.ArchType] = variant.imagesDeps
|
2020-02-14 00:00:45 +08:00
|
|
|
}
|
2020-02-19 04:43:06 +08:00
|
|
|
}
|
2020-03-19 02:00:41 +08:00
|
|
|
return files
|
2019-11-08 18:51:01 +08:00
|
|
|
}
|
|
|
|
|
2019-02-12 06:21:24 +08:00
|
|
|
// dexpreoptBoot singleton rules
|
2019-02-16 15:06:46 +08:00
|
|
|
func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) {
|
2019-02-12 06:21:24 +08:00
|
|
|
if skipDexpreoptBootJars(ctx) {
|
|
|
|
return
|
|
|
|
}
|
2020-02-01 01:10:36 +08:00
|
|
|
if dexpreopt.GetCachedGlobalSoongConfig(ctx) == nil {
|
|
|
|
// No module has enabled dexpreopting, so we assume there will be no boot image to make.
|
|
|
|
return
|
|
|
|
}
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-05-10 12:50:00 +08:00
|
|
|
d.dexpreoptConfigForMake = android.PathForOutput(ctx, ctx.Config().DeviceName(), "dexpreopt.config")
|
|
|
|
writeGlobalConfigForMake(ctx, d.dexpreoptConfigForMake)
|
|
|
|
|
2020-01-21 02:12:23 +08:00
|
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
2019-02-12 06:21:24 +08:00
|
|
|
|
|
|
|
// 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(ctx.Config().SanitizeDevice()) == 1 &&
|
|
|
|
ctx.Config().SanitizeDevice()[0] == "address" &&
|
2019-02-16 15:06:46 +08:00
|
|
|
global.SanitizeLite {
|
2019-02-12 06:21:24 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-12-20 00:40:09 +08:00
|
|
|
// Always create the default boot image first, to get a unique profile rule for all images.
|
|
|
|
d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
|
2020-01-03 21:25:54 +08:00
|
|
|
// Create boot image for the ART apex (build artifacts are accessed via the global boot image config).
|
|
|
|
d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx)))
|
2019-02-27 13:13:48 +08:00
|
|
|
|
|
|
|
dumpOatRules(ctx, d.defaultBootImage)
|
2019-02-16 15:06:46 +08:00
|
|
|
}
|
|
|
|
|
2020-01-13 23:18:16 +08:00
|
|
|
// Inspect this module to see if it contains a bootclasspath dex jar.
|
|
|
|
// Note that the same jar may occur in multiple modules.
|
|
|
|
// This logic is tested in the apex package to avoid import cycle apex <-> java.
|
|
|
|
func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, module android.Module) (int, android.Path) {
|
|
|
|
// All apex Java libraries have non-installable platform variants, skip them.
|
|
|
|
if module.IsSkipInstall() {
|
|
|
|
return -1, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
jar, hasJar := module.(interface{ DexJar() android.Path })
|
|
|
|
if !hasJar {
|
|
|
|
return -1, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
name := ctx.ModuleName(module)
|
|
|
|
index := android.IndexList(name, image.modules)
|
|
|
|
if index == -1 {
|
|
|
|
return -1, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that this module satisfies constraints for a particular boot image.
|
|
|
|
apex, isApexModule := module.(android.ApexModule)
|
|
|
|
if image.name == artBootImageName {
|
|
|
|
if isApexModule && strings.HasPrefix(apex.ApexName(), "com.android.art.") {
|
|
|
|
// ok, found the jar in the ART apex
|
|
|
|
} else if isApexModule && !apex.IsForPlatform() {
|
|
|
|
// this jar is part of an updatable apex other than ART, fail immediately
|
|
|
|
ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the ART boot image", name, apex.ApexName())
|
|
|
|
} else if isApexModule && apex.IsForPlatform() && Bool(module.(*Library).deviceProperties.Hostdex) {
|
|
|
|
// this is a special "hostdex" variant, skip it and resume search
|
|
|
|
return -1, nil
|
2020-04-08 22:00:49 +08:00
|
|
|
} else if name == "jacocoagent" && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
|
|
|
|
// this is Jacoco platform variant for a coverage build, skip it and resume search
|
|
|
|
return -1, nil
|
2020-01-13 23:18:16 +08:00
|
|
|
} else {
|
|
|
|
// this (installable) jar is part of the platform, fail immediately
|
|
|
|
ctx.Errorf("module '%s' is part of the platform and not allowed in the ART boot image", name)
|
|
|
|
}
|
|
|
|
} else if image.name == frameworkBootImageName {
|
|
|
|
if !isApexModule || apex.IsForPlatform() {
|
|
|
|
// ok, this jar is part of the platform
|
|
|
|
} else {
|
|
|
|
// this jar is part of an updatable apex, fail immediately
|
|
|
|
ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the framework boot image", name, apex.ApexName())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
panic("unknown boot image: " + image.name)
|
|
|
|
}
|
|
|
|
|
|
|
|
return index, jar.DexJar()
|
|
|
|
}
|
|
|
|
|
2020-02-19 04:43:06 +08:00
|
|
|
// buildBootImage takes a bootImageConfig, creates rules to build it, and returns the image.
|
|
|
|
func buildBootImage(ctx android.SingletonContext, image *bootImageConfig) *bootImageConfig {
|
2020-01-13 23:18:16 +08:00
|
|
|
// Collect dex jar paths for the boot image modules.
|
|
|
|
// This logic is tested in the apex package to avoid import cycle apex <-> java.
|
2019-02-16 15:06:46 +08:00
|
|
|
bootDexJars := make(android.Paths, len(image.modules))
|
2019-02-12 06:21:24 +08:00
|
|
|
ctx.VisitAllModules(func(module android.Module) {
|
2020-01-13 23:18:16 +08:00
|
|
|
if i, j := getBootImageJar(ctx, image, module); i != -1 {
|
|
|
|
bootDexJars[i] = j
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var missingDeps []string
|
|
|
|
// Ensure all modules were converted to paths
|
|
|
|
for i := range bootDexJars {
|
|
|
|
if bootDexJars[i] == nil {
|
|
|
|
if ctx.Config().AllowMissingDependencies() {
|
2019-02-16 15:06:46 +08:00
|
|
|
missingDeps = append(missingDeps, image.modules[i])
|
2019-02-12 06:21:24 +08:00
|
|
|
bootDexJars[i] = android.PathForOutput(ctx, "missing")
|
|
|
|
} else {
|
2020-01-13 23:18:16 +08:00
|
|
|
ctx.Errorf("failed to find a dex jar path for module '%s'"+
|
|
|
|
", note that some jars may be filtered out by module constraints",
|
2019-02-16 15:06:46 +08:00
|
|
|
image.modules[i])
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The path to bootclasspath dex files needs to be known at module GenerateAndroidBuildAction time, before
|
|
|
|
// the bootclasspath modules have been compiled. Copy the dex jars there so the module rules that have
|
|
|
|
// already been set up can find them.
|
|
|
|
for i := range bootDexJars {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.Cp,
|
|
|
|
Input: bootDexJars[i],
|
2019-02-16 15:06:46 +08:00
|
|
|
Output: image.dexPaths[i],
|
2019-02-12 06:21:24 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-02-16 15:06:46 +08:00
|
|
|
profile := bootImageProfileRule(ctx, image, missingDeps)
|
2019-07-24 20:19:29 +08:00
|
|
|
bootFrameworkProfileRule(ctx, image, missingDeps)
|
2020-04-01 20:52:27 +08:00
|
|
|
updatableBcpPackagesRule(ctx, image, missingDeps)
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-04-10 06:29:41 +08:00
|
|
|
var allFiles android.Paths
|
2020-02-19 04:43:06 +08:00
|
|
|
for _, variant := range image.variants {
|
|
|
|
files := buildBootImageVariant(ctx, variant, profile, missingDeps)
|
2019-11-08 18:51:01 +08:00
|
|
|
allFiles = append(allFiles, files.Paths()...)
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
2019-02-16 15:06:46 +08:00
|
|
|
|
2019-04-10 06:29:41 +08:00
|
|
|
if image.zip != nil {
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
rule.Command().
|
2019-07-09 08:08:34 +08:00
|
|
|
BuiltTool(ctx, "soong_zip").
|
2019-04-10 06:29:41 +08:00
|
|
|
FlagWithOutput("-o ", image.zip).
|
|
|
|
FlagWithArg("-C ", image.dir.String()).
|
|
|
|
FlagWithInputList("-f ", allFiles, " -f ")
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "zip_"+image.name, "zip "+image.name+" image")
|
|
|
|
}
|
|
|
|
|
2019-02-16 15:06:46 +08:00
|
|
|
return image
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
|
2020-02-19 04:43:06 +08:00
|
|
|
func buildBootImageVariant(ctx android.SingletonContext, image *bootImageVariant,
|
|
|
|
profile android.Path, missingDeps []string) android.WritablePaths {
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2020-01-11 04:32:59 +08:00
|
|
|
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
|
2020-01-21 02:12:23 +08:00
|
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
2019-02-16 15:06:46 +08:00
|
|
|
|
2020-02-19 04:43:06 +08:00
|
|
|
arch := image.target.Arch.ArchType
|
2020-02-14 00:00:45 +08:00
|
|
|
os := image.target.Os.String() // We need to distinguish host-x86 and device-x86.
|
|
|
|
symbolsDir := image.symbolsDir.Join(ctx, os, image.installSubdir, arch.String())
|
2019-11-08 18:51:01 +08:00
|
|
|
symbolsFile := symbolsDir.Join(ctx, image.stem+".oat")
|
2020-02-14 00:00:45 +08:00
|
|
|
outputDir := image.dir.Join(ctx, os, image.installSubdir, arch.String())
|
2019-11-08 18:54:21 +08:00
|
|
|
outputPath := outputDir.Join(ctx, image.stem+".oat")
|
|
|
|
oatLocation := dexpreopt.PathToLocation(outputPath, arch)
|
|
|
|
imagePath := outputPath.ReplaceExtension(ctx, "art")
|
2019-02-12 06:21:24 +08:00
|
|
|
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
rule.MissingDeps(missingDeps)
|
|
|
|
|
|
|
|
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()).
|
|
|
|
Flag(symbolsDir.Join(ctx, "*.invocation").String())
|
|
|
|
rule.Command().Text("rm").Flag("-f").
|
|
|
|
Flag(outputDir.Join(ctx, "*.art").String()).
|
|
|
|
Flag(outputDir.Join(ctx, "*.oat").String()).
|
|
|
|
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")
|
|
|
|
|
2020-01-11 04:32:59 +08:00
|
|
|
cmd.Tool(globalSoong.Dex2oat).
|
2019-02-12 06:21:24 +08:00
|
|
|
Flag("--avoid-storing-invocation").
|
2019-02-16 02:39:37 +08:00
|
|
|
FlagWithOutput("--write-invocation-to=", invocationPath).ImplicitOutput(invocationPath).
|
2019-02-16 15:06:46 +08:00
|
|
|
Flag("--runtime-arg").FlagWithArg("-Xms", global.Dex2oatImageXms).
|
|
|
|
Flag("--runtime-arg").FlagWithArg("-Xmx", global.Dex2oatImageXmx)
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-02-16 02:39:37 +08:00
|
|
|
if profile != nil {
|
2019-02-12 06:21:24 +08:00
|
|
|
cmd.FlagWithArg("--compiler-filter=", "speed-profile")
|
2019-02-16 02:39:37 +08:00
|
|
|
cmd.FlagWithInput("--profile-file=", profile)
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
|
2019-02-16 15:06:46 +08:00
|
|
|
if global.DirtyImageObjects.Valid() {
|
|
|
|
cmd.FlagWithInput("--dirty-image-objects=", global.DirtyImageObjects.Path())
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
|
2020-03-26 19:10:45 +08:00
|
|
|
if image.extends != nil {
|
2020-02-19 04:43:06 +08:00
|
|
|
artImage := image.primaryImages
|
2019-11-08 18:54:21 +08:00
|
|
|
cmd.
|
|
|
|
Flag("--runtime-arg").FlagWithInputList("-Xbootclasspath:", image.dexPathsDeps.Paths(), ":").
|
|
|
|
Flag("--runtime-arg").FlagWithList("-Xbootclasspath-locations:", image.dexLocationsDeps, ":").
|
|
|
|
FlagWithArg("--boot-image=", dexpreopt.PathToLocation(artImage, arch)).Implicit(artImage)
|
|
|
|
} else {
|
|
|
|
cmd.FlagWithArg("--base=", ctx.Config().LibartImgDeviceBaseAddress())
|
|
|
|
}
|
|
|
|
|
2019-02-12 06:21:24 +08:00
|
|
|
cmd.
|
2019-02-16 15:06:46 +08:00
|
|
|
FlagForEachInput("--dex-file=", image.dexPaths.Paths()).
|
|
|
|
FlagForEachArg("--dex-location=", image.dexLocations).
|
2019-02-12 06:21:24 +08:00
|
|
|
Flag("--generate-debug-info").
|
|
|
|
Flag("--generate-build-id").
|
2019-07-27 04:50:04 +08:00
|
|
|
Flag("--image-format=lz4hc").
|
2019-11-08 18:54:21 +08:00
|
|
|
FlagWithArg("--oat-symbols=", symbolsFile.String()).
|
2019-02-12 06:21:24 +08:00
|
|
|
Flag("--strip").
|
2019-11-08 18:54:21 +08:00
|
|
|
FlagWithArg("--oat-file=", outputPath.String()).
|
2019-02-12 06:21:24 +08:00
|
|
|
FlagWithArg("--oat-location=", oatLocation).
|
2019-11-08 18:54:21 +08:00
|
|
|
FlagWithArg("--image=", imagePath.String()).
|
2019-02-12 06:21:24 +08:00
|
|
|
FlagWithArg("--instruction-set=", arch.String()).
|
2019-02-16 15:06:46 +08:00
|
|
|
FlagWithArg("--android-root=", global.EmptyDirectory).
|
2019-02-12 06:21:24 +08:00
|
|
|
FlagWithArg("--no-inline-from=", "core-oj.jar").
|
2020-03-09 20:46:06 +08:00
|
|
|
Flag("--force-determinism").
|
2019-02-12 06:21:24 +08:00
|
|
|
Flag("--abort-on-hard-verifier-error")
|
|
|
|
|
2020-02-14 00:00:45 +08: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])
|
|
|
|
}
|
|
|
|
|
2019-02-16 15:06:46 +08:00
|
|
|
if global.BootFlags != "" {
|
|
|
|
cmd.Flag(global.BootFlags)
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if extraFlags != "" {
|
|
|
|
cmd.Flag(extraFlags)
|
|
|
|
}
|
|
|
|
|
2019-03-01 03:00:01 +08:00
|
|
|
cmd.Textf(`|| ( echo %s ; false )`, proptools.ShellEscape(failureMessage))
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-11-08 18:54:21 +08:00
|
|
|
installDir := filepath.Join("/", image.installSubdir, arch.String())
|
2019-02-12 06:21:24 +08:00
|
|
|
|
|
|
|
var vdexInstalls android.RuleBuilderInstalls
|
|
|
|
var unstrippedInstalls android.RuleBuilderInstalls
|
|
|
|
|
2019-04-10 06:29:41 +08:00
|
|
|
var zipFiles android.WritablePaths
|
|
|
|
|
2019-06-14 05:44:53 +08:00
|
|
|
for _, artOrOat := range image.moduleFiles(ctx, outputDir, ".art", ".oat") {
|
|
|
|
cmd.ImplicitOutput(artOrOat)
|
|
|
|
zipFiles = append(zipFiles, artOrOat)
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-06-14 05:44:53 +08:00
|
|
|
// Install the .oat and .art files
|
|
|
|
rule.Install(artOrOat, filepath.Join(installDir, artOrOat.Base()))
|
|
|
|
}
|
2019-04-10 06:29:41 +08:00
|
|
|
|
2019-06-14 05:44:53 +08:00
|
|
|
for _, vdex := range image.moduleFiles(ctx, outputDir, ".vdex") {
|
|
|
|
cmd.ImplicitOutput(vdex)
|
|
|
|
zipFiles = append(zipFiles, vdex)
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2020-02-14 00:00:45 +08:00
|
|
|
// Note that the vdex files are identical between architectures.
|
|
|
|
// Make rules will create symlinks to share them between architectures.
|
2019-02-12 06:21:24 +08:00
|
|
|
vdexInstalls = append(vdexInstalls,
|
2020-02-14 00:00:45 +08:00
|
|
|
android.RuleBuilderInstall{vdex, filepath.Join(installDir, vdex.Base())})
|
2019-06-14 05:44:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, unstrippedOat := range image.moduleFiles(ctx, symbolsDir, ".oat") {
|
|
|
|
cmd.ImplicitOutput(unstrippedOat)
|
2019-02-12 06:21:24 +08:00
|
|
|
|
|
|
|
// Install the unstripped oat files. The Make rules will put these in $(TARGET_OUT_UNSTRIPPED)
|
|
|
|
unstrippedInstalls = append(unstrippedInstalls,
|
2019-02-16 02:39:37 +08:00
|
|
|
android.RuleBuilderInstall{unstrippedOat, filepath.Join(installDir, unstrippedOat.Base())})
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
|
2020-02-14 00:00:45 +08:00
|
|
|
rule.Build(pctx, ctx, image.name+"JarsDexpreopt_"+image.target.String(), "dexpreopt "+image.name+" jars "+arch.String())
|
2019-02-12 06:21:24 +08:00
|
|
|
|
|
|
|
// save output and installed files for makevars
|
2020-02-19 04:43:06 +08:00
|
|
|
image.installs = rule.Installs()
|
|
|
|
image.vdexInstalls = vdexInstalls
|
|
|
|
image.unstrippedInstalls = unstrippedInstalls
|
2019-04-10 06:29:41 +08:00
|
|
|
|
|
|
|
return zipFiles
|
2019-02-12 06:21:24 +08: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.`
|
|
|
|
|
2020-02-19 04:43:06 +08:00
|
|
|
func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig, missingDeps []string) android.WritablePath {
|
2020-01-11 04:32:59 +08:00
|
|
|
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
|
2020-01-21 02:12:23 +08:00
|
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-06-27 01:01:36 +08:00
|
|
|
if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
|
2019-02-25 00:04:52 +08:00
|
|
|
return nil
|
|
|
|
}
|
2019-11-08 18:51:01 +08:00
|
|
|
profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
|
|
|
|
defaultProfile := "frameworks/base/config/boot-image-profile.txt"
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-02-22 23:34:40 +08:00
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
rule.MissingDeps(missingDeps)
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-02-22 23:34:40 +08:00
|
|
|
var bootImageProfile android.Path
|
|
|
|
if len(global.BootImageProfiles) > 1 {
|
|
|
|
combinedBootImageProfile := image.dir.Join(ctx, "boot-image-profile.txt")
|
|
|
|
rule.Command().Text("cat").Inputs(global.BootImageProfiles).Text(">").Output(combinedBootImageProfile)
|
|
|
|
bootImageProfile = combinedBootImageProfile
|
|
|
|
} else if len(global.BootImageProfiles) == 1 {
|
|
|
|
bootImageProfile = global.BootImageProfiles[0]
|
2019-11-08 18:51:01 +08:00
|
|
|
} else if path := android.ExistentPathForSource(ctx, defaultProfile); path.Valid() {
|
|
|
|
bootImageProfile = path.Path()
|
2019-02-16 02:39:37 +08:00
|
|
|
} else {
|
2019-11-08 18:51:01 +08:00
|
|
|
// 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
|
2019-02-16 02:39:37 +08:00
|
|
|
}
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-02-22 23:34:40 +08:00
|
|
|
profile := image.dir.Join(ctx, "boot.prof")
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-02-22 23:34:40 +08:00
|
|
|
rule.Command().
|
|
|
|
Text(`ANDROID_LOG_TAGS="*:e"`).
|
2020-01-11 04:32:59 +08:00
|
|
|
Tool(globalSoong.Profman).
|
2019-02-22 23:34:40 +08:00
|
|
|
FlagWithInput("--create-profile-from=", bootImageProfile).
|
2019-11-08 18:54:21 +08:00
|
|
|
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
|
2020-03-31 00:24:13 +08:00
|
|
|
FlagForEachArg("--dex-location=", image.getAnyAndroidVariant().dexLocationsDeps).
|
2019-02-22 23:34:40 +08:00
|
|
|
FlagWithOutput("--reference-profile-file=", profile)
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-02-22 23:34:40 +08:00
|
|
|
rule.Install(profile, "/system/etc/boot-image.prof")
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-02-22 23:34:40 +08:00
|
|
|
rule.Build(pctx, ctx, "bootJarsProfile", "profile boot jars")
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-02-22 23:34:40 +08:00
|
|
|
image.profileInstalls = rule.Installs()
|
2019-02-12 06:21:24 +08:00
|
|
|
|
2019-02-22 23:34:40 +08:00
|
|
|
return profile
|
2019-11-08 18:51:01 +08:00
|
|
|
})
|
|
|
|
if profile == nil {
|
|
|
|
return nil // wrap nil into a typed pointer with value nil
|
|
|
|
}
|
|
|
|
return profile.(android.WritablePath)
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
|
2019-02-22 23:34:40 +08:00
|
|
|
var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule")
|
|
|
|
|
2020-02-19 04:43:06 +08:00
|
|
|
func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConfig, missingDeps []string) android.WritablePath {
|
2020-01-11 04:32:59 +08:00
|
|
|
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
|
2020-01-21 02:12:23 +08:00
|
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
2019-07-24 20:19:29 +08:00
|
|
|
|
|
|
|
if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return ctx.Config().Once(bootFrameworkProfileRuleKey, func() interface{} {
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
rule.MissingDeps(missingDeps)
|
|
|
|
|
|
|
|
// Some branches like master-art-host don't have frameworks/base, so manually
|
|
|
|
// handle the case that the default is missing. Those branches won't attempt to build the profile rule,
|
|
|
|
// and if they do they'll get a missing deps error.
|
|
|
|
defaultProfile := "frameworks/base/config/boot-profile.txt"
|
|
|
|
path := android.ExistentPathForSource(ctx, defaultProfile)
|
|
|
|
var bootFrameworkProfile android.Path
|
|
|
|
if path.Valid() {
|
|
|
|
bootFrameworkProfile = path.Path()
|
|
|
|
} else {
|
|
|
|
missingDeps = append(missingDeps, defaultProfile)
|
|
|
|
bootFrameworkProfile = android.PathForOutput(ctx, "missing")
|
|
|
|
}
|
|
|
|
|
|
|
|
profile := image.dir.Join(ctx, "boot.bprof")
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text(`ANDROID_LOG_TAGS="*:e"`).
|
2020-01-11 04:32:59 +08:00
|
|
|
Tool(globalSoong.Profman).
|
2019-07-24 20:19:29 +08:00
|
|
|
Flag("--generate-boot-profile").
|
|
|
|
FlagWithInput("--create-profile-from=", bootFrameworkProfile).
|
2019-11-08 18:54:21 +08:00
|
|
|
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
|
2020-03-31 00:24:13 +08:00
|
|
|
FlagForEachArg("--dex-location=", image.getAnyAndroidVariant().dexLocationsDeps).
|
2019-07-24 20:19:29 +08:00
|
|
|
FlagWithOutput("--reference-profile-file=", profile)
|
|
|
|
|
|
|
|
rule.Install(profile, "/system/etc/boot-image.bprof")
|
|
|
|
rule.Build(pctx, ctx, "bootFrameworkProfile", "profile boot framework jars")
|
|
|
|
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
|
|
|
|
|
|
|
|
return profile
|
|
|
|
}).(android.WritablePath)
|
|
|
|
}
|
|
|
|
|
|
|
|
var bootFrameworkProfileRuleKey = android.NewOnceKey("bootFrameworkProfileRule")
|
|
|
|
|
2020-04-01 20:52:27 +08:00
|
|
|
func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConfig, missingDeps []string) android.WritablePath {
|
|
|
|
if ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return ctx.Config().Once(updatableBcpPackagesRuleKey, func() interface{} {
|
|
|
|
global := dexpreopt.GetGlobalConfig(ctx)
|
|
|
|
updatableModules := dexpreopt.GetJarsFromApexJarPairs(global.UpdatableBootJars)
|
|
|
|
|
|
|
|
// Collect `permitted_packages` for updatable boot jars.
|
|
|
|
var updatablePackages []string
|
|
|
|
ctx.VisitAllModules(func(module android.Module) {
|
|
|
|
if j, ok := module.(*Library); ok {
|
|
|
|
name := ctx.ModuleName(module)
|
|
|
|
if i := android.IndexList(name, updatableModules); i != -1 {
|
|
|
|
pp := j.properties.Permitted_packages
|
|
|
|
if len(pp) > 0 {
|
|
|
|
updatablePackages = append(updatablePackages, pp...)
|
|
|
|
} else {
|
|
|
|
ctx.Errorf("Missing permitted_packages for %s", name)
|
|
|
|
}
|
|
|
|
// Do not match the same library repeatedly.
|
|
|
|
updatableModules = append(updatableModules[:i], updatableModules[i+1:]...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// Sort updatable packages to ensure deterministic ordering.
|
|
|
|
sort.Strings(updatablePackages)
|
|
|
|
|
|
|
|
updatableBcpPackagesName := "updatable-bcp-packages.txt"
|
|
|
|
updatableBcpPackages := image.dir.Join(ctx, updatableBcpPackagesName)
|
|
|
|
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.WriteFile,
|
|
|
|
Output: updatableBcpPackages,
|
|
|
|
Args: map[string]string{
|
|
|
|
// WriteFile automatically adds the last end-of-line.
|
|
|
|
"content": strings.Join(updatablePackages, "\\n"),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
rule.MissingDeps(missingDeps)
|
|
|
|
rule.Install(updatableBcpPackages, "/system/etc/"+updatableBcpPackagesName)
|
|
|
|
// TODO: Rename `profileInstalls` to `extraInstalls`?
|
|
|
|
// Maybe even move the field out of the bootImageConfig into some higher level type?
|
|
|
|
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
|
|
|
|
|
|
|
|
return updatableBcpPackages
|
|
|
|
}).(android.WritablePath)
|
|
|
|
}
|
|
|
|
|
|
|
|
var updatableBcpPackagesRuleKey = android.NewOnceKey("updatableBcpPackagesRule")
|
|
|
|
|
2020-02-19 04:43:06 +08:00
|
|
|
func dumpOatRules(ctx android.SingletonContext, image *bootImageConfig) {
|
2019-02-27 13:13:48 +08:00
|
|
|
var allPhonies android.Paths
|
2020-02-19 04:43:06 +08:00
|
|
|
for _, image := range image.variants {
|
|
|
|
arch := image.target.Arch.ArchType
|
2020-03-16 21:27:55 +08: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 13:13:48 +08:00
|
|
|
// Create a rule to call oatdump.
|
2020-02-14 00:00:45 +08:00
|
|
|
output := android.PathForOutput(ctx, "boot."+suffix+".oatdump.txt")
|
2019-02-27 13:13:48 +08:00
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
rule.Command().
|
|
|
|
// TODO: for now, use the debug version for better error reporting
|
2019-07-09 08:08:34 +08:00
|
|
|
BuiltTool(ctx, "oatdumpd").
|
2019-11-08 18:54:21 +08:00
|
|
|
FlagWithInputList("--runtime-arg -Xbootclasspath:", image.dexPathsDeps.Paths(), ":").
|
|
|
|
FlagWithList("--runtime-arg -Xbootclasspath-locations:", image.dexLocationsDeps, ":").
|
2020-03-26 19:10:45 +08:00
|
|
|
FlagWithArg("--image=", strings.Join(image.imageLocations(), ":")).Implicits(image.imagesDeps.Paths()).
|
2019-02-27 13:13:48 +08:00
|
|
|
FlagWithOutput("--output=", output).
|
|
|
|
FlagWithArg("--instruction-set=", arch.String())
|
2020-02-14 00:00:45 +08:00
|
|
|
rule.Build(pctx, ctx, "dump-oat-boot-"+suffix, "dump oat boot "+arch.String())
|
2019-02-27 13:13:48 +08:00
|
|
|
|
|
|
|
// Create a phony rule that depends on the output file and prints the path.
|
2020-02-14 00:00:45 +08:00
|
|
|
phony := android.PathForPhony(ctx, "dump-oat-boot-"+suffix)
|
2019-02-27 13:13:48 +08:00
|
|
|
rule = android.NewRuleBuilder()
|
|
|
|
rule.Command().
|
|
|
|
Implicit(output).
|
|
|
|
ImplicitOutput(phony).
|
|
|
|
Text("echo").FlagWithArg("Output in ", output.String())
|
2020-02-14 00:00:45 +08:00
|
|
|
rule.Build(pctx, ctx, "phony-dump-oat-boot-"+suffix, "dump oat boot "+arch.String())
|
2019-02-27 13:13:48 +08:00
|
|
|
|
2020-03-26 19:10:45 +08:00
|
|
|
allPhonies = append(allPhonies, phony)
|
2019-02-27 13:13:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
phony := android.PathForPhony(ctx, "dump-oat-boot")
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.Phony,
|
|
|
|
Output: phony,
|
|
|
|
Inputs: allPhonies,
|
|
|
|
Description: "dump-oat-boot",
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-05-10 12:50:00 +08:00
|
|
|
func writeGlobalConfigForMake(ctx android.SingletonContext, path android.WritablePath) {
|
2020-01-21 02:12:23 +08:00
|
|
|
data := dexpreopt.GetGlobalConfigRawData(ctx)
|
2019-05-10 12:50:00 +08:00
|
|
|
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.WriteFile,
|
|
|
|
Output: path,
|
|
|
|
Args: map[string]string{
|
|
|
|
"content": string(data),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-02-16 15:06:46 +08:00
|
|
|
// Export paths for default boot image to Make
|
|
|
|
func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
|
2019-05-10 12:50:00 +08:00
|
|
|
if d.dexpreoptConfigForMake != nil {
|
|
|
|
ctx.Strict("DEX_PREOPT_CONFIG_FOR_MAKE", d.dexpreoptConfigForMake.String())
|
2020-01-07 07:11:37 +08:00
|
|
|
ctx.Strict("DEX_PREOPT_SOONG_CONFIG_FOR_MAKE", android.PathForOutput(ctx, "dexpreopt_soong.config").String())
|
2019-05-10 12:50:00 +08:00
|
|
|
}
|
|
|
|
|
2019-02-16 15:06:46 +08:00
|
|
|
image := d.defaultBootImage
|
|
|
|
if image != nil {
|
|
|
|
ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String())
|
2019-11-08 18:54:21 +08:00
|
|
|
ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_FILES", strings.Join(image.dexPathsDeps.Strings(), " "))
|
2020-03-31 00:24:13 +08:00
|
|
|
ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(image.getAnyAndroidVariant().dexLocationsDeps, " "))
|
2019-02-22 23:34:40 +08:00
|
|
|
|
|
|
|
var imageNames []string
|
|
|
|
for _, current := range append(d.otherImages, image) {
|
|
|
|
imageNames = append(imageNames, current.name)
|
2020-03-26 19:10:45 +08:00
|
|
|
for _, variant := range current.variants {
|
2020-02-14 00:00:45 +08:00
|
|
|
suffix := ""
|
2020-03-26 19:10:45 +08:00
|
|
|
if variant.target.Os.Class == android.Host {
|
2020-02-14 00:00:45 +08:00
|
|
|
suffix = "_host"
|
|
|
|
}
|
2020-03-26 19:10:45 +08:00
|
|
|
sfx := variant.name + suffix + "_" + variant.target.Arch.ArchType.String()
|
|
|
|
ctx.Strict("DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_"+sfx, variant.vdexInstalls.String())
|
|
|
|
ctx.Strict("DEXPREOPT_IMAGE_"+sfx, variant.images.String())
|
|
|
|
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())
|
2019-02-22 23:34:40 +08:00
|
|
|
}
|
2020-03-31 00:24:13 +08:00
|
|
|
imageLocations := current.getAnyAndroidVariant().imageLocations()
|
2020-03-26 19:10:45 +08:00
|
|
|
ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_"+current.name, strings.Join(imageLocations, ":"))
|
2019-12-05 05:16:01 +08:00
|
|
|
ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+current.name, current.zip.String())
|
2019-02-22 23:34:40 +08:00
|
|
|
}
|
|
|
|
ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(imageNames, " "))
|
2019-02-12 06:21:24 +08:00
|
|
|
}
|
|
|
|
}
|