Merge "jacoco correctly gathers info from APK-in-APEX"
diff --git a/apex/androidmk.go b/apex/androidmk.go
index b5c5331..5cdbcd6 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -216,8 +216,8 @@
if len(moduleNames) > 0 {
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " "))
}
- if len(a.externalDeps) > 0 {
- fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.externalDeps, " "))
+ if len(a.requiredDeps) > 0 {
+ fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.requiredDeps, " "))
}
a.writeRequiredModules(w)
var postInstallCommands []string
diff --git a/apex/apex.go b/apex/apex.go
index 75a6053..b6599d2 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -520,8 +520,13 @@
// list of files to be included in this apex
filesInfo []apexFile
- // list of module names that this APEX is depending on
+ // list of module names that should be installed along with this APEX
+ requiredDeps []string
+
+ // list of module names that this APEX is depending on (to be shown via *-deps-info target)
externalDeps []string
+ // list of module names that this APEX is including (to be shown via *-deps-info target)
+ internalDeps []string
testApex bool
vndkApex bool
@@ -701,6 +706,12 @@
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
javaLibTag, a.properties.Java_libs...)
+ // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
+ if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
+ ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
+ javaLibTag, "jacocoagent")
+ }
+
if String(a.properties.Key) == "" {
ctx.ModuleErrorf("key is missing")
return
@@ -939,7 +950,7 @@
a.primaryApexType = true
if ctx.Config().InstallExtraFlattenedApexes() {
- a.externalDeps = append(a.externalDeps, a.Name()+flattenedSuffix)
+ a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
}
}
case zipApex:
@@ -998,6 +1009,9 @@
depTag := ctx.OtherModuleDependencyTag(child)
depName := ctx.OtherModuleName(child)
if _, isDirectDep := parent.(*apexBundle); isDirectDep {
+ if depTag != keyTag && depTag != certificateTag {
+ a.internalDeps = append(a.internalDeps, depName)
+ }
switch depTag {
case sharedLibTag:
if cc, ok := child.(*cc.Module); ok {
@@ -1128,9 +1142,10 @@
//
// Always include if we are a host-apex however since those won't have any
// system libraries.
- if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.externalDeps) {
- a.externalDeps = append(a.externalDeps, cc.Name())
+ if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.requiredDeps) {
+ a.requiredDeps = append(a.requiredDeps, cc.Name())
}
+ a.externalDeps = append(a.externalDeps, depName)
requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
// Don't track further
return false
@@ -1138,6 +1153,8 @@
af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
af.transitiveDep = true
filesInfo = append(filesInfo, af)
+ a.internalDeps = append(a.internalDeps, depName)
+ a.internalDeps = append(a.internalDeps, cc.AllStaticDeps()...)
return true // track transitive dependencies
}
} else if cc.IsTestPerSrcDepTag(depTag) {
@@ -1153,8 +1170,10 @@
return true // track transitive dependencies
}
} else if java.IsJniDepTag(depTag) {
- // Do nothing for JNI dep. JNI libraries are always embedded in APK-in-APEX.
+ a.externalDeps = append(a.externalDeps, depName)
return true
+ } else if java.IsStaticLibDepTag(depTag) {
+ a.internalDeps = append(a.internalDeps, depName)
} else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
}
@@ -1252,6 +1271,7 @@
apexName := proptools.StringDefault(a.properties.Apex_name, a.Name())
a.compatSymlinks = makeCompatSymlinks(apexName, ctx)
+ a.buildApexDependencyInfo(ctx)
}
func newApexBundle() *apexBundle {
diff --git a/apex/apex_test.go b/apex/apex_test.go
index cc346e9..b37674f 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -219,6 +219,7 @@
"apex_manifest.json": nil,
"AndroidManifest.xml": nil,
"system/sepolicy/apex/myapex-file_contexts": nil,
+ "system/sepolicy/apex/myapex2-file_contexts": nil,
"system/sepolicy/apex/otherapex-file_contexts": nil,
"system/sepolicy/apex/commonapex-file_contexts": nil,
"system/sepolicy/apex/com.android.vndk-file_contexts": nil,
@@ -520,6 +521,12 @@
}
ensureListContains(t, noticeInputs, "NOTICE")
ensureListContains(t, noticeInputs, "custom_notice")
+
+ depsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("myapex-deps-info.txt").Args["content"], "\\n")
+ ensureListContains(t, depsInfo, "internal myjar")
+ ensureListContains(t, depsInfo, "internal mylib")
+ ensureListContains(t, depsInfo, "internal mylib2")
+ ensureListContains(t, depsInfo, "internal myotherjar")
}
func TestDefaults(t *testing.T) {
@@ -740,13 +747,13 @@
func TestApexWithExplicitStubsDependency(t *testing.T) {
ctx, _ := testApex(t, `
apex {
- name: "myapex",
- key: "myapex.key",
+ name: "myapex2",
+ key: "myapex2.key",
native_shared_libs: ["mylib"],
}
apex_key {
- name: "myapex.key",
+ name: "myapex2.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
@@ -779,7 +786,7 @@
`)
- apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule")
+ apexRule := ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
// Ensure that direct non-stubs dep is always included
@@ -791,7 +798,7 @@
// Ensure that dependency of stubs is not included
ensureNotContains(t, copyCmds, "image.apex/lib64/libbar.so")
- mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_myapex").Rule("ld").Args["libFlags"]
+ mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_myapex2").Rule("ld").Args["libFlags"]
// Ensure that mylib is linking with version 10 of libfoo
ensureContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_shared_10/libfoo.so")
@@ -802,6 +809,12 @@
// Ensure that libfoo stubs is not linking to libbar (since it is a stubs)
ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
+
+ depsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("myapex2-deps-info.txt").Args["content"], "\\n")
+ ensureListContains(t, depsInfo, "internal mylib")
+ ensureListContains(t, depsInfo, "external libfoo")
+ ensureListNotContains(t, depsInfo, "internal libfoo")
+ ensureListNotContains(t, depsInfo, "external mylib")
}
func TestApexWithRuntimeLibsDependency(t *testing.T) {
@@ -2652,7 +2665,7 @@
config.TestProductVariables.InstallExtraFlattenedApexes = proptools.BoolPtr(true)
})
ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
- ensureListContains(t, ab.externalDeps, "myapex.flattened")
+ ensureListContains(t, ab.requiredDeps, "myapex.flattened")
mk := android.AndroidMkDataForTest(t, config, "", ab)
var builder strings.Builder
mk.Custom(&builder, ab.Name(), "TARGET_", "", mk)
diff --git a/apex/builder.go b/apex/builder.go
index 4a760b9..ae90ce6 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -554,3 +554,40 @@
}
return ""
}
+
+func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) {
+ if !a.primaryApexType {
+ return
+ }
+
+ internalDeps := a.internalDeps
+ externalDeps := a.externalDeps
+
+ internalDeps = android.SortedUniqueStrings(internalDeps)
+ externalDeps = android.SortedUniqueStrings(externalDeps)
+ externalDeps = android.RemoveListFromList(externalDeps, internalDeps)
+
+ var content strings.Builder
+ for _, name := range internalDeps {
+ fmt.Fprintf(&content, "internal %s\\n", name)
+ }
+ for _, name := range externalDeps {
+ fmt.Fprintf(&content, "external %s\\n", name)
+ }
+
+ depsInfoFile := android.PathForOutput(ctx, a.Name()+"-deps-info.txt")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.WriteFile,
+ Description: "Dependency Info",
+ Output: depsInfoFile,
+ Args: map[string]string{
+ "content": content.String(),
+ },
+ })
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Phony,
+ Output: android.PathForPhony(ctx, a.Name()+"-deps-info"),
+ Inputs: []android.Path{depsInfoFile},
+ })
+}
diff --git a/cc/cc.go b/cc/cc.go
index 0c32225..0bab41f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -398,6 +398,13 @@
return ok && ccDepTag.Shared
}
+func IsStaticDepTag(depTag blueprint.DependencyTag) bool {
+ ccDepTag, ok := depTag.(DependencyTag)
+ return ok && (ccDepTag == staticExportDepTag ||
+ ccDepTag == lateStaticDepTag ||
+ ccDepTag == wholeStaticDepTag)
+}
+
func IsRuntimeDepTag(depTag blueprint.DependencyTag) bool {
ccDepTag, ok := depTag.(DependencyTag)
return ok && ccDepTag == runtimeDepTag
@@ -463,6 +470,9 @@
makeLinkType string
// Kythe (source file indexer) paths for this compilation module
kytheFiles android.Paths
+
+ // name of the modules that are direct or indirect static deps of this module
+ allStaticDeps []string
}
func (c *Module) Toc() android.OptionalPath {
@@ -1258,6 +1268,15 @@
return results
}
+func gatherTransitiveStaticDeps(staticDeps []LinkableInterface) []string {
+ var ret []string
+ for _, dep := range staticDeps {
+ ret = append(ret, dep.Module().Name())
+ ret = append(ret, dep.AllStaticDeps()...)
+ }
+ return android.FirstUniqueStrings(ret)
+}
+
func (c *Module) IsTestPerSrcAllTestsVariation() bool {
test, ok := c.linker.(testPerSrc)
return ok && test.isAllTestsVariation()
@@ -2328,6 +2347,8 @@
c.sabi.Properties.ReexportedIncludes = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludes)
}
+ c.allStaticDeps = gatherTransitiveStaticDeps(directStaticDeps)
+
return depPaths
}
@@ -2463,6 +2484,10 @@
return c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid()
}
+func (c *Module) AllStaticDeps() []string {
+ return c.allStaticDeps
+}
+
func (c *Module) AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
if c.linker != nil {
if library, ok := c.linker.(*libraryDecorator); ok {
diff --git a/cc/linkable.go b/cc/linkable.go
index 815d405..106092b 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -51,6 +51,8 @@
ToolchainLibrary() bool
NdkPrebuiltStl() bool
StubDecorator() bool
+
+ AllStaticDeps() []string
}
type DependencyTag struct {
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 83e3673..0c79ccc 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -22,7 +22,9 @@
"android/soong/android"
)
-// GlobalConfig stores the configuration for dex preopting set by the product
+// GlobalConfig stores the configuration for dex preopting. The fields are set
+// from product variables via dex_preopt_config.mk, except for SoongConfig
+// which come from CreateGlobalSoongConfig.
type GlobalConfig struct {
DisablePreopt bool // disable preopt for all modules
DisablePreoptModules []string // modules with preopt disabled by product-specific config
@@ -82,19 +84,19 @@
Dex2oatImageXmx string // max heap size for dex2oat for the boot image
Dex2oatImageXms string // initial heap size for dex2oat for the boot image
- Tools Tools // paths to tools possibly used by the generated commands
+ SoongConfig GlobalSoongConfig // settings read from dexpreopt_soong.config
}
-// Tools contains paths to tools possibly used by the generated commands. If you add a new tool here you MUST add it
-// to the order-only dependency list in DEXPREOPT_GEN_DEPS.
-type Tools struct {
- Profman android.Path
- Dex2oat android.Path
- Aapt android.Path
- SoongZip android.Path
- Zip2zip android.Path
- ManifestCheck android.Path
-
+// GlobalSoongConfig contains the global config that is generated from Soong,
+// stored in dexpreopt_soong.config.
+type GlobalSoongConfig struct {
+ // Paths to tools possibly used by the generated commands.
+ Profman android.Path
+ Dex2oat android.Path
+ Aapt android.Path
+ SoongZip android.Path
+ Zip2zip android.Path
+ ManifestCheck android.Path
ConstructContext android.Path
}
@@ -133,6 +135,17 @@
PresignedPrebuilt bool
}
+type globalSoongConfigSingleton struct{}
+
+var pctx = android.NewPackageContext("android/soong/dexpreopt")
+
+func init() {
+ pctx.Import("android/soong/android")
+ android.RegisterSingletonType("dexpreopt-soong-config", func() android.Singleton {
+ return &globalSoongConfigSingleton{}
+ })
+}
+
func constructPath(ctx android.PathContext, path string) android.Path {
buildDirPrefix := ctx.Config().BuildDir() + "/"
if path == "" {
@@ -167,9 +180,12 @@
return constructPath(ctx, path).(android.WritablePath)
}
-// LoadGlobalConfig reads the global dexpreopt.config file into a GlobalConfig struct. It is used directly in Soong
-// and in dexpreopt_gen called from Make to read the $OUT/dexpreopt.config written by Make.
-func LoadGlobalConfig(ctx android.PathContext, path string) (GlobalConfig, []byte, error) {
+// LoadGlobalConfig reads the global dexpreopt.config file into a GlobalConfig
+// struct, except the SoongConfig field which is set from the provided
+// soongConfig argument. LoadGlobalConfig is used directly in Soong and in
+// dexpreopt_gen called from Make to read the $OUT/dexpreopt.config written by
+// Make.
+func LoadGlobalConfig(ctx android.PathContext, path string, soongConfig GlobalSoongConfig) (GlobalConfig, []byte, error) {
type GlobalJSONConfig struct {
GlobalConfig
@@ -177,17 +193,6 @@
// used to construct the real value manually below.
DirtyImageObjects string
BootImageProfiles []string
-
- Tools struct {
- Profman string
- Dex2oat string
- Aapt string
- SoongZip string
- Zip2zip string
- ManifestCheck string
-
- ConstructContext string
- }
}
config := GlobalJSONConfig{}
@@ -200,13 +205,9 @@
config.GlobalConfig.DirtyImageObjects = android.OptionalPathForPath(constructPath(ctx, config.DirtyImageObjects))
config.GlobalConfig.BootImageProfiles = constructPaths(ctx, config.BootImageProfiles)
- config.GlobalConfig.Tools.Profman = constructPath(ctx, config.Tools.Profman)
- config.GlobalConfig.Tools.Dex2oat = constructPath(ctx, config.Tools.Dex2oat)
- config.GlobalConfig.Tools.Aapt = constructPath(ctx, config.Tools.Aapt)
- config.GlobalConfig.Tools.SoongZip = constructPath(ctx, config.Tools.SoongZip)
- config.GlobalConfig.Tools.Zip2zip = constructPath(ctx, config.Tools.Zip2zip)
- config.GlobalConfig.Tools.ManifestCheck = constructPath(ctx, config.Tools.ManifestCheck)
- config.GlobalConfig.Tools.ConstructContext = constructPath(ctx, config.Tools.ConstructContext)
+ // Set this here to force the caller to provide a value for this struct (from
+ // either CreateGlobalSoongConfig or LoadGlobalSoongConfig).
+ config.GlobalConfig.SoongConfig = soongConfig
return config.GlobalConfig, data, nil
}
@@ -253,6 +254,104 @@
return config.ModuleConfig, nil
}
+// CreateGlobalSoongConfig creates a GlobalSoongConfig from the current context.
+// Should not be used in dexpreopt_gen.
+func CreateGlobalSoongConfig(ctx android.PathContext) GlobalSoongConfig {
+ // Default to debug version to help find bugs.
+ // Set USE_DEX2OAT_DEBUG to false for only building non-debug versions.
+ var dex2oatBinary string
+ if ctx.Config().Getenv("USE_DEX2OAT_DEBUG") == "false" {
+ dex2oatBinary = "dex2oat"
+ } else {
+ dex2oatBinary = "dex2oatd"
+ }
+
+ return GlobalSoongConfig{
+ Profman: ctx.Config().HostToolPath(ctx, "profman"),
+ Dex2oat: ctx.Config().HostToolPath(ctx, dex2oatBinary),
+ Aapt: ctx.Config().HostToolPath(ctx, "aapt"),
+ SoongZip: ctx.Config().HostToolPath(ctx, "soong_zip"),
+ Zip2zip: ctx.Config().HostToolPath(ctx, "zip2zip"),
+ ManifestCheck: ctx.Config().HostToolPath(ctx, "manifest_check"),
+ ConstructContext: android.PathForSource(ctx, "build/make/core/construct_context.sh"),
+ }
+}
+
+type globalJsonSoongConfig struct {
+ Profman string
+ Dex2oat string
+ Aapt string
+ SoongZip string
+ Zip2zip string
+ ManifestCheck string
+ ConstructContext string
+}
+
+// LoadGlobalSoongConfig reads the dexpreopt_soong.config file into a
+// GlobalSoongConfig struct. It is only used in dexpreopt_gen.
+func LoadGlobalSoongConfig(ctx android.PathContext, path string) (GlobalSoongConfig, error) {
+ var jc globalJsonSoongConfig
+
+ _, err := loadConfig(ctx, path, &jc)
+ if err != nil {
+ return GlobalSoongConfig{}, err
+ }
+
+ config := GlobalSoongConfig{
+ Profman: constructPath(ctx, jc.Profman),
+ Dex2oat: constructPath(ctx, jc.Dex2oat),
+ Aapt: constructPath(ctx, jc.Aapt),
+ SoongZip: constructPath(ctx, jc.SoongZip),
+ Zip2zip: constructPath(ctx, jc.Zip2zip),
+ ManifestCheck: constructPath(ctx, jc.ManifestCheck),
+ ConstructContext: constructPath(ctx, jc.ConstructContext),
+ }
+
+ return config, nil
+}
+
+func (s *globalSoongConfigSingleton) GenerateBuildActions(ctx android.SingletonContext) {
+ config := CreateGlobalSoongConfig(ctx)
+ jc := globalJsonSoongConfig{
+ Profman: config.Profman.String(),
+ Dex2oat: config.Dex2oat.String(),
+ Aapt: config.Aapt.String(),
+ SoongZip: config.SoongZip.String(),
+ Zip2zip: config.Zip2zip.String(),
+ ManifestCheck: config.ManifestCheck.String(),
+ ConstructContext: config.ConstructContext.String(),
+ }
+
+ data, err := json.Marshal(jc)
+ if err != nil {
+ ctx.Errorf("failed to JSON marshal GlobalSoongConfig: %v", err)
+ return
+ }
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.WriteFile,
+ Output: android.PathForOutput(ctx, "dexpreopt_soong.config"),
+ Args: map[string]string{
+ "content": string(data),
+ },
+ })
+}
+
+func (s *globalSoongConfigSingleton) MakeVars(ctx android.MakeVarsContext) {
+ config := CreateGlobalSoongConfig(ctx)
+
+ ctx.Strict("DEX2OAT", config.Dex2oat.String())
+ ctx.Strict("DEXPREOPT_GEN_DEPS", strings.Join([]string{
+ config.Profman.String(),
+ config.Dex2oat.String(),
+ config.Aapt.String(),
+ config.SoongZip.String(),
+ config.Zip2zip.String(),
+ config.ManifestCheck.String(),
+ config.ConstructContext.String(),
+ }, " "))
+}
+
func loadConfig(ctx android.PathContext, path string, config interface{}) ([]byte, error) {
r, err := ctx.Fs().Open(path)
if err != nil {
@@ -312,7 +411,7 @@
BootFlags: "",
Dex2oatImageXmx: "",
Dex2oatImageXms: "",
- Tools: Tools{
+ SoongConfig: GlobalSoongConfig{
Profman: android.PathForTesting("profman"),
Dex2oat: android.PathForTesting("dex2oat"),
Aapt: android.PathForTesting("aapt"),
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index ee04dfd..ac5b691 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -131,7 +131,7 @@
cmd := rule.Command().
Text(`ANDROID_LOG_TAGS="*:e"`).
- Tool(global.Tools.Profman)
+ Tool(global.SoongConfig.Profman)
if module.ProfileIsTextListing {
// The profile is a test listing of classes (used for framework jars).
@@ -170,7 +170,7 @@
cmd := rule.Command().
Text(`ANDROID_LOG_TAGS="*:e"`).
- Tool(global.Tools.Profman)
+ Tool(global.SoongConfig.Profman)
// The profile is a test listing of methods.
// We need to generate the actual binary profile.
@@ -299,14 +299,14 @@
if module.EnforceUsesLibraries {
if module.ManifestPath != nil {
rule.Command().Text(`target_sdk_version="$(`).
- Tool(global.Tools.ManifestCheck).
+ Tool(global.SoongConfig.ManifestCheck).
Flag("--extract-target-sdk-version").
Input(module.ManifestPath).
Text(`)"`)
} else {
// No manifest to extract targetSdkVersion from, hope that DexJar is an APK
rule.Command().Text(`target_sdk_version="$(`).
- Tool(global.Tools.Aapt).
+ Tool(global.SoongConfig.Aapt).
Flag("dump badging").
Input(module.DexPath).
Text(`| grep "targetSdkVersion" | sed -n "s/targetSdkVersion:'\(.*\)'/\1/p"`).
@@ -327,7 +327,7 @@
Implicits(conditionalClassLoaderContextHost29)
rule.Command().Textf(`conditional_target_libs_29="%s"`,
strings.Join(conditionalClassLoaderContextTarget29, " "))
- rule.Command().Text("source").Tool(global.Tools.ConstructContext).Input(module.DexPath)
+ rule.Command().Text("source").Tool(global.SoongConfig.ConstructContext).Input(module.DexPath)
}
// Devices that do not have a product partition use a symlink from /product to /system/product.
@@ -340,7 +340,7 @@
cmd := rule.Command().
Text(`ANDROID_LOG_TAGS="*:e"`).
- Tool(global.Tools.Dex2oat).
+ Tool(global.SoongConfig.Dex2oat).
Flag("--avoid-storing-invocation").
FlagWithOutput("--write-invocation-to=", invocationPath).ImplicitOutput(invocationPath).
Flag("--runtime-arg").FlagWithArg("-Xms", global.Dex2oatXms).
@@ -409,7 +409,7 @@
dmInstalledPath := pathtools.ReplaceExtension(module.DexLocation, "dm")
tmpPath := module.BuildPath.InSameDir(ctx, "primary.vdex")
rule.Command().Text("cp -f").Input(vdexPath).Output(tmpPath)
- rule.Command().Tool(global.Tools.SoongZip).
+ rule.Command().Tool(global.SoongConfig.SoongZip).
FlagWithArg("-L", "9").
FlagWithOutput("-o", dmPath).
Flag("-j").
diff --git a/dexpreopt/dexpreopt_gen/dexpreopt_gen.go b/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
index 6f51080..d2faa00 100644
--- a/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
+++ b/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
@@ -30,10 +30,11 @@
)
var (
- dexpreoptScriptPath = flag.String("dexpreopt_script", "", "path to output dexpreopt script")
- globalConfigPath = flag.String("global", "", "path to global configuration file")
- moduleConfigPath = flag.String("module", "", "path to module configuration file")
- outDir = flag.String("out_dir", "", "path to output directory")
+ dexpreoptScriptPath = flag.String("dexpreopt_script", "", "path to output dexpreopt script")
+ globalSoongConfigPath = flag.String("global_soong", "", "path to global configuration file for settings originating from Soong")
+ globalConfigPath = flag.String("global", "", "path to global configuration file")
+ moduleConfigPath = flag.String("module", "", "path to module configuration file")
+ outDir = flag.String("out_dir", "", "path to output directory")
)
type pathContext struct {
@@ -63,17 +64,27 @@
usage("path to output dexpreopt script is required")
}
+ if *globalSoongConfigPath == "" {
+ usage("--global_soong configuration file is required")
+ }
+
if *globalConfigPath == "" {
- usage("path to global configuration file is required")
+ usage("--global configuration file is required")
}
if *moduleConfigPath == "" {
- usage("path to module configuration file is required")
+ usage("--module configuration file is required")
}
ctx := &pathContext{android.TestConfig(*outDir, nil, "", nil)}
- globalConfig, _, err := dexpreopt.LoadGlobalConfig(ctx, *globalConfigPath)
+ globalSoongConfig, err := dexpreopt.LoadGlobalSoongConfig(ctx, *globalSoongConfigPath)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "error loading global config %q: %s\n", *globalSoongConfigPath, err)
+ os.Exit(2)
+ }
+
+ globalConfig, _, err := dexpreopt.LoadGlobalConfig(ctx, *globalConfigPath, globalSoongConfig)
if err != nil {
fmt.Fprintf(os.Stderr, "error loading global config %q: %s\n", *globalConfigPath, err)
os.Exit(2)
@@ -121,7 +132,7 @@
dexpreoptRule.Command().Text("mkdir -p").Flag(filepath.Dir(installPath.String()))
dexpreoptRule.Command().Text("cp -f").Input(install.From).Output(installPath)
}
- dexpreoptRule.Command().Tool(global.Tools.SoongZip).
+ dexpreoptRule.Command().Tool(global.SoongConfig.SoongZip).
FlagWithArg("-o ", "$2").
FlagWithArg("-C ", installDir.String()).
FlagWithArg("-D ", installDir.String())
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 8308254..fe5bed5 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -178,12 +178,6 @@
return false
}
-func skipDexpreoptArtBootJars(ctx android.BuilderContext) bool {
- // with EMMA_INSTRUMENT_FRAMEWORK=true ART boot class path libraries have dependencies on framework,
- // therefore dexpreopt ART libraries cannot be dexpreopted in isolation => no ART boot image
- return ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK")
-}
-
type dexpreoptBootJars struct {
defaultBootImage *bootImage
otherImages []*bootImage
@@ -193,7 +187,7 @@
// Accessor function for the apex package. Returns nil if dexpreopt is disabled.
func DexpreoptedArtApexJars(ctx android.BuilderContext) map[android.ArchType]android.OutputPaths {
- if skipDexpreoptBootJars(ctx) || skipDexpreoptArtBootJars(ctx) {
+ if skipDexpreoptBootJars(ctx) {
return nil
}
return artBootImageConfig(ctx).imagesDeps
@@ -222,10 +216,8 @@
// Always create the default boot image first, to get a unique profile rule for all images.
d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
- if !skipDexpreoptArtBootJars(ctx) {
- // 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)))
- }
+ // 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)))
if global.GenerateApexImage {
// Create boot images for the JIT-zygote experiment.
d.otherImages = append(d.otherImages, buildBootImage(ctx, apexBootImageConfig(ctx)))
@@ -335,7 +327,7 @@
invocationPath := outputPath.ReplaceExtension(ctx, "invocation")
- cmd.Tool(global.Tools.Dex2oat).
+ cmd.Tool(global.SoongConfig.Dex2oat).
Flag("--avoid-storing-invocation").
FlagWithOutput("--write-invocation-to=", invocationPath).ImplicitOutput(invocationPath).
Flag("--runtime-arg").FlagWithArg("-Xms", global.Dex2oatImageXms).
@@ -444,7 +436,6 @@
return nil
}
profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
- tools := global.Tools
defaultProfile := "frameworks/base/config/boot-image-profile.txt"
rule := android.NewRuleBuilder()
@@ -470,7 +461,7 @@
rule.Command().
Text(`ANDROID_LOG_TAGS="*:e"`).
- Tool(tools.Profman).
+ Tool(global.SoongConfig.Profman).
FlagWithInput("--create-profile-from=", bootImageProfile).
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
FlagForEachArg("--dex-location=", image.dexLocationsDeps).
@@ -499,8 +490,6 @@
return nil
}
return ctx.Config().Once(bootFrameworkProfileRuleKey, func() interface{} {
- tools := global.Tools
-
rule := android.NewRuleBuilder()
rule.MissingDeps(missingDeps)
@@ -521,7 +510,7 @@
rule.Command().
Text(`ANDROID_LOG_TAGS="*:e"`).
- Tool(tools.Profman).
+ Tool(global.SoongConfig.Profman).
Flag("--generate-boot-profile").
FlagWithInput("--create-profile-from=", bootFrameworkProfile).
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
@@ -598,6 +587,7 @@
func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
if d.dexpreoptConfigForMake != nil {
ctx.Strict("DEX_PREOPT_CONFIG_FOR_MAKE", d.dexpreoptConfigForMake.String())
+ ctx.Strict("DEX_PREOPT_SOONG_CONFIG_FOR_MAKE", android.PathForOutput(ctx, "dexpreopt_soong.config").String())
}
image := d.defaultBootImage
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index 91e0dfb..35748b8 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -37,8 +37,9 @@
func dexpreoptGlobalConfigRaw(ctx android.PathContext) globalConfigAndRaw {
return ctx.Config().Once(dexpreoptGlobalConfigKey, func() interface{} {
if f := ctx.Config().DexpreoptGlobalConfig(); f != "" {
+ soongConfig := dexpreopt.CreateGlobalSoongConfig(ctx)
ctx.AddNinjaFileDeps(f)
- globalConfig, data, err := dexpreopt.LoadGlobalConfig(ctx, f)
+ globalConfig, data, err := dexpreopt.LoadGlobalConfig(ctx, f, soongConfig)
if err != nil {
panic(err)
}
@@ -135,6 +136,10 @@
deviceDir := android.PathForOutput(ctx, ctx.Config().DeviceName())
artModules := global.ArtApexJars
+ // With EMMA_INSTRUMENT_FRAMEWORK=true the Core libraries depend on jacoco.
+ if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
+ artModules = append(artModules, "jacocoagent")
+ }
frameworkModules := android.RemoveListFromList(global.BootJars,
concat(artModules, getJarsFromApexJarPairs(global.UpdatableBootJars)))
diff --git a/java/java.go b/java/java.go
index bfdc7fc..50ffd65 100644
--- a/java/java.go
+++ b/java/java.go
@@ -500,6 +500,14 @@
usesLibTag = dependencyTag{name: "uses-library"}
)
+func IsLibDepTag(depTag blueprint.DependencyTag) bool {
+ return depTag == libTag
+}
+
+func IsStaticLibDepTag(depTag blueprint.DependencyTag) bool {
+ return depTag == staticLibTag
+}
+
type sdkDep struct {
useModule, useFiles, useDefaultLibs, invalidVersion bool
diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go
index 715485f..d5c7579 100644
--- a/java/platform_compat_config.go
+++ b/java/platform_compat_config.go
@@ -80,6 +80,12 @@
p.metadata = outputPath
}
+func (p *platformCompatConfigSingleton) MakeVars(ctx android.MakeVarsContext) {
+ if p.metadata != nil {
+ ctx.Strict("INTERNAL_PLATFORM_MERGED_COMPAT_CONFIG", p.metadata.String())
+ }
+}
+
func (p *platformCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) {
rule := android.NewRuleBuilder()
diff --git a/rust/rust.go b/rust/rust.go
index 0eab8d2..14513fb 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -346,6 +346,11 @@
return nil
}
+func (mod *Module) AllStaticDeps() []string {
+ // TODO(jiyong): do this for rust?
+ return nil
+}
+
func (mod *Module) Module() android.Module {
return mod
}