Write ide_qeury results to stdout

All other output will be written to stderr.

Change-Id: Iefbd8292bb136e4723d5c168e4508ae183585c7c
This commit is contained in:
Michael Merg 2024-03-20 11:05:23 +00:00
parent 6d5a509efa
commit d8880abbdf
2 changed files with 5 additions and 5 deletions

View file

@ -117,7 +117,7 @@ llvm::Expected<std::unique_ptr<clang::tooling::CompilationDatabase>> LoadCompDB(
result.mutable_status()->set_code(::ide_query::Status::FAILURE); result.mutable_status()->set_code(::ide_query::Status::FAILURE);
result.mutable_status()->set_message("Command working dir " + result.mutable_status()->set_message("Command working dir " +
working_dir.str() + working_dir.str() +
"outside repository " + repo_dir); " outside repository " + repo_dir);
continue; continue;
} }
working_dir = working_dir.ltrim('/'); working_dir = working_dir.ltrim('/');

View file

@ -121,7 +121,7 @@ func main() {
log.Fatalf("Failed to query cc targets: %v", *status.Message) log.Fatalf("Failed to query cc targets: %v", *status.Message)
} }
toMake = append(toMake, ccTargets...) toMake = append(toMake, ccTargets...)
fmt.Printf("Running make for modules: %v\n", strings.Join(toMake, ", ")) fmt.Fprintf(os.Stderr, "Running make for modules: %v\n", strings.Join(toMake, ", "))
if err := runMake(ctx, env, toMake...); err != nil { if err := runMake(ctx, env, toMake...); err != nil {
log.Printf("Building deps failed: %v", err) log.Printf("Building deps failed: %v", err)
} }
@ -136,13 +136,13 @@ func main() {
log.Fatalf("Failed to marshal result proto: %v", err) log.Fatalf("Failed to marshal result proto: %v", err)
} }
err = os.WriteFile(path.Join(env.RepoDir, env.OutDir, "ide_query.pb"), data, 0644) _, err = os.Stdout.Write(data)
if err != nil { if err != nil {
log.Fatalf("Failed to write result proto: %v", err) log.Fatalf("Failed to write result proto: %v", err)
} }
for _, s := range res.Sources { for _, s := range res.Sources {
fmt.Printf("%s: %v (Deps: %d, Generated: %d)\n", s.GetPath(), s.GetStatus(), len(s.GetDeps()), len(s.GetGenerated())) fmt.Fprintf(os.Stderr, "%s: %v (Deps: %d, Generated: %d)\n", s.GetPath(), s.GetStatus(), len(s.GetDeps()), len(s.GetGenerated()))
} }
} }
@ -312,7 +312,7 @@ func runMake(ctx context.Context, env Env, modules ...string) error {
args = append(args, modules...) args = append(args, modules...)
cmd := exec.CommandContext(ctx, "build/soong/soong_ui.bash", args...) cmd := exec.CommandContext(ctx, "build/soong/soong_ui.bash", args...)
cmd.Dir = env.RepoDir cmd.Dir = env.RepoDir
cmd.Stdout = os.Stdout cmd.Stdout = os.Stderr
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
return cmd.Run() return cmd.Run()
} }