• Home
  • Raw
  • Download

Lines Matching +full:build +full:- +full:rules

7 //     http://www.apache.org/licenses/LICENSE-2.0
37 #include "build.h"
58 // Defined in msvc_helper_main-win32.cc.
61 // Defined in minidump-win32.cc.
69 /// Command-line options.
71 /// Build file to load.
80 /// Whether duplicate rules for one target should warn or print an error.
97 /// Build configuration set from flags (e.g. parallelism).
100 /// Loaded state (rules, nodes).
106 /// The build directory, used for storing the build log etc.
115 /// Get the Node for a given command-line path, handling features like
119 /// CollectTarget for all command-line arguments, filling in \a targets.
123 // The various subcommands, run via "-t XXX".
142 /// Open the build log.
150 /// Ensure the build directory exists, creating it if necessary.
159 /// For each edge, lookup in build log how long it took last time,
163 /// Build the targets listed on the command line.
167 /// Dump the output requested by '-d stats'.
172 if (n && n->in_edge()) in IsPathDead()
174 // Just checking n isn't enough: If an old output is both in the build log in IsPathDead()
179 // the deps log, and then a second recompaction will clear the build log, in IsPathDead()
185 if (mtime == -1) in IsPathDead()
193 /// Subtools, accessible via "-t foo".
198 /// Description (shown in "-t list").
203 /// Run after parsing the command-line flags and potentially changing
207 /// Run after loading build.ninja.
210 /// Run after loading the build/deps logs.
226 " --version print ninja version (\"%s\")\n" in Usage()
227 " -v, --verbose show all command lines while building\n" in Usage()
228 " --quiet don't show progress status, just command output\n" in Usage()
230 " -C DIR change to DIR before doing anything else\n" in Usage()
231 " -f FILE specify input build file [default=build.ninja]\n" in Usage()
233 " -j N run N jobs in parallel (0 means infinity) [default=%d on this system]\n" in Usage()
234 " -k N keep going until N jobs fail (0 means infinity) [default=1]\n" in Usage()
235 " -l N do not start new jobs if the load average is greater than N\n" in Usage()
236 " -n dry run (don't run commands but act like they succeeded)\n" in Usage()
238 " -d MODE enable debugging (use '-d list' to list modes)\n" in Usage()
239 " -t TOOL run a subtool (use '-t list' to list subtools)\n" in Usage()
241 " -w FLAG adjust warnings (use '-w list' to list warnings)\n", in Usage()
245 /// Choose a default value for the -j (parallelism) flag.
258 /// Rebuild the build manifest, if necessary.
281 if (!builder.Build(err)) in RebuildManifest()
286 if (!node->dirty()) { in RebuildManifest()
288 // https://github.com/ninja-build/ninja/issues/874 in RebuildManifest()
298 for (Node* out : edge->outputs_) { in ParsePreviousElapsedTimes()
299 BuildLog::LogEntry* log_entry = build_log_.LookupByOutput(out->path()); in ParsePreviousElapsedTimes()
302 edge->prev_elapsed_time_millis = in ParsePreviousElapsedTimes()
303 log_entry->end_time - log_entry->start_time; in ParsePreviousElapsedTimes()
320 if (!path.empty() && path[path.size() - 1] == '^') { in CollectTarget()
321 path.resize(path.size() - 1); in CollectTarget()
328 if (node->out_edges().empty()) { in CollectTarget()
336 Edge* edge = node->out_edges()[0]; in CollectTarget()
337 if (edge->outputs_.empty()) { in CollectTarget()
338 edge->Dump(); in CollectTarget()
341 node = edge->outputs_[0]; in CollectTarget()
349 *err += ", did you mean 'ninja -t clean'?"; in CollectTarget()
351 *err += ", did you mean 'ninja -h'?"; in CollectTarget()
355 *err += ", did you mean '" + suggestion->path() + "'?"; in CollectTarget()
366 return err->empty(); in CollectTargetsFromArgs()
373 targets->push_back(node); in CollectTargetsFromArgs()
411 printf("%s:\n", node->path().c_str()); in ToolQuery()
412 if (Edge* edge = node->in_edge()) { in ToolQuery()
413 if (edge->dyndep_ && edge->dyndep_->dyndep_pending()) { in ToolQuery()
414 if (!dyndep_loader.LoadDyndeps(edge->dyndep_, &err)) { in ToolQuery()
418 printf(" input: %s\n", edge->rule_->name().c_str()); in ToolQuery()
419 for (int in = 0; in < (int)edge->inputs_.size(); in++) { in ToolQuery()
421 if (edge->is_implicit(in)) in ToolQuery()
423 else if (edge->is_order_only(in)) in ToolQuery()
425 printf(" %s%s\n", label, edge->inputs_[in]->path().c_str()); in ToolQuery()
427 if (!edge->validations_.empty()) { in ToolQuery()
429 for (std::vector<Node*>::iterator validation = edge->validations_.begin(); in ToolQuery()
430 validation != edge->validations_.end(); ++validation) { in ToolQuery()
431 printf(" %s\n", (*validation)->path().c_str()); in ToolQuery()
436 for (vector<Edge*>::const_iterator edge = node->out_edges().begin(); in ToolQuery()
437 edge != node->out_edges().end(); ++edge) { in ToolQuery()
438 for (vector<Node*>::iterator out = (*edge)->outputs_.begin(); in ToolQuery()
439 out != (*edge)->outputs_.end(); ++out) { in ToolQuery()
440 printf(" %s\n", (*out)->path().c_str()); in ToolQuery()
443 const std::vector<Edge*> validation_edges = node->validation_out_edges(); in ToolQuery()
448 for (vector<Node*>::iterator out = (*edge)->outputs_.begin(); in ToolQuery()
449 out != (*edge)->outputs_.end(); ++out) { in ToolQuery()
450 printf(" %s\n", (*out)->path().c_str()); in ToolQuery()
460 RunBrowsePython(&state_, ninja_command_, options->input_file, argc, argv); in ToolBrowse()
475 argv--; in ToolMSVC()
487 const char* target = (*n)->path().c_str(); in ToolTargetsList()
488 if ((*n)->in_edge()) { in ToolTargetsList()
489 printf("%s: %s\n", target, (*n)->in_edge()->rule_->name().c_str()); in ToolTargetsList()
491 ToolTargetsList((*n)->in_edge()->inputs_, depth - 1, indent + 1); in ToolTargetsList()
500 for (vector<Edge*>::iterator e = state->edges_.begin(); in ToolTargetsSourceList()
501 e != state->edges_.end(); ++e) { in ToolTargetsSourceList()
502 for (vector<Node*>::iterator inps = (*e)->inputs_.begin(); in ToolTargetsSourceList()
503 inps != (*e)->inputs_.end(); ++inps) { in ToolTargetsSourceList()
504 if (!(*inps)->in_edge()) in ToolTargetsSourceList()
505 printf("%s\n", (*inps)->path().c_str()); in ToolTargetsSourceList()
512 set<string> rules; in ToolTargetsList() local
515 for (vector<Edge*>::iterator e = state->edges_.begin(); in ToolTargetsList()
516 e != state->edges_.end(); ++e) { in ToolTargetsList()
517 if ((*e)->rule_->name() == rule_name) { in ToolTargetsList()
518 for (vector<Node*>::iterator out_node = (*e)->outputs_.begin(); in ToolTargetsList()
519 out_node != (*e)->outputs_.end(); ++out_node) { in ToolTargetsList()
520 rules.insert((*out_node)->path()); in ToolTargetsList()
526 for (set<string>::const_iterator i = rules.begin(); in ToolTargetsList()
527 i != rules.end(); ++i) { in ToolTargetsList()
535 for (vector<Edge*>::iterator e = state->edges_.begin(); in ToolTargetsList()
536 e != state->edges_.end(); ++e) { in ToolTargetsList()
537 for (vector<Node*>::iterator out_node = (*e)->outputs_.begin(); in ToolTargetsList()
538 out_node != (*e)->outputs_.end(); ++out_node) { in ToolTargetsList()
540 (*out_node)->path().c_str(), in ToolTargetsList()
541 (*e)->rule_->name().c_str()); in ToolTargetsList()
568 printf("%s: deps not found\n", (*it)->path().c_str()); in ToolDeps()
573 TimeStamp mtime = disk_interface.Stat((*it)->path(), &err); in ToolDeps()
574 if (mtime == -1) in ToolDeps()
577 (*it)->path().c_str(), deps->node_count, deps->mtime, in ToolDeps()
578 (!mtime || mtime > deps->mtime ? "STALE":"VALID")); in ToolDeps()
579 for (int i = 0; i < deps->node_count; ++i) in ToolDeps()
580 printf(" %s\n", deps->nodes[i]->path().c_str()); in ToolDeps()
650 // The rules tool uses getopt, and expects argv[0] to contain the name of in ToolRules()
651 // the tool, i.e. "rules". in ToolRules()
653 argv--; in ToolRules()
659 while ((opt = getopt(argc, argv, const_cast<char*>("hd"))) != -1) { in ToolRules()
666 printf("usage: ninja -t rules [options]\n" in ToolRules()
669 " -d also print the description of the rule\n" in ToolRules()
670 " -h print this message\n" in ToolRules()
676 argc -= optind; in ToolRules()
678 // Print rules in ToolRules()
680 typedef map<string, const Rule*> Rules; in ToolRules() typedef
681 const Rules& rules = state_.bindings_.GetRules(); in ToolRules() local
682 for (Rules::const_iterator i = rules.begin(); i != rules.end(); ++i) { in ToolRules()
683 printf("%s", i->first.c_str()); in ToolRules()
685 const Rule* rule = i->second; in ToolRules()
686 const EvalString* description = rule->GetBinding("description"); in ToolRules()
688 printf(": %s", description->Unparse().c_str()); in ToolRules()
700 printf("usage: ninja -t wincodepage\n"); in ToolWinCodePage()
703 printf("Build file encoding: %s\n", GetACP() == CP_UTF8? "UTF-8" : "ANSI"); in ToolWinCodePage()
712 if (!seen->insert(edge).second) in PrintCommands()
716 for (vector<Node*>::iterator in = edge->inputs_.begin(); in PrintCommands()
717 in != edge->inputs_.end(); ++in) in PrintCommands()
718 PrintCommands((*in)->in_edge(), seen, mode); in PrintCommands()
721 if (!edge->is_phony()) in PrintCommands()
722 puts(edge->EvaluateCommand().c_str()); in PrintCommands()
729 --argv; in ToolCommands()
735 while ((opt = getopt(argc, argv, const_cast<char*>("hs"))) != -1) { in ToolCommands()
742 printf("usage: ninja -t commands [options] [targets]\n" in ToolCommands()
745 " -s only print the final command to build [target], not the whole chain\n" in ToolCommands()
751 argc -= optind; in ToolCommands()
762 PrintCommands((*in)->in_edge(), &seen, mode); in ToolCommands()
771 if (!seen->insert(edge).second) in CollectInputs()
774 for (vector<Node*>::iterator in = edge->inputs_.begin(); in CollectInputs()
775 in != edge->inputs_.end(); ++in) in CollectInputs()
776 CollectInputs((*in)->in_edge(), seen, result); in CollectInputs()
778 if (!edge->is_phony()) { in CollectInputs()
779 edge->CollectInputs(true, result); in CollectInputs()
787 argv--; in ToolInputs()
792 while ((opt = getopt_long(argc, argv, "h", kLongOptions, NULL)) != -1) { in ToolInputs()
796 // clang-format off in ToolInputs()
798 "Usage '-t inputs [options] [targets]\n" in ToolInputs()
801 "explicit, implicit and order-only inputs, but not validation ones.\n\n" in ToolInputs()
803 " -h, --help Print this message.\n"); in ToolInputs()
804 // clang-format on in ToolInputs()
809 argc -= optind; in ToolInputs()
821 CollectInputs((*in)->in_edge(), &seen, &result); in ToolInputs()
837 argv--; in ToolClean()
844 while ((opt = getopt(argc, argv, const_cast<char*>("hgr"))) != -1) { in ToolClean()
854 printf("usage: ninja -t clean [options] [targets]\n" in ToolClean()
857 " -g also clean files marked as ninja generator output\n" in ToolClean()
858 " -r interpret targets as a list of rules to clean instead\n" in ToolClean()
864 argc -= optind; in ToolClean()
893 string command = edge->EvaluateCommand(); in EvaluateCommandWithRspfile()
897 string rspfile = edge->GetUnescapedRspfile(); in EvaluateCommandWithRspfile()
903 (command[index - 1] != '@' && in EvaluateCommandWithRspfile()
904 command.find("--option-file=") != index - 14 && in EvaluateCommandWithRspfile()
905 command.find("-f ") != index - 3)) in EvaluateCommandWithRspfile()
908 string rspfile_content = edge->GetBinding("rspfile_content"); in EvaluateCommandWithRspfile()
915 if (command[index - 1] == '@') { in EvaluateCommandWithRspfile()
916 command.replace(index - 1, rspfile.length() + 1, rspfile_content); in EvaluateCommandWithRspfile()
917 } else if (command.find("-f ") == index - 3) { in EvaluateCommandWithRspfile()
918 command.replace(index - 3, rspfile.length() + 3, rspfile_content); in EvaluateCommandWithRspfile()
919 } else { // --option-file syntax in EvaluateCommandWithRspfile()
920 command.replace(index - 14, rspfile.length() + 14, rspfile_content); in EvaluateCommandWithRspfile()
932 PrintJSONString(edge->inputs_[0]->path()); in printCompdb()
934 PrintJSONString(edge->outputs_[0]->path()); in printCompdb()
943 argv--; in ToolCompilationDatabase()
949 while ((opt = getopt(argc, argv, const_cast<char*>("hx"))) != -1) { in ToolCompilationDatabase()
958 "usage: ninja -t compdb [options] [rules]\n" in ToolCompilationDatabase()
961 " -x expand @rspfile style response file invocations\n" in ToolCompilationDatabase()
967 argc -= optind; in ToolCompilationDatabase()
986 if ((*e)->inputs_.empty()) in ToolCompilationDatabase()
996 if ((*e)->rule_->name() == argv[i]) { in ToolCompilationDatabase()
1026 argv--; in ToolRestat()
1030 while ((opt = getopt(argc, argv, const_cast<char*>("h"))) != -1) { in ToolRestat()
1034 printf("usage: ninja -t restat [outputs]\n"); in ToolRestat()
1039 argc -= optind; in ToolRestat()
1051 Error("loading build log %s: %s", log_path.c_str(), err.c_str()); in ToolRestat()
1072 Error("opening build log: %s", err.c_str()); in ToolRestat()
1086 "'2`9 `!2 `4!><3;5! J2$b,`!>;2!:2!`,d?b`!>\n26 `'-;,(<9!> $F3 )3.:!.2 d\"" in ToolUrtle()
1087 "2 ) !>\n30 7`2'<3!- \"=-='5 .2 `2-=\",!>\n25 .ze9$er2 .,cd16$bc.'\n22 .e" in ToolUrtle()
1096 count = count*10 + *p - '0'; in ToolUrtle()
1113 { "msvc", "build helper for MSVC cl.exe (DEPRECATED)", in ChooseTool()
1134 { "recompact", "recompacts ninja-internal data structures", in ChooseTool()
1136 { "restat", "restats all outputs in the build log", in ChooseTool()
1138 { "rules", "list all rules", in ChooseTool()
1153 for (const Tool* tool = &kTools[0]; tool->name; ++tool) { in ChooseTool()
1154 if (tool->desc) in ChooseTool()
1155 printf("%11s %s\n", tool->name, tool->desc); in ChooseTool()
1160 for (const Tool* tool = &kTools[0]; tool->name; ++tool) { in ChooseTool()
1161 if (tool->name == tool_name) in ChooseTool()
1166 for (const Tool* tool = &kTools[0]; tool->name; ++tool) in ChooseTool()
1167 words.push_back(tool->name); in ChooseTool()
1190 "multiple modes can be enabled via -d FOO -d BAR\n"); in DebugEnable()
1227 " phonycycle={err,warn} phony build statement references itself\n" in WarningEnable()
1231 options->dupe_edges_should_err = true; in WarningEnable()
1234 options->dupe_edges_should_err = false; in WarningEnable()
1237 options->phony_cycle_should_err = true; in WarningEnable()
1240 options->phony_cycle_should_err = false; in WarningEnable()
1268 Error("loading build log %s: %s", log_path.c_str(), err.c_str()); in OpenBuildLog()
1289 Error("opening build log: %s", err.c_str()); in OpenBuildLog()
1337 g_metrics->Report(); in DumpMetrics()
1342 printf("path->node hash load %.2f (%d entries / %d buckets)\n", in DumpMetrics()
1350 Error("creating build directory %s: %s", in EnsureBuildDirExists()
1362 status->Error("%s", err.c_str()); in RunBuild()
1373 status->Error("%s", err.c_str()); in RunBuild()
1376 // Added a target that is already up-to-date; not really in RunBuild()
1382 // Make sure restat rules do not see stale timestamps. in RunBuild()
1387 status->Info("no work to do."); in RunBuild()
1392 if (!builder.Build(&err)) { in RunBuild()
1393 status->Info("build stopped: %s.", err.c_str()); in RunBuild()
1406 /// Test example: C++ exception in a stack-unwind-block
1407 /// Real-world example: ninja launched a compiler to process a tricky
1437 config->parallelism = GuessParallelism(); in Refresh()
1443 /// Parse argv for command-line options.
1444 /// Returns an exit code, or -1 if Ninja should continue.
1459 while (!options->tool && in ReadFlags()
1461 NULL)) != -1) { in ReadFlags()
1468 options->input_file = optarg; in ReadFlags()
1474 Fatal("invalid -j parameter"); in ReadFlags()
1478 config->parallelism = value > 0 ? value : INT_MAX; in ReadFlags()
1486 Fatal("-k parameter not numeric; did you mean -k 0?"); in ReadFlags()
1491 config->failures_allowed = value > 0 ? value : INT_MAX; in ReadFlags()
1498 Fatal("-l parameter not numeric: did you mean -l 0.0?"); in ReadFlags()
1499 config->max_load_average = value; in ReadFlags()
1503 config->dry_run = true; in ReadFlags()
1506 options->tool = ChooseTool(optarg); in ReadFlags()
1507 if (!options->tool) in ReadFlags()
1511 config->verbosity = BuildConfig::VERBOSE; in ReadFlags()
1514 config->verbosity = BuildConfig::NO_STATUS_UPDATE; in ReadFlags()
1521 options->working_dir = optarg; in ReadFlags()
1534 *argc -= optind; in ReadFlags()
1536 return -1; in ReadFlags()
1544 options.input_file = "build.ninja"; in real_main()
1563 status->Info("Entering directory `%s'", options.working_dir); in real_main()
1565 Fatal("chdir to '%s' - %s", options.working_dir, strerror(errno)); in real_main()
1569 if (options.tool && options.tool->when == Tool::RUN_AFTER_FLAGS) { in real_main()
1573 exit((ninja.*options.tool->func)(&options, argc, argv)); in real_main()
1591 status->Error("%s", err.c_str()); in real_main()
1595 if (options.tool && options.tool->when == Tool::RUN_AFTER_LOAD) in real_main()
1596 exit((ninja.*options.tool->func)(&options, argc, argv)); in real_main()
1604 if (options.tool && options.tool->when == Tool::RUN_AFTER_LOGS) in real_main()
1605 exit((ninja.*options.tool->func)(&options, argc, argv)); in real_main()
1613 // Start the build over with the new manifest. in real_main()
1616 status->Error("rebuilding '%s': %s", options.input_file, err.c_str()); in real_main()
1628 status->Error("manifest '%s' still dirty after %d tries, perhaps system time is not set", in real_main()
1638 // block (e.g. an exception in a stack-unwind-block). in main()