queryview: blocklist package module type.

The package module type was recently introduced, and its module name is
the full package path. queryview uses the module name as the eventual
target name in the generated BUILD files, so this causes a crash as seen
in b/179605762.

Workaround this by not generating package modules in the queryview
directory.

Test: m queryview && bazel query --config=queryview //...
Fixes: 179605762
Change-Id: Iac2bd79d02bec47d6271583d106c184fb2f16e68
This commit is contained in:
Jingwen Chen 2021-02-08 00:49:32 -05:00
parent b7eab01167
commit 96af35bec6
1 changed files with 6 additions and 0 deletions

View File

@ -173,6 +173,12 @@ func GenerateBazelTargets(ctx bpToBuildContext, codegenMode CodegenMode) map[str
}
t = generateBazelTarget(ctx, m)
case QueryView:
// Blocklist certain module types from being generated.
if canonicalizeModuleType(ctx.ModuleType(m)) == "package" {
// package module name contain slashes, and thus cannot
// be mapped cleanly to a bazel label.
return
}
t = generateSoongModuleTarget(ctx, m)
default:
panic(fmt.Errorf("Unknown code-generation mode: %s", codegenMode))