diff options
| author | Spandan Das <spandandas@google.com> | 2024-01-31 02:59:47 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2024-01-31 02:59:47 +0000 |
| commit | 9e54c887e14d108005a28221fe7318e6c237622b (patch) | |
| tree | 04f775119ac8041717078a703ef386775e122e8e /apex | |
| parent | f4ef60c1a5724e6b5983a1a3a1ffd5a00dd4d84f (diff) | |
| parent | e0d8cb256903ec98f00050e0b96768e96393ede7 (diff) | |
Merge "Propagate profile_guided requirement of imports to top-level apex" into main am: f3c63e6743 am: e0d8cb2569
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2929189
Change-Id: I995aeca38f5691d58330e2bb99d202946a3e7540
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'apex')
| -rw-r--r-- | apex/deapexer.go | 5 | ||||
| -rw-r--r-- | apex/prebuilt.go | 11 | ||||
| -rw-r--r-- | apex/systemserver_classpath_fragment_test.go | 20 |
3 files changed, 26 insertions, 10 deletions
diff --git a/apex/deapexer.go b/apex/deapexer.go index 5ff622c5b..a6731080c 100644 --- a/apex/deapexer.go +++ b/apex/deapexer.go @@ -53,6 +53,10 @@ type DeapexerProperties struct { // all architectures, e.g. java. CommonModules []string + // List of modules that use an embedded .prof to guide optimization of the equivalent dexpreopt artifact + // This is a subset of CommonModules + DexpreoptProfileGuidedModules []string + // List of files exported from the .apex file by this module // // Each entry is a path from the apex root, e.g. javalib/core-libart.jar. @@ -128,6 +132,7 @@ func (p *Deapexer) GenerateAndroidBuildActions(ctx android.ModuleContext) { if len(exports) > 0 { // Make the information available for other modules. di := android.NewDeapexerInfo(apexModuleName(ctx.ModuleName()), exports, p.properties.CommonModules) + di.AddDexpreoptProfileGuidedExportedModuleNames(p.properties.DexpreoptProfileGuidedModules...) android.SetProvider(ctx, android.DeapexerProvider, di) // Create a sorted list of the files that this exports. diff --git a/apex/prebuilt.go b/apex/prebuilt.go index 551942d31..399d9b92f 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -629,6 +629,7 @@ func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutator // Compute the deapexer properties from the transitive dependencies of this module. commonModules := []string{} + dexpreoptProfileGuidedModules := []string{} exportedFiles := []string{} ctx.WalkDeps(func(child, parent android.Module) bool { tag := ctx.OtherModuleDependencyTag(child) @@ -642,9 +643,14 @@ func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutator if _, ok := tag.(android.RequiresFilesFromPrebuiltApexTag); ok { commonModules = append(commonModules, name) - requiredFiles := child.(android.RequiredFilesFromPrebuiltApex).RequiredFilesFromPrebuiltApex(ctx) + extract := child.(android.RequiredFilesFromPrebuiltApex) + requiredFiles := extract.RequiredFilesFromPrebuiltApex(ctx) exportedFiles = append(exportedFiles, requiredFiles...) + if extract.UseProfileGuidedDexpreopt() { + dexpreoptProfileGuidedModules = append(dexpreoptProfileGuidedModules, name) + } + // Visit the dependencies of this module just in case they also require files from the // prebuilt apex. return true @@ -657,7 +663,8 @@ func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutator deapexerProperties := &DeapexerProperties{ // Remove any duplicates from the common modules lists as a module may be included via a direct // dependency as well as transitive ones. - CommonModules: android.SortedUniqueStrings(commonModules), + CommonModules: android.SortedUniqueStrings(commonModules), + DexpreoptProfileGuidedModules: android.SortedUniqueStrings(dexpreoptProfileGuidedModules), } // Populate the exported files property in a fixed order. diff --git a/apex/systemserver_classpath_fragment_test.go b/apex/systemserver_classpath_fragment_test.go index 6b2c39777..f6c53b270 100644 --- a/apex/systemserver_classpath_fragment_test.go +++ b/apex/systemserver_classpath_fragment_test.go @@ -221,8 +221,6 @@ func TestSystemServerClasspathFragmentWithContentNotInMake(t *testing.T) { } func TestPrebuiltSystemserverclasspathFragmentContents(t *testing.T) { - // TODO(spandandas): Fix the rules for profile guided dexpreopt of deapexed prebuilt jars - t.Skip() result := android.GroupFixturePreparers( prepareForTestWithSystemserverclasspathFragment, prepareForTestWithMyapex, @@ -294,8 +292,8 @@ func TestPrebuiltSystemserverclasspathFragmentContents(t *testing.T) { "javalib/bar.jar.prof", }) - assertProfileGuided(t, ctx, "foo", "android_common_myapex", false) - assertProfileGuided(t, ctx, "bar", "android_common_myapex", true) + assertProfileGuidedPrebuilt(t, ctx, "myapex", "foo", false) + assertProfileGuidedPrebuilt(t, ctx, "myapex", "bar", true) } func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) { @@ -381,8 +379,6 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) { } func TestPrebuiltStandaloneSystemserverclasspathFragmentContents(t *testing.T) { - // TODO(spandandas): Fix the rules for profile guided dexpreopt of deapexed prebuilt jars - t.Skip() result := android.GroupFixturePreparers( prepareForTestWithSystemserverclasspathFragment, prepareForTestWithMyapex, @@ -447,8 +443,8 @@ func TestPrebuiltStandaloneSystemserverclasspathFragmentContents(t *testing.T) { "javalib/bar.jar.prof", }) - assertProfileGuided(t, ctx, "foo", "android_common_myapex", false) - assertProfileGuided(t, ctx, "bar", "android_common_myapex", true) + assertProfileGuidedPrebuilt(t, ctx, "myapex", "foo", false) + assertProfileGuidedPrebuilt(t, ctx, "myapex", "bar", true) } func assertProfileGuided(t *testing.T, ctx *android.TestContext, moduleName string, variant string, expected bool) { @@ -458,3 +454,11 @@ func assertProfileGuided(t *testing.T, ctx *android.TestContext, moduleName stri t.Fatalf("Expected profile-guided to be %v, got %v", expected, actual) } } + +func assertProfileGuidedPrebuilt(t *testing.T, ctx *android.TestContext, apexName string, moduleName string, expected bool) { + dexpreopt := ctx.ModuleForTests(apexName, "android_common_"+apexName).Rule("dexpreopt." + moduleName) + actual := strings.Contains(dexpreopt.RuleParams.Command, "--profile-file=") + if expected != actual { + t.Fatalf("Expected profile-guided to be %v, got %v", expected, actual) + } +} |
