Add AllowMissingDependencies support for prebuilt_etc module with no src property

Arch-specific prebuilt_etc modules may be missing source files for new
architectures.  Allow build analysis to continue when there is no
source file when AllowMissingDependencies is set.

Bug: 250918230
Test: lunch aosp_riscv64-userdebug && m ALLOW_MISSING_DEPENDENCIES=true nothing
Test: TestPrebuiltEtcAllowMissingDependencies
Change-Id: I647c7305339e3ed80283be5e59e6f4ef15ae2384
This commit is contained in:
Colin Cross 2022-10-03 15:31:29 -07:00
parent 14ec66c2fb
commit 725eac60a2
2 changed files with 51 additions and 17 deletions

View file

@ -296,27 +296,37 @@ func (p *PrebuiltEtc) ExcludeFromRecoverySnapshot() bool {
}
func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if p.properties.Src == nil {
ctx.PropertyErrorf("src", "missing prebuilt source file")
return
}
p.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
// Determine the output file basename.
// If Filename is set, use the name specified by the property.
// If Filename_from_src is set, use the source file name.
// Otherwise use the module name.
filename := proptools.String(p.properties.Filename)
filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
if filename != "" {
if filenameFromSrc {
ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
return
if p.properties.Src != nil {
p.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
// Determine the output file basename.
// If Filename is set, use the name specified by the property.
// If Filename_from_src is set, use the source file name.
// Otherwise use the module name.
if filename != "" {
if filenameFromSrc {
ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
return
}
} else if filenameFromSrc {
filename = p.sourceFilePath.Base()
} else {
filename = ctx.ModuleName()
}
} else if ctx.Config().AllowMissingDependencies() {
// If no srcs was set and AllowMissingDependencies is enabled then
// mark the module as missing dependencies and set a fake source path
// and file name.
ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
p.sourceFilePath = android.PathForModuleSrc(ctx)
if filename == "" {
filename = ctx.ModuleName()
}
} else if filenameFromSrc {
filename = p.sourceFilePath.Base()
} else {
filename = ctx.ModuleName()
ctx.PropertyErrorf("src", "missing prebuilt source file")
return
}
p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath

View file

@ -195,6 +195,30 @@ func TestPrebuiltEtcHost(t *testing.T) {
}
}
func TestPrebuiltEtcAllowMissingDependencies(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForPrebuiltEtcTest,
android.PrepareForTestDisallowNonExistentPaths,
android.FixtureModifyConfig(
func(config android.Config) {
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
}),
).RunTestWithBp(t, `
prebuilt_etc {
name: "foo.conf",
filename_from_src: true,
arch: {
x86: {
src: "x86.conf",
},
},
}
`)
android.AssertStringEquals(t, "expected error rule", "android/soong/android.Error",
result.ModuleForTests("foo.conf", "android_arm64_armv8-a").Output("foo.conf").Rule.String())
}
func TestPrebuiltRootInstallDirPath(t *testing.T) {
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_root {