Remove the internal extractor module created by apex_set am: 9d6e209f44 am: 5994600572

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3273164

Change-Id: Iac682fe1a9026f4075929adfd895913f1c3c567d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Spandan Das
2024-09-23 23:13:07 +00:00
committed by Automerger Merge Worker
2 changed files with 36 additions and 68 deletions

View File

@@ -7861,9 +7861,9 @@ func TestAppSetBundlePrebuilt(t *testing.T) {
ctx := testApex(t, bp, prepareForTestWithSantitizeHwaddress) ctx := testApex(t, bp, prepareForTestWithSantitizeHwaddress)
// Check that the extractor produces the correct output file from the correct input file. // Check that the extractor produces the correct output file from the correct input file.
extractorOutput := "out/soong/.intermediates/prebuilt_myapex.apex.extractor/android_common/extracted/myapex.hwasan.apks" extractorOutput := "out/soong/.intermediates/myapex/android_common_myapex/extracted/myapex.hwasan.apks"
m := ctx.ModuleForTests("prebuilt_myapex.apex.extractor", "android_common") m := ctx.ModuleForTests("myapex", "android_common_myapex")
extractedApex := m.Output(extractorOutput) extractedApex := m.Output(extractorOutput)
android.AssertArrayString(t, "extractor input", []string{"myapex.hwasan.apks"}, extractedApex.Inputs.Strings()) android.AssertArrayString(t, "extractor input", []string{"myapex.hwasan.apks"}, extractedApex.Inputs.Strings())
@@ -7888,10 +7888,10 @@ func TestApexSetApksModuleAssignment(t *testing.T) {
} }
`) `)
m := ctx.ModuleForTests("prebuilt_myapex.apex.extractor", "android_common") m := ctx.ModuleForTests("myapex", "android_common_myapex")
// Check that the extractor produces the correct apks file from the input module // Check that the extractor produces the correct apks file from the input module
extractorOutput := "out/soong/.intermediates/prebuilt_myapex.apex.extractor/android_common/extracted/myapex.apks" extractorOutput := "out/soong/.intermediates/myapex/android_common_myapex/extracted/myapex.apks"
extractedApex := m.Output(extractorOutput) extractedApex := m.Output(extractorOutput)
android.AssertArrayString(t, "extractor input", []string{"myapex.apks"}, extractedApex.Inputs.Strings()) android.AssertArrayString(t, "extractor input", []string{"myapex.apks"}, extractedApex.Inputs.Strings())
@@ -8453,7 +8453,7 @@ func TestApexSet(t *testing.T) {
}), }),
) )
m := ctx.ModuleForTests("prebuilt_myapex.apex.extractor", "android_common") m := ctx.ModuleForTests("myapex", "android_common_myapex")
// Check extract_apks tool parameters. // Check extract_apks tool parameters.
extractedApex := m.Output("extracted/myapex.apks") extractedApex := m.Output("extracted/myapex.apks")
@@ -8494,7 +8494,7 @@ func TestApexSet_NativeBridge(t *testing.T) {
}), }),
) )
m := ctx.ModuleForTests("prebuilt_myapex.apex.extractor", "android_common") m := ctx.ModuleForTests("myapex", "android_common_myapex")
// Check extract_apks tool parameters. No native bridge arch expected // Check extract_apks tool parameters. No native bridge arch expected
extractedApex := m.Output("extracted/myapex.apks") extractedApex := m.Output("extracted/myapex.apks")

View File

@@ -253,6 +253,8 @@ func (p *prebuiltCommon) AndroidMkEntries() []android.AndroidMkEntries {
return entriesList return entriesList
} }
// DEPRECATED. // TODO (spandandas): Remove this interface.
// prebuiltApexModuleCreator defines the methods that need to be implemented by prebuilt_apex and // prebuiltApexModuleCreator defines the methods that need to be implemented by prebuilt_apex and
// apex_set in order to create the modules needed to provide access to the prebuilt .apex file. // apex_set in order to create the modules needed to provide access to the prebuilt .apex file.
type prebuiltApexModuleCreator interface { type prebuiltApexModuleCreator interface {
@@ -731,26 +733,11 @@ type prebuiltApexExtractorModule struct {
extractedApex android.WritablePath extractedApex android.WritablePath
} }
func privateApexExtractorModuleFactory() android.Module { // extract registers the build actions to extract an apex from .apks file
module := &prebuiltApexExtractorModule{} // returns the path of the extracted apex
module.AddProperties( func extract(ctx android.ModuleContext, apexSet android.Path, prerelease *bool) android.Path {
&module.properties,
)
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
return module
}
func (p *prebuiltApexExtractorModule) Srcs() android.Paths {
return android.Paths{p.extractedApex}
}
func (p *prebuiltApexExtractorModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
srcsSupplier := func(ctx android.BaseModuleContext, prebuilt android.Module) []string {
return p.properties.prebuiltSrcs(ctx)
}
defaultAllowPrerelease := ctx.Config().IsEnvTrue("SOONG_ALLOW_PRERELEASE_APEXES") defaultAllowPrerelease := ctx.Config().IsEnvTrue("SOONG_ALLOW_PRERELEASE_APEXES")
apexSet := android.SingleSourcePathFromSupplier(ctx, srcsSupplier, "set") extractedApex := android.PathForModuleOut(ctx, "extracted", apexSet.Base())
p.extractedApex = android.PathForModuleOut(ctx, "extracted", apexSet.Base())
// Filter out NativeBridge archs (b/260115309) // Filter out NativeBridge archs (b/260115309)
abis := java.SupportedAbis(ctx, true) abis := java.SupportedAbis(ctx, true)
ctx.Build(pctx, ctx.Build(pctx,
@@ -758,14 +745,16 @@ func (p *prebuiltApexExtractorModule) GenerateAndroidBuildActions(ctx android.Mo
Rule: extractMatchingApex, Rule: extractMatchingApex,
Description: "Extract an apex from an apex set", Description: "Extract an apex from an apex set",
Inputs: android.Paths{apexSet}, Inputs: android.Paths{apexSet},
Output: p.extractedApex, Output: extractedApex,
Args: map[string]string{ Args: map[string]string{
"abis": strings.Join(abis, ","), "abis": strings.Join(abis, ","),
"allow-prereleased": strconv.FormatBool(proptools.BoolDefault(p.properties.Prerelease, defaultAllowPrerelease)), "allow-prereleased": strconv.FormatBool(proptools.BoolDefault(prerelease, defaultAllowPrerelease)),
"sdk-version": ctx.Config().PlatformSdkVersion().String(), "sdk-version": ctx.Config().PlatformSdkVersion().String(),
"skip-sdk-check": strconv.FormatBool(ctx.Config().IsEnvTrue("SOONG_SKIP_APPSET_SDK_CHECK")), "skip-sdk-check": strconv.FormatBool(ctx.Config().IsEnvTrue("SOONG_SKIP_APPSET_SDK_CHECK")),
}, },
}) },
)
return extractedApex
} }
type ApexSet struct { type ApexSet struct {
@@ -834,47 +823,18 @@ func (a *ApexSet) hasSanitizedSource(sanitizer string) bool {
func apexSetFactory() android.Module { func apexSetFactory() android.Module {
module := &ApexSet{} module := &ApexSet{}
module.AddProperties(&module.properties) module.AddProperties(&module.properties)
module.initPrebuiltCommon(module, &module.properties.PrebuiltCommonProperties) module.prebuiltCommon.prebuiltCommonProperties = &module.properties.PrebuiltCommonProperties
// init the module as a prebuilt
// even though this module type has srcs, use `InitPrebuiltModuleWithoutSrcs`, since the existing
// InitPrebuiltModule* are not friendly with Sources of Configurable type.
// The actual src will be evaluated in GenerateAndroidBuildActions.
android.InitPrebuiltModuleWithoutSrcs(module)
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
return module return module
} }
func createApexExtractorModule(ctx android.BottomUpMutatorContext, name string, apexExtractorProperties *ApexExtractorProperties) {
props := struct {
Name *string
}{
Name: proptools.StringPtr(name),
}
ctx.CreateModule(privateApexExtractorModuleFactory,
&props,
apexExtractorProperties,
)
}
func apexExtractorModuleName(baseModuleName string) string {
return baseModuleName + ".apex.extractor"
}
var _ prebuiltApexModuleCreator = (*ApexSet)(nil)
// createPrebuiltApexModules creates modules necessary to export files from the apex set to other
// modules.
//
// This effectively does for apex_set what Prebuilt.createPrebuiltApexModules does for a
// prebuilt_apex except that instead of creating a selector module which selects one .apex file
// from those provided this creates an extractor module which extracts the appropriate .apex file
// from the zip file containing them.
func (a *ApexSet) createPrebuiltApexModules(ctx android.BottomUpMutatorContext) {
apexExtractorModuleName := apexExtractorModuleName(a.Name())
createApexExtractorModule(ctx, apexExtractorModuleName, &a.properties.ApexExtractorProperties)
apexFileSource := ":" + apexExtractorModuleName
// After passing the arch specific src properties to the creating the apex selector module
a.prebuiltCommonProperties.Selected_apex = proptools.StringPtr(apexFileSource)
}
func (a *ApexSet) ComponentDepsMutator(ctx android.BottomUpMutatorContext) { func (a *ApexSet) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
a.prebuiltApexContentsDeps(ctx) a.prebuiltApexContentsDeps(ctx)
} }
@@ -897,7 +857,15 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.ModuleErrorf("filename should end in %s or %s for apex_set", imageApexSuffix, imageCapexSuffix) ctx.ModuleErrorf("filename should end in %s or %s for apex_set", imageApexSuffix, imageCapexSuffix)
} }
inputApex := android.OptionalPathForModuleSrc(ctx, a.prebuiltCommonProperties.Selected_apex).Path() var apexSet android.Path
if srcs := a.properties.prebuiltSrcs(ctx); len(srcs) == 1 {
apexSet = android.PathForModuleSrc(ctx, srcs[0])
} else {
ctx.ModuleErrorf("Expected exactly one source apex_set file, found %v\n", srcs)
}
extractedApex := extract(ctx, apexSet, a.properties.Prerelease)
a.outputApex = android.PathForModuleOut(ctx, a.installFilename) a.outputApex = android.PathForModuleOut(ctx, a.installFilename)
// Build the output APEX. If compression is not enabled, make sure the output is not compressed even if the input is compressed // Build the output APEX. If compression is not enabled, make sure the output is not compressed even if the input is compressed
@@ -907,7 +875,7 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
} }
ctx.Build(pctx, android.BuildParams{ ctx.Build(pctx, android.BuildParams{
Rule: buildRule, Rule: buildRule,
Input: inputApex, Input: extractedApex,
Output: a.outputApex, Output: a.outputApex,
}) })
@@ -916,7 +884,7 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
return return
} }
deapexerInfo := a.getDeapexerInfo(ctx, inputApex) deapexerInfo := a.getDeapexerInfo(ctx, extractedApex)
// dexpreopt any system server jars if present // dexpreopt any system server jars if present
a.dexpreoptSystemServerJars(ctx, deapexerInfo) a.dexpreoptSystemServerJars(ctx, deapexerInfo)