Consolidate the code to resolve a deapexer module dependency.
It will get more logic in upcoming CLs.
Add a property to DeapexerInfo for the APEX name, for use in error
messages.
Test: m nothing
Bug: 192006406
Change-Id: I957f3df8b34543a38cde38768dac93e78132d672
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 1f9bd5a..420489e 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4859,8 +4859,11 @@
// Make sure that dexpreopt can access dex implementation files from the prebuilt.
ctx := testDexpreoptWithApexes(t, bp, "", transform)
+ deapexerName := deapexerModuleName("myapex")
+ android.AssertStringEquals(t, "APEX module name from deapexer name", "myapex", apexModuleName(deapexerName))
+
// Make sure that the deapexer has the correct input APEX.
- deapexer := ctx.ModuleForTests("myapex.deapexer", "android_common")
+ deapexer := ctx.ModuleForTests(deapexerName, "android_common")
rule := deapexer.Rule("deapexer")
if expected, actual := []string{"myapex-arm64.apex"}, android.NormalizePathsForTesting(rule.Implicits); !reflect.DeepEqual(expected, actual) {
t.Errorf("expected: %q, found: %q", expected, actual)
diff --git a/apex/deapexer.go b/apex/deapexer.go
index 2c1835a..8c9030a 100644
--- a/apex/deapexer.go
+++ b/apex/deapexer.go
@@ -15,6 +15,8 @@
package apex
import (
+ "strings"
+
"android/soong/android"
)
@@ -75,6 +77,17 @@
inputApex android.Path
}
+// Returns the name of the deapexer module corresponding to an APEX module with the given name.
+func deapexerModuleName(apexModuleName string) string {
+ return apexModuleName + ".deapexer"
+}
+
+// Returns the name of the APEX module corresponding to an deapexer module with
+// the given name. This reverses deapexerModuleName.
+func apexModuleName(deapexerModuleName string) string {
+ return strings.TrimSuffix(deapexerModuleName, ".deapexer")
+}
+
func privateDeapexerFactory() android.Module {
module := &Deapexer{}
module.AddProperties(&module.properties, &module.selectedApexProperties)
@@ -113,7 +126,8 @@
// apex relative path to extracted file path available for other modules.
if len(exports) > 0 {
// Make the information available for other modules.
- ctx.SetProvider(android.DeapexerProvider, android.NewDeapexerInfo(exports))
+ di := android.NewDeapexerInfo(apexModuleName(ctx.ModuleName()), exports)
+ ctx.SetProvider(android.DeapexerProvider, di)
// Create a sorted list of the files that this exports.
exportedPaths = android.SortedUniquePaths(exportedPaths)
@@ -131,6 +145,6 @@
for _, p := range exportedPaths {
command.Output(p.(android.WritablePath))
}
- builder.Build("deapexer", "deapex "+ctx.ModuleName())
+ builder.Build("deapexer", "deapex "+apexModuleName(ctx.ModuleName()))
}
}
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index d7be9a9..d59f8bf 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -631,10 +631,6 @@
)
}
-func deapexerModuleName(baseModuleName string) string {
- return baseModuleName + ".deapexer"
-}
-
func apexSelectorModuleName(baseModuleName string) string {
return baseModuleName + ".apex.selector"
}