" -i FILE specify input build file [default=build.ninja]\n"
" -n dry run (don't run commands but pretend they succeeded)\n"
" -v show all command lines\n"
+" -q show inputs/outputs of target (query mode)\n"
);
}
BuildConfig config;
const char* input_file = "build.ninja";
bool graph = false;
+ bool query = false;
int opt;
- while ((opt = getopt_long(argc, argv, "ghi:nv", options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "ghi:nvq", options, NULL)) != -1) {
switch (opt) {
case 'g':
graph = true;
case 'v':
config.verbosity = BuildConfig::VERBOSE;
break;
+ case 'q':
+ query = true;
+ break;
case 'h':
default:
usage();
return 0;
}
+ if (query) {
+ for (int i = 0; i < argc; ++i) {
+ Node* node = state.GetNode(argv[i]);
+ if (node) {
+ printf("%s:\n", argv[i]);
+ if (node->in_edge_) {
+ printf(" input: %s\n", node->in_edge_->rule_->name_.c_str());
+ for (vector<Node*>::iterator in = node->in_edge_->inputs_.begin();
+ in != node->in_edge_->inputs_.end(); ++in) {
+ printf(" %s\n", (*in)->file_->path_.c_str());
+ }
+ }
+ for (vector<Edge*>::iterator edge = node->out_edges_.begin();
+ edge != node->out_edges_.end(); ++edge) {
+ printf(" output: %s\n", (*edge)->rule_->name_.c_str());
+ for (vector<Node*>::iterator out = (*edge)->outputs_.begin();
+ out != (*edge)->outputs_.end(); ++out) {
+ printf(" %s\n", (*out)->file_->path_.c_str());
+ }
+ }
+ } else {
+ printf("%s unknown\n", argv[i]);
+ }
+ }
+ return 0;
+ }
+
const char* kLogPath = ".ninja_log";
if (!state.build_log_->Load(kLogPath, &err)) {
fprintf(stderr, "error loading build log: %s\n", err.c_str());