Really fix queryview.

In addition, make the Ninja command nicer by using backticks instead of
backslash-quoting double quotes.

Test: Manual: "m queryview"
Change-Id: I5d6e1d41424e0229bfe08e2e7eaf2fb025ed48c2
This commit is contained in:
Lukacs T. Berki 2021-03-08 16:34:09 +01:00
parent 89071b08c7
commit 47a9d0cd98
2 changed files with 15 additions and 10 deletions

View File

@ -66,16 +66,20 @@ func generateBuildActionsForBazelConversion(ctx SingletonContext, converterMode
bazelQueryView := ctx.Rule(pctx, "bazelQueryView", bazelQueryView := ctx.Rule(pctx, "bazelQueryView",
blueprint.RuleParams{ blueprint.RuleParams{
Command: fmt.Sprintf( Command: fmt.Sprintf(
"rm -rf ${outDir}/* && "+ `rm -rf "${outDir}/"* && `+
"BUILDER=\"%s\" && "+ `mkdir -p "${outDir}" && `+
"cd $$(dirname \"$$BUILDER\") && "+ `echo WORKSPACE: cat "%s" > "${outDir}/.queryview-depfile.d" && `+
"ABSBUILDER=\"$$PWD/$$(basename \"$$BUILDER\")\" && "+ `BUILDER="%s" && `+
"cd / && "+ `echo BUILDER=$$BUILDER && `+
"env -i \"$$ABSBUILDER\" --bazel_queryview_dir ${outDir} \"%s\" && "+ `cd "$$(dirname "$$BUILDER")" && `+
"echo WORKSPACE: `cat %s` > ${outDir}/.queryview-depfile.d", `echo PWD=$$PWD && `+
`ABSBUILDER="$$PWD/$$(basename "$$BUILDER")" && `+
`echo ABSBUILDER=$$ABSBUILDER && `+
`cd / && `+
`env -i "$$ABSBUILDER" --bazel_queryview_dir "${outDir}" "%s"`,
moduleListFilePath.String(), // Use the contents of Android.bp.list as the depfile.
primaryBuilder.String(), primaryBuilder.String(),
strings.Join(os.Args[1:], "\" \""), strings.Join(os.Args[1:], "\" \""),
moduleListFilePath.String(), // Use the contents of Android.bp.list as the depfile.
), ),
CommandDeps: []string{primaryBuilder.String()}, CommandDeps: []string{primaryBuilder.String()},
Description: fmt.Sprintf( Description: fmt.Sprintf(

View File

@ -43,7 +43,7 @@ func init() {
flag.StringVar(&delveListen, "delve_listen", "", "Delve port to listen on for debugging") flag.StringVar(&delveListen, "delve_listen", "", "Delve port to listen on for debugging")
flag.StringVar(&delvePath, "delve_path", "", "Path to Delve. Only used if --delve_listen is set") flag.StringVar(&delvePath, "delve_path", "", "Path to Delve. Only used if --delve_listen is set")
flag.StringVar(&docFile, "soong_docs", "", "build documentation file to output") flag.StringVar(&docFile, "soong_docs", "", "build documentation file to output")
flag.StringVar(&bazelQueryViewDir, "bazel_queryview_dir", "", "path to the bazel queryview directory") flag.StringVar(&bazelQueryViewDir, "bazel_queryview_dir", "", "path to the bazel queryview directory relative to --top")
} }
func newNameResolver(config android.Config) *android.NameResolver { func newNameResolver(config android.Config) *android.NameResolver {
@ -150,7 +150,8 @@ func main() {
if bazelQueryViewDir != "" { if bazelQueryViewDir != "" {
// Run the code-generation phase to convert BazelTargetModules to BUILD files. // Run the code-generation phase to convert BazelTargetModules to BUILD files.
codegenContext := bp2build.NewCodegenContext(configuration, *ctx, bp2build.QueryView) codegenContext := bp2build.NewCodegenContext(configuration, *ctx, bp2build.QueryView)
if err := createBazelQueryView(codegenContext, bazelQueryViewDir); err != nil { absoluteQueryViewDir := shared.JoinPath(topDir, bazelQueryViewDir)
if err := createBazelQueryView(codegenContext, absoluteQueryViewDir); err != nil {
fmt.Fprintf(os.Stderr, "%s", err) fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1) os.Exit(1)
} }