Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to get the command for just a single target would be cool #466

Open
nico opened this issue Dec 1, 2012 · 2 comments
Open

A way to get the command for just a single target would be cool #466

nico opened this issue Dec 1, 2012 · 2 comments
Labels

Comments

@nico
Copy link
Collaborator

nico commented Dec 1, 2012

If I want to use the clang_complete plugin with chrome, I need to give it -D and -I flags for every file. One way to do this is to run

ninja -C out/Release chrome -t commands   | grep chrome/browser/ui/browser.cc

and grab all -D and -I flags from that command. That works fairly well, but 2s of the 2.3s needed by this command is spent in ninja writing all commands to stdout and grep finding the one line I care about. (Not much faster if I > /dev/null instead of grep.)

With this proof-of-concept change in PrintCommands(), the time for this goes from 2.3s to 0.3s:

-  if (!edge->is_phony())
-    puts(edge->EvaluateCommand().c_str());
+  if (!edge->is_phony()) {
+    string cmd = edge->EvaluateCommand();
+    if (cmd.find("chrome/browser/ui/browser.cc") != string::npos)
+      puts(cmd.c_str());
+  }

This time is part of the time clang_complete spends after hitting the first '.' in a file, so getting it faster would be nice. I can't think of a good syntax for this though.

@evmar
Copy link
Collaborator

evmar commented Dec 8, 2012

It seems reasonable for commands to take an argument, which would constrain it to a command that produced a given output. Then you could use ninja -t commands foobar.cc^

@nico
Copy link
Collaborator Author

nico commented Dec 8, 2012

That'd make sense to me, but it'd be backwards incompatible: -t commands already takes an argument and as far as I understand prints out all commands contained in that argument. That's probably useful in some situations too, so maybe there's need to be a way to pick between "all commands in the graph" and "just one leaf command"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants