Fix Make modules name conflict for override_apex
When an override_apex named Foo overrides an apex module named Bar, the Make modules from Foo have Foo as their suffix. Previously the suffix was Bar for both of the overriding and the overridden APEXes, causing name conflicts in the Make side. Bug: 144338929 Test: apex_test.go Change-Id: I1396910ab294ba5f5e0585af6d37f1eab9460250
This commit is contained in:
committed by
Jiyong Park
parent
9d78c66ac3
commit
1670ca0d8b
@@ -1162,7 +1162,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
// prepend the name of this APEX to the module names. These names will be the names of
|
// prepend the name of this APEX to the module names. These names will be the names of
|
||||||
// modules that will be defined if the APEX is flattened.
|
// modules that will be defined if the APEX is flattened.
|
||||||
for i := range filesInfo {
|
for i := range filesInfo {
|
||||||
filesInfo[i].moduleName = filesInfo[i].moduleName + "." + ctx.ModuleName() + a.suffix
|
filesInfo[i].moduleName = filesInfo[i].moduleName + "." + a.Name() + a.suffix
|
||||||
}
|
}
|
||||||
|
|
||||||
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
||||||
@@ -1195,7 +1195,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
a.buildUnflattenedApex(ctx)
|
a.buildUnflattenedApex(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName())
|
apexName := proptools.StringDefault(a.properties.Apex_name, a.Name())
|
||||||
a.compatSymlinks = makeCompatSymlinks(apexName, ctx)
|
a.compatSymlinks = makeCompatSymlinks(apexName, ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2934,7 +2934,7 @@ func TestApexAvailable(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOverrideApex(t *testing.T) {
|
func TestOverrideApex(t *testing.T) {
|
||||||
ctx, _ := testApex(t, `
|
ctx, config := testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
name: "myapex",
|
name: "myapex",
|
||||||
key: "myapex.key",
|
key: "myapex.key",
|
||||||
@@ -2974,6 +2974,23 @@ func TestOverrideApex(t *testing.T) {
|
|||||||
|
|
||||||
ensureNotContains(t, copyCmds, "image.apex/app/app/app.apk")
|
ensureNotContains(t, copyCmds, "image.apex/app/app/app.apk")
|
||||||
ensureContains(t, copyCmds, "image.apex/app/app/override_app.apk")
|
ensureContains(t, copyCmds, "image.apex/app/app/override_app.apk")
|
||||||
|
|
||||||
|
apexBundle := module.Module().(*apexBundle)
|
||||||
|
name := apexBundle.Name()
|
||||||
|
if name != "override_myapex" {
|
||||||
|
t.Errorf("name should be \"override_myapex\", but was %q", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||||
|
var builder strings.Builder
|
||||||
|
data.Custom(&builder, name, "TARGET_", "", data)
|
||||||
|
androidMk := builder.String()
|
||||||
|
ensureContains(t, androidMk, "LOCAL_MODULE := app.override_myapex")
|
||||||
|
ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.override_myapex")
|
||||||
|
ensureContains(t, androidMk, "LOCAL_MODULE_STEM := override_myapex.apex")
|
||||||
|
ensureNotContains(t, androidMk, "LOCAL_MODULE := app.myapex")
|
||||||
|
ensureNotContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.myapex")
|
||||||
|
ensureNotContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.apex")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
@@ -244,7 +244,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
apexType := a.properties.ApexType
|
apexType := a.properties.ApexType
|
||||||
suffix := apexType.suffix()
|
suffix := apexType.suffix()
|
||||||
unsignedOutputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+suffix+".unsigned")
|
unsignedOutputFile := android.PathForModuleOut(ctx, a.Name()+suffix+".unsigned")
|
||||||
|
|
||||||
filesToCopy := []android.Path{}
|
filesToCopy := []android.Path{}
|
||||||
for _, f := range a.filesInfo {
|
for _, f := range a.filesInfo {
|
||||||
@@ -253,7 +253,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
copyCommands := []string{}
|
copyCommands := []string{}
|
||||||
emitCommands := []string{}
|
emitCommands := []string{}
|
||||||
imageContentFile := android.PathForModuleOut(ctx, ctx.ModuleName()+"-content.txt")
|
imageContentFile := android.PathForModuleOut(ctx, a.Name()+"-content.txt")
|
||||||
emitCommands = append(emitCommands, "echo ./apex_manifest.json >> "+imageContentFile.String())
|
emitCommands = append(emitCommands, "echo ./apex_manifest.json >> "+imageContentFile.String())
|
||||||
for i, src := range filesToCopy {
|
for i, src := range filesToCopy {
|
||||||
dest := filepath.Join(a.filesInfo[i].installDir, src.Base())
|
dest := filepath.Join(a.filesInfo[i].installDir, src.Base())
|
||||||
@@ -284,7 +284,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
implicitInputs = append(implicitInputs, imageContentFile)
|
implicitInputs = append(implicitInputs, imageContentFile)
|
||||||
whitelistedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.Whitelisted_files))
|
whitelistedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.Whitelisted_files))
|
||||||
|
|
||||||
phonyOutput := android.PathForModuleOut(ctx, ctx.ModuleName()+"-diff-phony-output")
|
phonyOutput := android.PathForModuleOut(ctx, a.Name()+"-diff-phony-output")
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: diffApexContentRule,
|
Rule: diffApexContentRule,
|
||||||
Implicits: implicitInputs,
|
Implicits: implicitInputs,
|
||||||
@@ -293,7 +293,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"whitelisted_files_file": whitelistedFilesFile.String(),
|
"whitelisted_files_file": whitelistedFilesFile.String(),
|
||||||
"image_content_file": imageContentFile.String(),
|
"image_content_file": imageContentFile.String(),
|
||||||
"apex_module_name": ctx.ModuleName(),
|
"apex_module_name": a.Name(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
implicitInputs = append(implicitInputs, cannedFsConfig, a.fileContexts, a.private_key_file, a.public_key_file)
|
implicitInputs = append(implicitInputs, cannedFsConfig, a.fileContexts, a.private_key_file, a.public_key_file)
|
||||||
optFlags = append(optFlags, "--pubkey "+a.public_key_file.String())
|
optFlags = append(optFlags, "--pubkey "+a.public_key_file.String())
|
||||||
|
|
||||||
manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(ctx.ModuleName())
|
manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(a.Name())
|
||||||
if overridden {
|
if overridden {
|
||||||
optFlags = append(optFlags, "--override_apk_package_name "+manifestPackageName)
|
optFlags = append(optFlags, "--override_apk_package_name "+manifestPackageName)
|
||||||
}
|
}
|
||||||
@@ -368,7 +368,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
|
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
|
||||||
|
|
||||||
noticeFile := a.buildNoticeFile(ctx, ctx.ModuleName()+suffix)
|
noticeFile := a.buildNoticeFile(ctx, a.Name()+suffix)
|
||||||
if noticeFile.Valid() {
|
if noticeFile.Valid() {
|
||||||
// If there's a NOTICE file, embed it as an asset file in the APEX.
|
// If there's a NOTICE file, embed it as an asset file in the APEX.
|
||||||
implicitInputs = append(implicitInputs, noticeFile.Path())
|
implicitInputs = append(implicitInputs, noticeFile.Path())
|
||||||
@@ -407,8 +407,8 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
apexProtoFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".pb"+suffix)
|
apexProtoFile := android.PathForModuleOut(ctx, a.Name()+".pb"+suffix)
|
||||||
bundleModuleFile := android.PathForModuleOut(ctx, ctx.ModuleName()+suffix+"-base.zip")
|
bundleModuleFile := android.PathForModuleOut(ctx, a.Name()+suffix+"-base.zip")
|
||||||
a.bundleModuleFile = bundleModuleFile
|
a.bundleModuleFile = bundleModuleFile
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
@@ -443,7 +443,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
a.outputFile = android.PathForModuleOut(ctx, ctx.ModuleName()+suffix)
|
a.outputFile = android.PathForModuleOut(ctx, a.Name()+suffix)
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: java.Signapk,
|
Rule: java.Signapk,
|
||||||
Description: "signapk",
|
Description: "signapk",
|
||||||
@@ -461,7 +461,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
// Install to $OUT/soong/{target,host}/.../apex
|
// Install to $OUT/soong/{target,host}/.../apex
|
||||||
if a.installable() {
|
if a.installable() {
|
||||||
ctx.InstallFile(a.installDir, ctx.ModuleName()+suffix, a.outputFile)
|
ctx.InstallFile(a.installDir, a.Name()+suffix, a.outputFile)
|
||||||
}
|
}
|
||||||
a.buildFilesInfo(ctx)
|
a.buildFilesInfo(ctx)
|
||||||
}
|
}
|
||||||
@@ -501,8 +501,8 @@ func (a *apexBundle) buildFilesInfo(ctx android.ModuleContext) {
|
|||||||
if a.installable() {
|
if a.installable() {
|
||||||
// For flattened APEX, do nothing but make sure that apex_manifest.json and apex_pubkey are also copied along
|
// For flattened APEX, do nothing but make sure that apex_manifest.json and apex_pubkey are also copied along
|
||||||
// with other ordinary files.
|
// with other ordinary files.
|
||||||
a.filesInfo = append(a.filesInfo, apexFile{a.manifestJsonOut, "apex_manifest.json." + ctx.ModuleName() + a.suffix, ".", etc, nil, nil})
|
a.filesInfo = append(a.filesInfo, apexFile{a.manifestJsonOut, "apex_manifest.json." + a.Name() + a.suffix, ".", etc, nil, nil})
|
||||||
a.filesInfo = append(a.filesInfo, apexFile{a.manifestPbOut, "apex_manifest.pb." + ctx.ModuleName() + a.suffix, ".", etc, nil, nil})
|
a.filesInfo = append(a.filesInfo, apexFile{a.manifestPbOut, "apex_manifest.pb." + a.Name() + a.suffix, ".", etc, nil, nil})
|
||||||
|
|
||||||
// rename to apex_pubkey
|
// rename to apex_pubkey
|
||||||
copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey")
|
copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey")
|
||||||
@@ -511,10 +511,10 @@ func (a *apexBundle) buildFilesInfo(ctx android.ModuleContext) {
|
|||||||
Input: a.public_key_file,
|
Input: a.public_key_file,
|
||||||
Output: copiedPubkey,
|
Output: copiedPubkey,
|
||||||
})
|
})
|
||||||
a.filesInfo = append(a.filesInfo, apexFile{copiedPubkey, "apex_pubkey." + ctx.ModuleName() + a.suffix, ".", etc, nil, nil})
|
a.filesInfo = append(a.filesInfo, apexFile{copiedPubkey, "apex_pubkey." + a.Name() + a.suffix, ".", etc, nil, nil})
|
||||||
|
|
||||||
if a.properties.ApexType == flattenedApex {
|
if a.properties.ApexType == flattenedApex {
|
||||||
apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName())
|
apexName := proptools.StringDefault(a.properties.Apex_name, a.Name())
|
||||||
for _, fi := range a.filesInfo {
|
for _, fi := range a.filesInfo {
|
||||||
dir := filepath.Join("apex", apexName, fi.installDir)
|
dir := filepath.Join("apex", apexName, fi.installDir)
|
||||||
target := ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.builtFile.Base(), fi.builtFile)
|
target := ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.builtFile.Base(), fi.builtFile)
|
||||||
|
Reference in New Issue
Block a user