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
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index 362a8ef..baad58e 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -296,27 +296,37 @@
}
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 filenameFromSrc {
- filename = p.sourceFilePath.Base()
+ } 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 {
- filename = ctx.ModuleName()
+ ctx.PropertyErrorf("src", "missing prebuilt source file")
+ return
}
p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath