Separate apex selection from apex.Prebuilt
This dedups the apex selection (which was previously being done by both
the apex.Prebuilt module type and the Deapexer module type) by
separating it out into its own module.
The apex.Prebuilt module retrieves the selected apex from its
selected_apex property which is simply initialized with
":<selector-module-name>".
The Deapexer module retrieves the selected apex it should use from its
src property which is initialized in the same way. That makes it easy
for the Deapexer module to be reused by the apex_set in a similar way.
Bug: 181267622
Test: m droid
Change-Id: I90cfb55698d35a97dcf28b95afcb1f58584bc90c
diff --git a/apex/deapexer.go b/apex/deapexer.go
index e7aa551..1db13f9 100644
--- a/apex/deapexer.go
+++ b/apex/deapexer.go
@@ -49,21 +49,27 @@
Exported_java_libs []string
}
+type SelectedApexProperties struct {
+ // The path to the apex selected for use by this module.
+ //
+ // Is tagged as `android:"path"` because it will usually contain a string of the form ":<module>"
+ // and is tagged as "`blueprint:"mutate"` because it is only initialized in a LoadHook not an
+ // Android.bp file.
+ Selected_apex *string `android:"path" blueprint:"mutated"`
+}
+
type Deapexer struct {
android.ModuleBase
- properties DeapexerProperties
- apexFileProperties ApexFileProperties
+ properties DeapexerProperties
+ selectedApexProperties SelectedApexProperties
inputApex android.Path
}
func privateDeapexerFactory() android.Module {
module := &Deapexer{}
- module.AddProperties(
- &module.properties,
- &module.apexFileProperties,
- )
+ module.AddProperties(&module.properties, &module.selectedApexProperties)
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
return module
}
@@ -78,7 +84,7 @@
}
func (p *Deapexer) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- p.inputApex = android.SingleSourcePathFromSupplier(ctx, p.apexFileProperties.prebuiltApexSelector, "src")
+ p.inputApex = android.OptionalPathForModuleSrc(ctx, p.selectedApexProperties.Selected_apex).Path()
// Create and remember the directory into which the .apex file's contents will be unpacked.
deapexerOutput := android.PathForModuleOut(ctx, "deapexer")