2018-11-13 02:13:39 +08:00
|
|
|
// Copyright 2018 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.
|
|
|
|
|
|
|
|
// The dexpreopt package converts a global dexpreopt config and a module dexpreopt config into rules to perform
|
2019-10-18 21:51:38 +08:00
|
|
|
// dexpreopting.
|
2018-11-13 02:13:39 +08:00
|
|
|
//
|
|
|
|
// It is used in two places; in the dexpeopt_gen binary for modules defined in Make, and directly linked into Soong.
|
|
|
|
//
|
|
|
|
// For Make modules it is built into the dexpreopt_gen binary, which is executed as a Make rule using global config and
|
|
|
|
// module config specified in JSON files. The binary writes out two shell scripts, only updating them if they have
|
|
|
|
// changed. One script takes an APK or JAR as an input and produces a zip file containing any outputs of preopting,
|
|
|
|
// in the location they should be on the device. The Make build rules will unzip the zip file into $(PRODUCT_OUT) when
|
|
|
|
// installing the APK, which will install the preopt outputs into $(PRODUCT_OUT)/system or $(PRODUCT_OUT)/system_other
|
2019-10-18 21:51:38 +08:00
|
|
|
// as necessary. The zip file may be empty if preopting was disabled for any reason.
|
2018-11-13 02:13:39 +08:00
|
|
|
//
|
|
|
|
// The intermediate shell scripts allow changes to this package or to the global config to regenerate the shell scripts
|
|
|
|
// but only require re-executing preopting if the script has changed.
|
|
|
|
//
|
|
|
|
// For Soong modules this package is linked directly into Soong and run from the java package. It generates the same
|
|
|
|
// commands as for make, using athe same global config JSON file used by make, but using a module config structure
|
|
|
|
// provided by Soong. The generated commands are then converted into Soong rule and written directly to the ninja file,
|
|
|
|
// with no extra shell scripts involved.
|
|
|
|
package dexpreopt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"path/filepath"
|
2019-02-16 02:39:37 +08:00
|
|
|
"runtime"
|
2018-11-13 02:13:39 +08:00
|
|
|
"strings"
|
|
|
|
|
2019-01-31 09:32:39 +08:00
|
|
|
"android/soong/android"
|
|
|
|
|
2018-11-13 02:13:39 +08:00
|
|
|
"github.com/google/blueprint/pathtools"
|
|
|
|
)
|
|
|
|
|
|
|
|
const SystemPartition = "/system/"
|
|
|
|
const SystemOtherPartition = "/system_other/"
|
|
|
|
|
2020-04-24 19:15:20 +08:00
|
|
|
var DexpreoptRunningInSoong = false
|
|
|
|
|
2018-11-13 02:13:39 +08:00
|
|
|
// GenerateDexpreoptRule generates a set of commands that will preopt a module based on a GlobalConfig and a
|
|
|
|
// ModuleConfig. The produced files and their install locations will be available through rule.Installs().
|
2020-11-17 09:32:30 +08:00
|
|
|
func GenerateDexpreoptRule(ctx android.BuilderContext, globalSoong *GlobalSoongConfig,
|
2020-02-01 01:44:54 +08:00
|
|
|
global *GlobalConfig, module *ModuleConfig) (rule *android.RuleBuilder, err error) {
|
2019-02-16 02:39:37 +08:00
|
|
|
|
2018-11-13 02:13:39 +08:00
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
2019-02-16 02:39:37 +08:00
|
|
|
if _, ok := r.(runtime.Error); ok {
|
|
|
|
panic(r)
|
|
|
|
} else if e, ok := r.(error); ok {
|
2018-11-13 02:13:39 +08:00
|
|
|
err = e
|
|
|
|
rule = nil
|
|
|
|
} else {
|
|
|
|
panic(r)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2020-11-17 09:32:30 +08:00
|
|
|
rule = android.NewRuleBuilder(pctx, ctx)
|
2018-11-13 02:13:39 +08:00
|
|
|
|
2019-02-16 02:39:37 +08:00
|
|
|
generateProfile := module.ProfileClassListing.Valid() && !global.DisableGenerateProfile
|
2019-07-24 20:19:29 +08:00
|
|
|
generateBootProfile := module.ProfileBootListing.Valid() && !global.DisableGenerateProfile
|
2018-11-13 02:13:39 +08:00
|
|
|
|
2019-02-16 02:39:37 +08:00
|
|
|
var profile android.WritablePath
|
2018-11-13 02:13:39 +08:00
|
|
|
if generateProfile {
|
2020-01-11 04:32:59 +08:00
|
|
|
profile = profileCommand(ctx, globalSoong, global, module, rule)
|
2018-11-13 02:13:39 +08:00
|
|
|
}
|
2019-07-24 20:19:29 +08:00
|
|
|
if generateBootProfile {
|
2020-01-11 04:32:59 +08:00
|
|
|
bootProfileCommand(ctx, globalSoong, global, module, rule)
|
2019-07-24 20:19:29 +08:00
|
|
|
}
|
2018-11-13 02:13:39 +08:00
|
|
|
|
2019-12-03 23:39:23 +08:00
|
|
|
if !dexpreoptDisabled(ctx, global, module) {
|
2020-11-03 23:15:46 +08:00
|
|
|
if valid, err := validateClassLoaderContext(module.ClassLoaderContexts); err != nil {
|
2020-10-21 00:41:54 +08:00
|
|
|
android.ReportPathErrorf(ctx, err.Error())
|
2020-11-03 23:15:46 +08:00
|
|
|
} else if valid {
|
|
|
|
fixClassLoaderContext(module.ClassLoaderContexts)
|
|
|
|
|
2019-01-09 09:38:37 +08:00
|
|
|
appImage := (generateProfile || module.ForceCreateAppImage || global.DefaultAppImages) &&
|
|
|
|
!module.NoCreateAppImage
|
|
|
|
|
|
|
|
generateDM := shouldGenerateDM(module, global)
|
|
|
|
|
2019-11-08 18:54:21 +08:00
|
|
|
for archIdx, _ := range module.Archs {
|
2020-11-03 23:15:46 +08:00
|
|
|
dexpreoptCommand(ctx, globalSoong, global, module, rule, archIdx, profile, appImage, generateDM)
|
2018-11-13 02:13:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rule, nil
|
|
|
|
}
|
|
|
|
|
2020-02-01 01:44:54 +08:00
|
|
|
func dexpreoptDisabled(ctx android.PathContext, global *GlobalConfig, module *ModuleConfig) bool {
|
2019-01-09 09:38:37 +08:00
|
|
|
if contains(global.DisablePreoptModules, module.Name) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2020-08-19 23:32:54 +08:00
|
|
|
// Don't preopt individual boot jars, they will be preopted together.
|
|
|
|
if global.BootJars.ContainsJar(module.Name) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2019-11-27 20:26:49 +08:00
|
|
|
// Don't preopt system server jars that are updatable.
|
2020-07-01 21:31:13 +08:00
|
|
|
if global.UpdatableSystemServerJars.ContainsJar(module.Name) {
|
|
|
|
return true
|
2019-11-27 20:26:49 +08:00
|
|
|
}
|
|
|
|
|
2019-01-09 09:38:37 +08:00
|
|
|
// If OnlyPreoptBootImageAndSystemServer=true and module is not in boot class path skip
|
|
|
|
// Also preopt system server jars since selinux prevents system server from loading anything from
|
|
|
|
// /data. If we don't do this they will need to be extracted which is not favorable for RAM usage
|
|
|
|
// or performance. If PreoptExtractedApk is true, we ignore the only preopt boot image options.
|
2020-07-01 21:31:13 +08:00
|
|
|
if global.OnlyPreoptBootImageAndSystemServer && !global.BootJars.ContainsJar(module.Name) &&
|
2019-01-09 09:38:37 +08:00
|
|
|
!contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-02-01 01:44:54 +08:00
|
|
|
func profileCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, global *GlobalConfig,
|
|
|
|
module *ModuleConfig, rule *android.RuleBuilder) android.WritablePath {
|
2019-02-16 02:39:37 +08:00
|
|
|
|
|
|
|
profilePath := module.BuildPath.InSameDir(ctx, "profile.prof")
|
2018-11-13 02:13:39 +08:00
|
|
|
profileInstalledPath := module.DexLocation + ".prof"
|
|
|
|
|
|
|
|
if !module.ProfileIsTextListing {
|
2021-04-29 16:05:18 +08:00
|
|
|
rule.Command().Text("rm -f").Output(profilePath)
|
|
|
|
rule.Command().Text("touch").Output(profilePath)
|
2018-11-13 02:13:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd := rule.Command().
|
|
|
|
Text(`ANDROID_LOG_TAGS="*:e"`).
|
2020-01-11 04:32:59 +08:00
|
|
|
Tool(globalSoong.Profman)
|
2018-11-13 02:13:39 +08:00
|
|
|
|
|
|
|
if module.ProfileIsTextListing {
|
|
|
|
// The profile is a test listing of classes (used for framework jars).
|
|
|
|
// We need to generate the actual binary profile before being able to compile.
|
2019-02-16 02:39:37 +08:00
|
|
|
cmd.FlagWithInput("--create-profile-from=", module.ProfileClassListing.Path())
|
2018-11-13 02:13:39 +08:00
|
|
|
} else {
|
|
|
|
// The profile is binary profile (used for apps). Run it through profman to
|
|
|
|
// ensure the profile keys match the apk.
|
|
|
|
cmd.
|
|
|
|
Flag("--copy-and-update-profile-key").
|
2019-02-16 02:39:37 +08:00
|
|
|
FlagWithInput("--profile-file=", module.ProfileClassListing.Path())
|
2018-11-13 02:13:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd.
|
2021-04-23 22:18:33 +08:00
|
|
|
Flag("--output-profile-type=app").
|
2018-11-13 02:13:39 +08:00
|
|
|
FlagWithInput("--apk=", module.DexPath).
|
|
|
|
Flag("--dex-location="+module.DexLocation).
|
|
|
|
FlagWithOutput("--reference-profile-file=", profilePath)
|
|
|
|
|
|
|
|
if !module.ProfileIsTextListing {
|
|
|
|
cmd.Text(fmt.Sprintf(`|| echo "Profile out of date for %s"`, module.DexPath))
|
|
|
|
}
|
|
|
|
rule.Install(profilePath, profileInstalledPath)
|
|
|
|
|
|
|
|
return profilePath
|
|
|
|
}
|
|
|
|
|
2020-02-01 01:44:54 +08:00
|
|
|
func bootProfileCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, global *GlobalConfig,
|
|
|
|
module *ModuleConfig, rule *android.RuleBuilder) android.WritablePath {
|
2019-07-24 20:19:29 +08:00
|
|
|
|
|
|
|
profilePath := module.BuildPath.InSameDir(ctx, "profile.bprof")
|
|
|
|
profileInstalledPath := module.DexLocation + ".bprof"
|
|
|
|
|
|
|
|
if !module.ProfileIsTextListing {
|
2021-04-29 16:05:18 +08:00
|
|
|
rule.Command().Text("rm -f").Output(profilePath)
|
|
|
|
rule.Command().Text("touch").Output(profilePath)
|
2019-07-24 20:19:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd := 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
|
|
|
|
|
|
|
// The profile is a test listing of methods.
|
|
|
|
// We need to generate the actual binary profile.
|
|
|
|
cmd.FlagWithInput("--create-profile-from=", module.ProfileBootListing.Path())
|
|
|
|
|
|
|
|
cmd.
|
2021-04-23 22:18:33 +08:00
|
|
|
Flag("--output-profile-type=bprof").
|
2019-07-24 20:19:29 +08:00
|
|
|
FlagWithInput("--apk=", module.DexPath).
|
|
|
|
Flag("--dex-location="+module.DexLocation).
|
|
|
|
FlagWithOutput("--reference-profile-file=", profilePath)
|
|
|
|
|
|
|
|
if !module.ProfileIsTextListing {
|
|
|
|
cmd.Text(fmt.Sprintf(`|| echo "Profile out of date for %s"`, module.DexPath))
|
|
|
|
}
|
|
|
|
rule.Install(profilePath, profileInstalledPath)
|
|
|
|
|
|
|
|
return profilePath
|
|
|
|
}
|
|
|
|
|
2020-02-01 01:44:54 +08:00
|
|
|
func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, global *GlobalConfig,
|
2020-11-03 23:15:46 +08:00
|
|
|
module *ModuleConfig, rule *android.RuleBuilder, archIdx int, profile android.WritablePath,
|
|
|
|
appImage bool, generateDM bool) {
|
2019-11-08 18:54:21 +08:00
|
|
|
|
|
|
|
arch := module.Archs[archIdx]
|
2018-11-13 02:13:39 +08:00
|
|
|
|
|
|
|
// HACK: make soname in Soong-generated .odex files match Make.
|
|
|
|
base := filepath.Base(module.DexLocation)
|
|
|
|
if filepath.Ext(base) == ".jar" {
|
|
|
|
base = "javalib.jar"
|
|
|
|
} else if filepath.Ext(base) == ".apk" {
|
|
|
|
base = "package.apk"
|
|
|
|
}
|
|
|
|
|
|
|
|
toOdexPath := func(path string) string {
|
|
|
|
return filepath.Join(
|
|
|
|
filepath.Dir(path),
|
|
|
|
"oat",
|
2019-02-12 07:11:14 +08:00
|
|
|
arch.String(),
|
2018-11-13 02:13:39 +08:00
|
|
|
pathtools.ReplaceExtension(filepath.Base(path), "odex"))
|
|
|
|
}
|
|
|
|
|
2019-02-16 02:39:37 +08:00
|
|
|
odexPath := module.BuildPath.InSameDir(ctx, "oat", arch.String(), pathtools.ReplaceExtension(base, "odex"))
|
2018-11-13 02:13:39 +08:00
|
|
|
odexInstallPath := toOdexPath(module.DexLocation)
|
|
|
|
if odexOnSystemOther(module, global) {
|
2019-10-03 21:18:45 +08:00
|
|
|
odexInstallPath = filepath.Join(SystemOtherPartition, odexInstallPath)
|
2018-11-13 02:13:39 +08:00
|
|
|
}
|
|
|
|
|
2019-02-16 02:39:37 +08:00
|
|
|
vdexPath := odexPath.ReplaceExtension(ctx, "vdex")
|
2018-11-13 02:13:39 +08:00
|
|
|
vdexInstallPath := pathtools.ReplaceExtension(odexInstallPath, "vdex")
|
|
|
|
|
2019-02-16 02:39:37 +08:00
|
|
|
invocationPath := odexPath.ReplaceExtension(ctx, "invocation")
|
2018-12-19 07:16:26 +08:00
|
|
|
|
2020-03-11 19:59:34 +08:00
|
|
|
systemServerJars := NonUpdatableSystemServerJars(ctx, global)
|
|
|
|
|
2020-06-30 18:25:49 +08:00
|
|
|
rule.Command().FlagWithArg("mkdir -p ", filepath.Dir(odexPath.String()))
|
|
|
|
rule.Command().FlagWithOutput("rm -f ", odexPath)
|
2020-05-29 22:35:06 +08:00
|
|
|
|
2020-06-30 18:25:49 +08:00
|
|
|
if jarIndex := android.IndexList(module.Name, systemServerJars); jarIndex >= 0 {
|
2020-11-03 23:15:46 +08:00
|
|
|
// System server jars should be dexpreopted together: class loader context of each jar
|
|
|
|
// should include all preceding jars on the system server classpath.
|
|
|
|
|
|
|
|
var clcHost android.Paths
|
|
|
|
var clcTarget []string
|
|
|
|
for _, lib := range systemServerJars[:jarIndex] {
|
|
|
|
clcHost = append(clcHost, SystemServerDexJarHostPath(ctx, lib))
|
|
|
|
clcTarget = append(clcTarget, filepath.Join("/system/framework", lib+".jar"))
|
|
|
|
}
|
|
|
|
|
2020-06-30 18:25:49 +08:00
|
|
|
// Copy the system server jar to a predefined location where dex2oat will find it.
|
|
|
|
dexPathHost := SystemServerDexJarHostPath(ctx, module.Name)
|
|
|
|
rule.Command().Text("mkdir -p").Flag(filepath.Dir(dexPathHost.String()))
|
|
|
|
rule.Command().Text("cp -f").Input(module.DexPath).Output(dexPathHost)
|
|
|
|
|
|
|
|
checkSystemServerOrder(ctx, jarIndex)
|
|
|
|
|
|
|
|
rule.Command().
|
2020-11-03 23:15:46 +08:00
|
|
|
Text("class_loader_context_arg=--class-loader-context=PCL[" + strings.Join(clcHost.Strings(), ":") + "]").
|
|
|
|
Implicits(clcHost).
|
|
|
|
Text("stored_class_loader_context_arg=--stored-class-loader-context=PCL[" + strings.Join(clcTarget, ":") + "]")
|
|
|
|
|
2021-03-12 20:12:12 +08:00
|
|
|
} else {
|
|
|
|
// There are three categories of Java modules handled here:
|
|
|
|
//
|
|
|
|
// - Modules that have passed verify_uses_libraries check. They are AOT-compiled and
|
|
|
|
// expected to be loaded on device without CLC mismatch errors.
|
|
|
|
//
|
|
|
|
// - Modules that have failed the check in relaxed mode, so it didn't cause a build error.
|
|
|
|
// They are dexpreopted with "verify" filter and not AOT-compiled.
|
|
|
|
// TODO(b/132357300): ensure that CLC mismatch errors are ignored with "verify" filter.
|
|
|
|
//
|
|
|
|
// - Modules that didn't run the check. They are AOT-compiled, but it's unknown if they
|
|
|
|
// will have CLC mismatch errors on device (the check is disabled by default).
|
|
|
|
//
|
|
|
|
// TODO(b/132357300): enable the check by default and eliminate the last category, so that
|
|
|
|
// no time/space is wasted on AOT-compiling modules that will fail CLC check on device.
|
|
|
|
|
|
|
|
var manifestOrApk android.Path
|
2021-04-15 08:12:49 +08:00
|
|
|
if module.ManifestPath.Valid() {
|
2021-03-12 20:12:12 +08:00
|
|
|
// Ok, there is an XML manifest.
|
2021-04-15 08:12:49 +08:00
|
|
|
manifestOrApk = module.ManifestPath.Path()
|
2021-03-12 20:12:12 +08:00
|
|
|
} else if filepath.Ext(base) == ".apk" {
|
|
|
|
// Ok, there is is an APK with the manifest inside.
|
|
|
|
manifestOrApk = module.DexPath
|
|
|
|
}
|
|
|
|
|
2020-06-30 18:25:49 +08:00
|
|
|
// Generate command that saves target SDK version in a shell variable.
|
2021-03-04 00:38:37 +08:00
|
|
|
if manifestOrApk == nil {
|
2021-03-12 20:12:12 +08:00
|
|
|
// There is neither an XML manifest nor APK => nowhere to extract targetSdkVersion from.
|
|
|
|
// Set the latest ("any") version: then construct_context will not add any compatibility
|
|
|
|
// libraries (if this is incorrect, there will be a CLC mismatch and dexopt on device).
|
|
|
|
rule.Command().Textf(`target_sdk_version=%d`, AnySdkVersion)
|
|
|
|
} else {
|
|
|
|
rule.Command().Text(`target_sdk_version="$(`).
|
|
|
|
Tool(globalSoong.ManifestCheck).
|
|
|
|
Flag("--extract-target-sdk-version").
|
|
|
|
Input(manifestOrApk).
|
2021-03-25 20:52:49 +08:00
|
|
|
FlagWithInput("--aapt ", globalSoong.Aapt).
|
2021-03-12 20:12:12 +08:00
|
|
|
Text(`)"`)
|
2019-05-23 01:21:09 +08:00
|
|
|
}
|
2020-06-30 18:25:49 +08:00
|
|
|
|
2020-06-30 19:39:01 +08:00
|
|
|
// Generate command that saves host and target class loader context in shell variables.
|
2020-11-03 23:15:46 +08:00
|
|
|
clc, paths := ComputeClassLoaderContext(module.ClassLoaderContexts)
|
Add non-fatal mode for verify_uses_libraries check.
The new mode is enabled with environment variable
RELAX_USES_LIBRARY_CHECK. If the variable is set to true, then a
verify_uses_libraries check failure does not fail the build, instead it
sets a special compiler filter "extract" for dexpreopt, which means that
the DEX file will be extracted, but it won't be compiled to native code.
Class loader context will be set to empty in this case (not &, as it is
going to be deprecated soon).
If the variable RELAX_USES_LIBRARY_CHECK is unset or set to something
other than "true", then the old behaviour of the verify_uses_libraries
check is preserved.
The intended use case for this flag is to have a smoother migration path
for the Java modules that need to add <uses-library> information in
the build files. The flag allows to quickly silence build errors. This
flag should be used with caution and only as a temporary measure, as it
masks real errors and affects performance.
verify_uses_libraries check is reworked so that it writes the error
message to a status file (which is used instead of the former timestamp
file). Currently the stored error message is not used, but it may be
used later to produce a warning. Dexpreopt command checks if the status
file exists and is nonempty; if that is the case, then compiler filter
is set to "extract".
Bug: 132357300
Test: Manually add some mismatch between the libraries in the Android.bp
and Android.mk files for dexpreopted apps, build with
RELAX_USES_LIBRARY_CHECK=true and obsserve that the build doesn't
fail and they are compiled with compiler-filter "extract".
Unset RELAX_USES_LIBRARY_CHECK and observe that the build fails.
Change-Id: Ibb5d993a25b1df1d2e70b7d5aafc6997f9d64e67
2021-02-18 00:23:28 +08:00
|
|
|
rule.Command().
|
2021-03-12 20:12:12 +08:00
|
|
|
Text(`eval "$(`).Tool(globalSoong.ConstructContext).
|
2020-10-07 22:17:13 +08:00
|
|
|
Text(` --target-sdk-version ${target_sdk_version}`).
|
Add non-fatal mode for verify_uses_libraries check.
The new mode is enabled with environment variable
RELAX_USES_LIBRARY_CHECK. If the variable is set to true, then a
verify_uses_libraries check failure does not fail the build, instead it
sets a special compiler filter "extract" for dexpreopt, which means that
the DEX file will be extracted, but it won't be compiled to native code.
Class loader context will be set to empty in this case (not &, as it is
going to be deprecated soon).
If the variable RELAX_USES_LIBRARY_CHECK is unset or set to something
other than "true", then the old behaviour of the verify_uses_libraries
check is preserved.
The intended use case for this flag is to have a smoother migration path
for the Java modules that need to add <uses-library> information in
the build files. The flag allows to quickly silence build errors. This
flag should be used with caution and only as a temporary measure, as it
masks real errors and affects performance.
verify_uses_libraries check is reworked so that it writes the error
message to a status file (which is used instead of the former timestamp
file). Currently the stored error message is not used, but it may be
used later to produce a warning. Dexpreopt command checks if the status
file exists and is nonempty; if that is the case, then compiler filter
is set to "extract".
Bug: 132357300
Test: Manually add some mismatch between the libraries in the Android.bp
and Android.mk files for dexpreopted apps, build with
RELAX_USES_LIBRARY_CHECK=true and obsserve that the build doesn't
fail and they are compiled with compiler-filter "extract".
Unset RELAX_USES_LIBRARY_CHECK and observe that the build fails.
Change-Id: Ibb5d993a25b1df1d2e70b7d5aafc6997f9d64e67
2021-02-18 00:23:28 +08:00
|
|
|
Text(clc).Implicits(paths).
|
2021-03-12 20:12:12 +08:00
|
|
|
Text(`)"`)
|
2018-11-13 02:13:39 +08:00
|
|
|
}
|
|
|
|
|
2019-03-05 22:07:07 +08:00
|
|
|
// Devices that do not have a product partition use a symlink from /product to /system/product.
|
|
|
|
// Because on-device dexopt will see dex locations starting with /product, we change the paths
|
|
|
|
// to mimic this behavior.
|
|
|
|
dexLocationArg := module.DexLocation
|
|
|
|
if strings.HasPrefix(dexLocationArg, "/system/product/") {
|
|
|
|
dexLocationArg = strings.TrimPrefix(dexLocationArg, "/system")
|
|
|
|
}
|
|
|
|
|
2018-11-13 02:13:39 +08:00
|
|
|
cmd := rule.Command().
|
|
|
|
Text(`ANDROID_LOG_TAGS="*:e"`).
|
2020-01-11 04:32:59 +08:00
|
|
|
Tool(globalSoong.Dex2oat).
|
2018-11-13 02:13:39 +08:00
|
|
|
Flag("--avoid-storing-invocation").
|
2018-12-19 07:16:26 +08:00
|
|
|
FlagWithOutput("--write-invocation-to=", invocationPath).ImplicitOutput(invocationPath).
|
2018-11-13 02:13:39 +08:00
|
|
|
Flag("--runtime-arg").FlagWithArg("-Xms", global.Dex2oatXms).
|
|
|
|
Flag("--runtime-arg").FlagWithArg("-Xmx", global.Dex2oatXmx).
|
2019-02-12 06:21:24 +08:00
|
|
|
Flag("--runtime-arg").FlagWithInputList("-Xbootclasspath:", module.PreoptBootClassPathDexFiles, ":").
|
|
|
|
Flag("--runtime-arg").FlagWithList("-Xbootclasspath-locations:", module.PreoptBootClassPathDexLocations, ":").
|
2018-11-13 02:13:39 +08:00
|
|
|
Flag("${class_loader_context_arg}").
|
2020-03-11 19:59:34 +08:00
|
|
|
Flag("${stored_class_loader_context_arg}").
|
2020-01-04 01:33:17 +08:00
|
|
|
FlagWithArg("--boot-image=", strings.Join(module.DexPreoptImageLocations, ":")).Implicits(module.DexPreoptImagesDeps[archIdx].Paths()).
|
2018-11-13 02:13:39 +08:00
|
|
|
FlagWithInput("--dex-file=", module.DexPath).
|
2019-03-05 22:07:07 +08:00
|
|
|
FlagWithArg("--dex-location=", dexLocationArg).
|
2018-11-13 02:13:39 +08:00
|
|
|
FlagWithOutput("--oat-file=", odexPath).ImplicitOutput(vdexPath).
|
|
|
|
// Pass an empty directory, dex2oat shouldn't be reading arbitrary files
|
|
|
|
FlagWithArg("--android-root=", global.EmptyDirectory).
|
2019-02-12 07:11:14 +08:00
|
|
|
FlagWithArg("--instruction-set=", arch.String()).
|
2018-11-13 02:13:39 +08:00
|
|
|
FlagWithArg("--instruction-set-variant=", global.CpuVariant[arch]).
|
|
|
|
FlagWithArg("--instruction-set-features=", global.InstructionSetFeatures[arch]).
|
|
|
|
Flag("--no-generate-debug-info").
|
|
|
|
Flag("--generate-build-id").
|
|
|
|
Flag("--abort-on-hard-verifier-error").
|
|
|
|
Flag("--force-determinism").
|
|
|
|
FlagWithArg("--no-inline-from=", "core-oj.jar")
|
|
|
|
|
|
|
|
var preoptFlags []string
|
|
|
|
if len(module.PreoptFlags) > 0 {
|
|
|
|
preoptFlags = module.PreoptFlags
|
|
|
|
} else if len(global.PreoptFlags) > 0 {
|
|
|
|
preoptFlags = global.PreoptFlags
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(preoptFlags) > 0 {
|
|
|
|
cmd.Text(strings.Join(preoptFlags, " "))
|
|
|
|
}
|
|
|
|
|
|
|
|
if module.UncompressedDex {
|
|
|
|
cmd.FlagWithArg("--copy-dex-files=", "false")
|
|
|
|
}
|
|
|
|
|
2020-02-11 23:54:35 +08:00
|
|
|
if !android.PrefixInList(preoptFlags, "--compiler-filter=") {
|
2018-11-13 02:13:39 +08:00
|
|
|
var compilerFilter string
|
|
|
|
if contains(global.SystemServerJars, module.Name) {
|
|
|
|
// Jars of system server, use the product option if it is set, speed otherwise.
|
|
|
|
if global.SystemServerCompilerFilter != "" {
|
|
|
|
compilerFilter = global.SystemServerCompilerFilter
|
|
|
|
} else {
|
|
|
|
compilerFilter = "speed"
|
|
|
|
}
|
|
|
|
} else if contains(global.SpeedApps, module.Name) || contains(global.SystemServerApps, module.Name) {
|
|
|
|
// Apps loaded into system server, and apps the product default to being compiled with the
|
|
|
|
// 'speed' compiler filter.
|
|
|
|
compilerFilter = "speed"
|
2019-02-16 02:39:37 +08:00
|
|
|
} else if profile != nil {
|
2018-11-13 02:13:39 +08:00
|
|
|
// For non system server jars, use speed-profile when we have a profile.
|
|
|
|
compilerFilter = "speed-profile"
|
|
|
|
} else if global.DefaultCompilerFilter != "" {
|
|
|
|
compilerFilter = global.DefaultCompilerFilter
|
|
|
|
} else {
|
|
|
|
compilerFilter = "quicken"
|
|
|
|
}
|
Add non-fatal mode for verify_uses_libraries check.
The new mode is enabled with environment variable
RELAX_USES_LIBRARY_CHECK. If the variable is set to true, then a
verify_uses_libraries check failure does not fail the build, instead it
sets a special compiler filter "extract" for dexpreopt, which means that
the DEX file will be extracted, but it won't be compiled to native code.
Class loader context will be set to empty in this case (not &, as it is
going to be deprecated soon).
If the variable RELAX_USES_LIBRARY_CHECK is unset or set to something
other than "true", then the old behaviour of the verify_uses_libraries
check is preserved.
The intended use case for this flag is to have a smoother migration path
for the Java modules that need to add <uses-library> information in
the build files. The flag allows to quickly silence build errors. This
flag should be used with caution and only as a temporary measure, as it
masks real errors and affects performance.
verify_uses_libraries check is reworked so that it writes the error
message to a status file (which is used instead of the former timestamp
file). Currently the stored error message is not used, but it may be
used later to produce a warning. Dexpreopt command checks if the status
file exists and is nonempty; if that is the case, then compiler filter
is set to "extract".
Bug: 132357300
Test: Manually add some mismatch between the libraries in the Android.bp
and Android.mk files for dexpreopted apps, build with
RELAX_USES_LIBRARY_CHECK=true and obsserve that the build doesn't
fail and they are compiled with compiler-filter "extract".
Unset RELAX_USES_LIBRARY_CHECK and observe that the build fails.
Change-Id: Ibb5d993a25b1df1d2e70b7d5aafc6997f9d64e67
2021-02-18 00:23:28 +08:00
|
|
|
if module.EnforceUsesLibraries {
|
|
|
|
// If the verify_uses_libraries check failed (in this case status file contains a
|
2021-03-02 20:25:02 +08:00
|
|
|
// non-empty error message), then use "verify" compiler filter to avoid compiling any
|
Add non-fatal mode for verify_uses_libraries check.
The new mode is enabled with environment variable
RELAX_USES_LIBRARY_CHECK. If the variable is set to true, then a
verify_uses_libraries check failure does not fail the build, instead it
sets a special compiler filter "extract" for dexpreopt, which means that
the DEX file will be extracted, but it won't be compiled to native code.
Class loader context will be set to empty in this case (not &, as it is
going to be deprecated soon).
If the variable RELAX_USES_LIBRARY_CHECK is unset or set to something
other than "true", then the old behaviour of the verify_uses_libraries
check is preserved.
The intended use case for this flag is to have a smoother migration path
for the Java modules that need to add <uses-library> information in
the build files. The flag allows to quickly silence build errors. This
flag should be used with caution and only as a temporary measure, as it
masks real errors and affects performance.
verify_uses_libraries check is reworked so that it writes the error
message to a status file (which is used instead of the former timestamp
file). Currently the stored error message is not used, but it may be
used later to produce a warning. Dexpreopt command checks if the status
file exists and is nonempty; if that is the case, then compiler filter
is set to "extract".
Bug: 132357300
Test: Manually add some mismatch between the libraries in the Android.bp
and Android.mk files for dexpreopted apps, build with
RELAX_USES_LIBRARY_CHECK=true and obsserve that the build doesn't
fail and they are compiled with compiler-filter "extract".
Unset RELAX_USES_LIBRARY_CHECK and observe that the build fails.
Change-Id: Ibb5d993a25b1df1d2e70b7d5aafc6997f9d64e67
2021-02-18 00:23:28 +08:00
|
|
|
// code (it would be rejected on device because of a class loader context mismatch).
|
|
|
|
cmd.Text("--compiler-filter=$(if test -s ").
|
|
|
|
Input(module.EnforceUsesLibrariesStatusFile).
|
2021-03-02 20:25:02 +08:00
|
|
|
Text(" ; then echo verify ; else echo " + compilerFilter + " ; fi)")
|
Add non-fatal mode for verify_uses_libraries check.
The new mode is enabled with environment variable
RELAX_USES_LIBRARY_CHECK. If the variable is set to true, then a
verify_uses_libraries check failure does not fail the build, instead it
sets a special compiler filter "extract" for dexpreopt, which means that
the DEX file will be extracted, but it won't be compiled to native code.
Class loader context will be set to empty in this case (not &, as it is
going to be deprecated soon).
If the variable RELAX_USES_LIBRARY_CHECK is unset or set to something
other than "true", then the old behaviour of the verify_uses_libraries
check is preserved.
The intended use case for this flag is to have a smoother migration path
for the Java modules that need to add <uses-library> information in
the build files. The flag allows to quickly silence build errors. This
flag should be used with caution and only as a temporary measure, as it
masks real errors and affects performance.
verify_uses_libraries check is reworked so that it writes the error
message to a status file (which is used instead of the former timestamp
file). Currently the stored error message is not used, but it may be
used later to produce a warning. Dexpreopt command checks if the status
file exists and is nonempty; if that is the case, then compiler filter
is set to "extract".
Bug: 132357300
Test: Manually add some mismatch between the libraries in the Android.bp
and Android.mk files for dexpreopted apps, build with
RELAX_USES_LIBRARY_CHECK=true and obsserve that the build doesn't
fail and they are compiled with compiler-filter "extract".
Unset RELAX_USES_LIBRARY_CHECK and observe that the build fails.
Change-Id: Ibb5d993a25b1df1d2e70b7d5aafc6997f9d64e67
2021-02-18 00:23:28 +08:00
|
|
|
} else {
|
|
|
|
cmd.FlagWithArg("--compiler-filter=", compilerFilter)
|
|
|
|
}
|
2018-11-13 02:13:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if generateDM {
|
|
|
|
cmd.FlagWithArg("--copy-dex-files=", "false")
|
2019-02-16 02:39:37 +08:00
|
|
|
dmPath := module.BuildPath.InSameDir(ctx, "generated.dm")
|
2018-11-13 02:13:39 +08:00
|
|
|
dmInstalledPath := pathtools.ReplaceExtension(module.DexLocation, "dm")
|
2019-02-16 02:39:37 +08:00
|
|
|
tmpPath := module.BuildPath.InSameDir(ctx, "primary.vdex")
|
2018-11-13 02:13:39 +08:00
|
|
|
rule.Command().Text("cp -f").Input(vdexPath).Output(tmpPath)
|
2020-01-11 04:32:59 +08:00
|
|
|
rule.Command().Tool(globalSoong.SoongZip).
|
2018-11-13 02:13:39 +08:00
|
|
|
FlagWithArg("-L", "9").
|
|
|
|
FlagWithOutput("-o", dmPath).
|
|
|
|
Flag("-j").
|
|
|
|
Input(tmpPath)
|
|
|
|
rule.Install(dmPath, dmInstalledPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
// By default, emit debug info.
|
|
|
|
debugInfo := true
|
|
|
|
if global.NoDebugInfo {
|
|
|
|
// If the global setting suppresses mini-debug-info, disable it.
|
|
|
|
debugInfo = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// PRODUCT_SYSTEM_SERVER_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO.
|
|
|
|
// PRODUCT_OTHER_JAVA_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO.
|
|
|
|
if contains(global.SystemServerJars, module.Name) {
|
|
|
|
if global.AlwaysSystemServerDebugInfo {
|
|
|
|
debugInfo = true
|
|
|
|
} else if global.NeverSystemServerDebugInfo {
|
|
|
|
debugInfo = false
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if global.AlwaysOtherDebugInfo {
|
|
|
|
debugInfo = true
|
|
|
|
} else if global.NeverOtherDebugInfo {
|
|
|
|
debugInfo = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Never enable on eng.
|
|
|
|
if global.IsEng {
|
|
|
|
debugInfo = false
|
|
|
|
}
|
|
|
|
|
|
|
|
if debugInfo {
|
|
|
|
cmd.Flag("--generate-mini-debug-info")
|
|
|
|
} else {
|
|
|
|
cmd.Flag("--no-generate-mini-debug-info")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the compiler reason to 'prebuilt' to identify the oat files produced
|
|
|
|
// during the build, as opposed to compiled on the device.
|
|
|
|
cmd.FlagWithArg("--compilation-reason=", "prebuilt")
|
|
|
|
|
|
|
|
if appImage {
|
2019-02-16 02:39:37 +08:00
|
|
|
appImagePath := odexPath.ReplaceExtension(ctx, "art")
|
2018-11-13 02:13:39 +08:00
|
|
|
appImageInstallPath := pathtools.ReplaceExtension(odexInstallPath, "art")
|
|
|
|
cmd.FlagWithOutput("--app-image-file=", appImagePath).
|
|
|
|
FlagWithArg("--image-format=", "lz4")
|
2019-04-30 00:33:50 +08:00
|
|
|
if !global.DontResolveStartupStrings {
|
|
|
|
cmd.FlagWithArg("--resolve-startup-const-strings=", "true")
|
|
|
|
}
|
2018-11-13 02:13:39 +08:00
|
|
|
rule.Install(appImagePath, appImageInstallPath)
|
|
|
|
}
|
|
|
|
|
2019-02-16 02:39:37 +08:00
|
|
|
if profile != nil {
|
|
|
|
cmd.FlagWithInput("--profile-file=", profile)
|
2018-11-13 02:13:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
rule.Install(odexPath, odexInstallPath)
|
|
|
|
rule.Install(vdexPath, vdexInstallPath)
|
|
|
|
}
|
|
|
|
|
2020-02-01 01:44:54 +08:00
|
|
|
func shouldGenerateDM(module *ModuleConfig, global *GlobalConfig) bool {
|
2018-11-13 02:13:39 +08:00
|
|
|
// Generating DM files only makes sense for verify, avoid doing for non verify compiler filter APKs.
|
|
|
|
// No reason to use a dm file if the dex is already uncompressed.
|
|
|
|
return global.GenerateDMFiles && !module.UncompressedDex &&
|
|
|
|
contains(module.PreoptFlags, "--compiler-filter=verify")
|
|
|
|
}
|
|
|
|
|
2020-02-01 01:44:54 +08:00
|
|
|
func OdexOnSystemOtherByName(name string, dexLocation string, global *GlobalConfig) bool {
|
2018-11-13 02:13:39 +08:00
|
|
|
if !global.HasSystemOther {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if global.SanitizeLite {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-12 21:12:16 +08:00
|
|
|
if contains(global.SpeedApps, name) || contains(global.SystemServerApps, name) {
|
2018-11-13 02:13:39 +08:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, f := range global.PatternsOnSystemOther {
|
2020-09-15 17:28:55 +08:00
|
|
|
if makefileMatch(filepath.Join(SystemPartition, f), dexLocation) {
|
2018-11-13 02:13:39 +08:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-02-01 01:44:54 +08:00
|
|
|
func odexOnSystemOther(module *ModuleConfig, global *GlobalConfig) bool {
|
2019-02-12 21:12:16 +08:00
|
|
|
return OdexOnSystemOtherByName(module.Name, module.DexLocation, global)
|
|
|
|
}
|
|
|
|
|
2019-02-09 13:37:00 +08:00
|
|
|
// PathToLocation converts .../system/framework/arm64/boot.art to .../system/framework/boot.art
|
2019-02-16 02:39:37 +08:00
|
|
|
func PathToLocation(path android.Path, arch android.ArchType) string {
|
|
|
|
pathArch := filepath.Base(filepath.Dir(path.String()))
|
2019-02-12 07:11:14 +08:00
|
|
|
if pathArch != arch.String() {
|
|
|
|
panic(fmt.Errorf("last directory in %q must be %q", path, arch.String()))
|
2019-02-09 13:37:00 +08:00
|
|
|
}
|
2019-02-16 02:39:37 +08:00
|
|
|
return filepath.Join(filepath.Dir(filepath.Dir(path.String())), filepath.Base(path.String()))
|
2019-02-09 13:37:00 +08:00
|
|
|
}
|
|
|
|
|
2018-11-13 02:13:39 +08:00
|
|
|
func makefileMatch(pattern, s string) bool {
|
|
|
|
percent := strings.IndexByte(pattern, '%')
|
|
|
|
switch percent {
|
|
|
|
case -1:
|
|
|
|
return pattern == s
|
|
|
|
case len(pattern) - 1:
|
|
|
|
return strings.HasPrefix(s, pattern[:len(pattern)-1])
|
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unsupported makefile pattern %q", pattern))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-03 23:39:23 +08:00
|
|
|
var nonUpdatableSystemServerJarsKey = android.NewOnceKey("nonUpdatableSystemServerJars")
|
|
|
|
|
|
|
|
// TODO: eliminate the superficial global config parameter by moving global config definition
|
|
|
|
// from java subpackage to dexpreopt.
|
2020-02-01 01:44:54 +08:00
|
|
|
func NonUpdatableSystemServerJars(ctx android.PathContext, global *GlobalConfig) []string {
|
2019-12-03 23:39:23 +08:00
|
|
|
return ctx.Config().Once(nonUpdatableSystemServerJarsKey, func() interface{} {
|
2020-07-01 21:31:13 +08:00
|
|
|
return android.RemoveListFromList(global.SystemServerJars, global.UpdatableSystemServerJars.CopyOfJars())
|
2019-12-03 23:39:23 +08:00
|
|
|
}).([]string)
|
|
|
|
}
|
|
|
|
|
2020-03-11 19:59:34 +08:00
|
|
|
// A predefined location for the system server dex jars. This is needed in order to generate
|
|
|
|
// class loader context for dex2oat, as the path to the jar in the Soong module may be unknown
|
|
|
|
// at that time (Soong processes the jars in dependency order, which may be different from the
|
|
|
|
// the system server classpath order).
|
|
|
|
func SystemServerDexJarHostPath(ctx android.PathContext, jar string) android.OutputPath {
|
2020-04-24 19:15:20 +08:00
|
|
|
if DexpreoptRunningInSoong {
|
|
|
|
// Soong module, just use the default output directory $OUT/soong.
|
|
|
|
return android.PathForOutput(ctx, "system_server_dexjars", jar+".jar")
|
|
|
|
} else {
|
|
|
|
// Make module, default output directory is $OUT (passed via the "null config" created
|
|
|
|
// by dexpreopt_gen). Append Soong subdirectory to match Soong module paths.
|
|
|
|
return android.PathForOutput(ctx, "soong", "system_server_dexjars", jar+".jar")
|
|
|
|
}
|
2020-03-11 19:59:34 +08:00
|
|
|
}
|
|
|
|
|
2020-03-27 19:30:00 +08:00
|
|
|
// Check the order of jars on the system server classpath and give a warning/error if a jar precedes
|
|
|
|
// one of its dependencies. This is not an error, but a missed optimization, as dexpreopt won't
|
|
|
|
// have the dependency jar in the class loader context, and it won't be able to resolve any
|
|
|
|
// references to its classes and methods.
|
|
|
|
func checkSystemServerOrder(ctx android.PathContext, jarIndex int) {
|
|
|
|
mctx, isModule := ctx.(android.ModuleContext)
|
|
|
|
if isModule {
|
|
|
|
config := GetGlobalConfig(ctx)
|
|
|
|
jars := NonUpdatableSystemServerJars(ctx, config)
|
|
|
|
mctx.WalkDeps(func(dep android.Module, parent android.Module) bool {
|
|
|
|
depIndex := android.IndexList(dep.Name(), jars)
|
|
|
|
if jarIndex < depIndex && !config.BrokenSuboptimalOrderOfSystemServerJars {
|
|
|
|
jar := jars[jarIndex]
|
|
|
|
dep := jars[depIndex]
|
|
|
|
mctx.ModuleErrorf("non-optimal order of jars on the system server classpath:"+
|
|
|
|
" '%s' precedes its dependency '%s', so dexpreopt is unable to resolve any"+
|
|
|
|
" references from '%s' to '%s'.\n", jar, dep, jar, dep)
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add non-fatal mode for verify_uses_libraries check.
The new mode is enabled with environment variable
RELAX_USES_LIBRARY_CHECK. If the variable is set to true, then a
verify_uses_libraries check failure does not fail the build, instead it
sets a special compiler filter "extract" for dexpreopt, which means that
the DEX file will be extracted, but it won't be compiled to native code.
Class loader context will be set to empty in this case (not &, as it is
going to be deprecated soon).
If the variable RELAX_USES_LIBRARY_CHECK is unset or set to something
other than "true", then the old behaviour of the verify_uses_libraries
check is preserved.
The intended use case for this flag is to have a smoother migration path
for the Java modules that need to add <uses-library> information in
the build files. The flag allows to quickly silence build errors. This
flag should be used with caution and only as a temporary measure, as it
masks real errors and affects performance.
verify_uses_libraries check is reworked so that it writes the error
message to a status file (which is used instead of the former timestamp
file). Currently the stored error message is not used, but it may be
used later to produce a warning. Dexpreopt command checks if the status
file exists and is nonempty; if that is the case, then compiler filter
is set to "extract".
Bug: 132357300
Test: Manually add some mismatch between the libraries in the Android.bp
and Android.mk files for dexpreopted apps, build with
RELAX_USES_LIBRARY_CHECK=true and obsserve that the build doesn't
fail and they are compiled with compiler-filter "extract".
Unset RELAX_USES_LIBRARY_CHECK and observe that the build fails.
Change-Id: Ibb5d993a25b1df1d2e70b7d5aafc6997f9d64e67
2021-02-18 00:23:28 +08:00
|
|
|
// Returns path to a file containing the reult of verify_uses_libraries check (empty if the check
|
|
|
|
// has succeeded, or an error message if it failed).
|
|
|
|
func UsesLibrariesStatusFile(ctx android.ModuleContext) android.WritablePath {
|
|
|
|
return android.PathForModuleOut(ctx, "enforce_uses_libraries.status")
|
|
|
|
}
|
|
|
|
|
2018-11-13 02:13:39 +08:00
|
|
|
func contains(l []string, s string) bool {
|
|
|
|
for _, e := range l {
|
|
|
|
if e == s {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-16 15:03:34 +08:00
|
|
|
var copyOf = android.CopyOf
|