Merge "Relax restriction on suffix of apex_set filename to include .capex"

This commit is contained in:
Mohammad Islam 2021-09-09 08:21:27 +00:00 committed by Gerrit Code Review
commit 385cde82d4
5 changed files with 38 additions and 8 deletions

View file

@ -382,7 +382,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String())
stemSuffix := apexType.suffix()
if a.isCompressed {
stemSuffix = ".capex"
stemSuffix = imageCapexSuffix
}
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+stemSuffix)
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())

View file

@ -1152,9 +1152,10 @@ const (
const (
// File extensions of an APEX for different packaging methods
imageApexSuffix = ".apex"
zipApexSuffix = ".zipapex"
flattenedSuffix = ".flattened"
imageApexSuffix = ".apex"
imageCapexSuffix = ".capex"
zipApexSuffix = ".zipapex"
flattenedSuffix = ".flattened"
// variant names each of which is for a packaging method
imageApexType = "image"

View file

@ -4640,6 +4640,35 @@ func TestPrebuiltFilenameOverride(t *testing.T) {
}
}
func TestApexSetFilenameOverride(t *testing.T) {
testApex(t, `
apex_set {
name: "com.company.android.myapex",
apex_name: "com.android.myapex",
set: "company-myapex.apks",
filename: "com.company.android.myapex.apex"
}
`).ModuleForTests("com.company.android.myapex", "android_common_com.android.myapex")
testApex(t, `
apex_set {
name: "com.company.android.myapex",
apex_name: "com.android.myapex",
set: "company-myapex.apks",
filename: "com.company.android.myapex.capex"
}
`).ModuleForTests("com.company.android.myapex", "android_common_com.android.myapex")
testApexError(t, `filename should end in .apex or .capex for apex_set`, `
apex_set {
name: "com.company.android.myapex",
apex_name: "com.android.myapex",
set: "company-myapex.apks",
filename: "some-random-suffix"
}
`)
}
func TestPrebuiltOverrides(t *testing.T) {
ctx := testApex(t, `
prebuilt_apex {

View file

@ -786,7 +786,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
if apexType == imageApex && (compressionEnabled || a.testOnlyShouldForceCompression()) {
a.isCompressed = true
unsignedCompressedOutputFile := android.PathForModuleOut(ctx, a.Name()+".capex.unsigned")
unsignedCompressedOutputFile := android.PathForModuleOut(ctx, a.Name()+imageCapexSuffix+".unsigned")
compressRule := android.NewRuleBuilder(pctx, ctx)
compressRule.Command().
@ -800,7 +800,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
FlagWithOutput("--output ", unsignedCompressedOutputFile)
compressRule.Build("compressRule", "Generate unsigned compressed APEX file")
signedCompressedOutputFile := android.PathForModuleOut(ctx, a.Name()+".capex")
signedCompressedOutputFile := android.PathForModuleOut(ctx, a.Name()+imageCapexSuffix)
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_SIGNAPK") {
args["outCommaList"] = signedCompressedOutputFile.String()
}

View file

@ -924,8 +924,8 @@ func (a *ApexSet) ApexInfoMutator(mctx android.TopDownMutatorContext) {
func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.installFilename = a.InstallFilename()
if !strings.HasSuffix(a.installFilename, imageApexSuffix) {
ctx.ModuleErrorf("filename should end in %s for apex_set", imageApexSuffix)
if !strings.HasSuffix(a.installFilename, imageApexSuffix) && !strings.HasSuffix(a.installFilename, imageCapexSuffix) {
ctx.ModuleErrorf("filename should end in %s or %s for apex_set", imageApexSuffix, imageCapexSuffix)
}
inputApex := android.OptionalPathForModuleSrc(ctx, a.prebuiltCommonProperties.Selected_apex).Path()