• Home
  • Raw
  • Download

Lines Matching +full:ninja +full:- +full:build

2 // Use of this source code is governed by a BSD-style license that can be
42 const char kSwitchCleanStale[] = "clean-stale";
56 const char kSwitchIdeRootTarget[] = "ide-root-target";
57 const char kSwitchNinjaExecutable[] = "ninja-executable";
58 const char kSwitchNinjaExtraArgs[] = "ninja-extra-args";
59 const char kSwitchNinjaOutputsFile[] = "ninja-outputs-file";
60 const char kSwitchNinjaOutputsScript[] = "ninja-outputs-script";
61 const char kSwitchNinjaOutputsScriptArgs[] = "ninja-outputs-script-args";
62 const char kSwitchNoDeps[] = "no-deps";
64 const char kSwitchXcodeProject[] = "xcode-project";
65 const char kSwitchXcodeBuildSystem[] = "xcode-build-system";
68 const char kSwitchXcodeConfigurations[] = "xcode-configs";
69 const char kSwitchXcodeConfigurationBuildPath[] = "xcode-config-build-dir";
71 "xcode-additional-files-patterns";
72 const char kSwitchXcodeAdditionalFilesRoots[] = "xcode-additional-files-roots";
73 const char kSwitchJsonFileName[] = "json-file-name";
74 const char kSwitchJsonIdeScript[] = "json-ide-script";
75 const char kSwitchJsonIdeScriptArgs[] = "json-ide-script-args";
76 const char kSwitchExportCompileCommands[] = "export-compile-commands";
77 const char kSwitchExportRustProject[] = "export-rust-project";
79 // A map type used to implement --ide=ninja_outputs
82 // Collects Ninja rules for each toolchain. The lock protects the rules
98 // Called on worker thread to write the ninja file.
103 write_info->want_ninja_outputs ? &target_ninja_outputs : nullptr; in BackgroundDoWrite()
106 std::lock_guard<std::mutex> lock(write_info->lock); in BackgroundDoWrite()
107 resolved = &((*write_info->resolved_map)[std::this_thread::get_id()]); in BackgroundDoWrite()
115 std::lock_guard<std::mutex> lock(write_info->lock); in BackgroundDoWrite()
116 write_info->rules[target->toolchain()].emplace_back(target, in BackgroundDoWrite()
119 if (write_info->want_ninja_outputs) { in BackgroundDoWrite()
120 write_info->ninja_outputs_map.emplace(target, in BackgroundDoWrite()
129 const Item* item = record->item(); in ItemResolvedAndGeneratedCallback()
130 const Target* target = item->AsTarget(); in ItemResolvedAndGeneratedCallback()
132 g_scheduler->ScheduleWork( in ItemResolvedAndGeneratedCallback()
146 OutputFile output_file(targets[0]->settings()->build_settings(), file); in FindTargetThatGeneratesFile()
148 for (const auto& cur_output : target->computed_outputs()) { in FindTargetThatGeneratesFile()
167 targets[0]->settings()->default_toolchain_label(); in PrintInvalidGeneratedInput()
169 if (target->settings()->toolchain_label() != default_toolchain) { in PrintInvalidGeneratedInput()
177 generator->settings()->toolchain_label() != default_toolchain) in PrintInvalidGeneratedInput()
185 err += " " + target->label().GetUserVisibleName(show_toolchains) + "\n"; in PrintInvalidGeneratedInput()
190 err += generator->label().GetUserVisibleName(show_toolchains); in PrintInvalidGeneratedInput()
192 err += "but no targets in the build generate that file."; in PrintInvalidGeneratedInput()
202 g_scheduler->GetUnknownGeneratedInputs(); in CheckForInvalidGeneratedInputs()
210 auto end_of_range = unknown_inputs.upper_bound(cur->first); in CheckForInvalidGeneratedInputs()
213 SourceFile bad_input = cur->first; in CheckForInvalidGeneratedInputs()
216 targets.push_back((cur++)->second); in CheckForInvalidGeneratedInputs()
218 PrintInvalidGeneratedInput(setup->builder(), bad_input, targets); in CheckForInvalidGeneratedInputs()
244 bool quiet = command_line->HasSwitch(switches::kQuiet); in RunIdeWriter()
269 if (command_line->HasSwitch(kSwitchSln)) in RunIdeWriter()
270 sln_name = command_line->GetSwitchValueString(kSwitchSln); in RunIdeWriter()
272 if (command_line->HasSwitch(kSwitchFilters)) in RunIdeWriter()
273 filters = command_line->GetSwitchValueString(kSwitchFilters); in RunIdeWriter()
275 if (command_line->HasSwitch(kSwitchIdeValueWinSdk)) in RunIdeWriter()
276 win_kit = command_line->GetSwitchValueString(kSwitchIdeValueWinSdk); in RunIdeWriter()
278 if (command_line->HasSwitch(kSwitchNinjaExtraArgs)) { in RunIdeWriter()
280 command_line->GetSwitchValueString(kSwitchNinjaExtraArgs); in RunIdeWriter()
283 if (command_line->HasSwitch(kSwitchNinjaExecutable)) { in RunIdeWriter()
285 command_line->GetSwitchValueString(kSwitchNinjaExecutable); in RunIdeWriter()
287 bool no_deps = command_line->HasSwitch(kSwitchNoDeps); in RunIdeWriter()
299 command_line->GetSwitchValueString(kSwitchXcodeProject), in RunIdeWriter()
300 command_line->GetSwitchValueString(kSwitchIdeRootTarget), in RunIdeWriter()
301 command_line->GetSwitchValueString(kSwitchNinjaExecutable), in RunIdeWriter()
302 command_line->GetSwitchValueString(kSwitchFilters), in RunIdeWriter()
303 command_line->GetSwitchValueString(kSwitchXcodeConfigurations), in RunIdeWriter()
304 command_line->GetSwitchValuePath(kSwitchXcodeConfigurationBuildPath), in RunIdeWriter()
305 command_line->GetSwitchValueNative(kSwitchXcodeAdditionalFilesPatterns), in RunIdeWriter()
306 command_line->GetSwitchValueNative(kSwitchXcodeAdditionalFilesRoots), in RunIdeWriter()
315 command_line->GetSwitchValueString(kSwitchXcodeBuildSystem); in RunIdeWriter()
322 *err = Err(Location(), "Unknown build system: " + build_system); in RunIdeWriter()
337 if (command_line->HasSwitch(kSwitchIdeRootTarget)) in RunIdeWriter()
338 root_target = command_line->GetSwitchValueString(kSwitchIdeRootTarget); in RunIdeWriter()
349 command_line->GetSwitchValueString(kSwitchJsonFileName); in RunIdeWriter()
353 command_line->GetSwitchValueString(kSwitchJsonIdeScript); in RunIdeWriter()
355 command_line->GetSwitchValueString(kSwitchJsonIdeScriptArgs); in RunIdeWriter()
356 std::string filters = command_line->GetSwitchValueString(kSwitchFilters); in RunIdeWriter()
378 bool quiet = command_line->HasSwitch(switches::kQuiet); in RunRustProjectWriter()
381 std::string file_name = "rust-project.json"; in RunRustProjectWriter()
385 OutputString("Generating rust-project.json took " + in RunRustProjectWriter()
398 command_line->HasSwitch(kSwitchExportCompileCommands); in RunCompileCommandsWriter()
404 bool quiet = command_line->HasSwitch(switches::kQuiet); in RunCompileCommandsWriter()
407 // The compilation database file goes in the build directory. in RunCompileCommandsWriter()
418 command_line->GetSwitchValueString(kSwitchExportCompileCommands); in RunCompileCommandsWriter()
438 // tools. Since these tools can re-write ninja build log and dep logs, it is in RunNinjaPostProcessTools()
439 // really important that ninja executable used for tools matches the in RunNinjaPostProcessTools()
443 *err = Err(Location(), "No --ninja-executable provided.", in RunNinjaPostProcessTools()
444 "--clean-stale requires a ninja executable to run. You can " in RunNinjaPostProcessTools()
445 "provide one on the command line via --ninja-executable."); in RunNinjaPostProcessTools()
453 build_settings->GetFullPath(build_settings->build_dir()); in RunNinjaPostProcessTools()
456 if (build_settings->ninja_required_version() < Version{1, 10, 0}) { in RunNinjaPostProcessTools()
457 *err = Err(Location(), "Need a ninja executable at least version 1.10.0.", in RunNinjaPostProcessTools()
458 "--clean-stale requires a ninja executable of version 1.10.0 " in RunNinjaPostProcessTools()
472 // If we have a ninja version that supports restat, we should restat the in RunNinjaPostProcessTools()
473 // build.ninja or build.ninja.stamp files so the next ninja invocation in RunNinjaPostProcessTools()
474 // will use the right mtimes. If gen is being invoked as part of a re-gen in RunNinjaPostProcessTools()
475 // (ie, ninja is invoking gn gen), then we can elide this restat, as in RunNinjaPostProcessTools()
476 // ninja will restat the appropriate file anyways after it is complete. in RunNinjaPostProcessTools()
478 build_settings->ninja_required_version() >= Version{1, 10, 0}) { in RunNinjaPostProcessTools()
480 base::FilePath(FILE_PATH_LITERAL("build.ninja")), in RunNinjaPostProcessTools()
481 base::FilePath(FILE_PATH_LITERAL("build.ninja.stamp")), in RunNinjaPostProcessTools()
494 const char kGen_HelpShort[] = "gen: Generate ninja files.";
496 R"(gn gen [--check] [<ide options>] <out_dir>
498 Generates ninja files from the current tree and puts them in the given output
501 The output directory can be a source-repo-absolute path name such as:
506 "gn gen --check" is the same as running "gn check". "gn gen --check=system" is
507 the same as running "gn check --check-system". See "gn help check" for
510 See "gn help switches" for the common command-line switches.
514 --ninja-executable=<string>
515 Can be used to specify the ninja executable to use. This executable will
516 be used as an IDE option to indicate which ninja to use for building. This
518 restat on generated ninja files and for use with --clean-stale.
520 --clean-stale
522 the build directory, and their records pruned from the ninja build log and
523 dependency database after the ninja build graph has been generated. This
524 option requires a ninja executable of at least version 1.10.0. It can be
525 provided by the --ninja-executable switch. Also see "gn help clean_stale".
532 --ide=<ide_name>
534 "eclipse" - Eclipse CDT settings file.
535 "vs" - Visual Studio project/solution files.
537 "vs2013" - Visual Studio 2013 project/solution files.
538 "vs2015" - Visual Studio 2015 project/solution files.
539 "vs2017" - Visual Studio 2017 project/solution files.
540 "vs2019" - Visual Studio 2019 project/solution files.
541 "vs2022" - Visual Studio 2022 project/solution files.
542 "xcode" - Xcode workspace/solution files.
543 "qtcreator" - QtCreator project files.
544 "json" - JSON file containing target information
546 --filters=<path_prefixes>
547 Semicolon-separated list of label patterns used to limit the set of
554 --sln=<file_name>
556 root build directory.
558 --no-deps
560 --filters option works. Only directly matching targets are included.
562 --winsdk=<sdk_version>
567 --ninja-executable=<string>
568 Can be used to specify the ninja executable to use when building.
570 --ninja-extra-args=<string>
571 This string is passed without any quoting to the ninja invocation
572 command-line. Can be used to configure ninja flags, like "-j".
576 --xcode-project=<file_name>
578 written to the root build directory.
580 --xcode-build-system=<value>
581 Configure the build system to use for the Xcode project. Supported
583 "legacy" - Legacy Build system
584 "new" - New Build System
586 --xcode-configs=<config_name_list>
587 Configure the list of build configuration supported by the generated
588 project. If specified, must be a list of semicolon-separated strings.
590 project derived from the build directory.
592 --xcode-config-build-dir=<string>
595 the directory where ninja needs to be invoked. This variable can be
596 used to build for multiple configuration / platform / environment from
598 gn build directory with the correct args.gn for each).
603 --xcode-additional-files-patterns=<pattern_list>
604 If present, must be a list of semicolon-separated file patterns. It
609 --xcode-additional-files-roots=<path_list>
610 If present, must be a list of semicolon-separated paths. It will be used
614 --ninja-executable=<string>
615 Can be used to specify the ninja executable to use when building.
617 --ninja-extra-args=<string>
618 This string is passed without any quoting to the ninja invocation
619 command-line. Can be used to configure ninja flags, like "-j".
621 --ide-root-target=<target_name>
623 "All" invokes ninja without any target and builds everything.
627 --ide-root-target=<target_name>
629 to contain files of it and its dependencies. If unset, the whole build
650 --json-file-name=<json_file_name>
653 --json-ide-script=<path_to_python_script>
659 --json-ide-script-args=<argument>
662 Ninja Outputs
664 The --ninja-outputs-file=<FILE> option dumps a JSON file that maps GN labels
665 to their Ninja output paths. This can be later processed to build an index
666 to convert between Ninja targets and GN ones before or after the build itself.
679 --ninja-outputs-script=<path_to_python_script>
685 --ninja-outputs-script-args=<argument>
690 --export-rust-project
691 Produces a rust-project.json file in the root of the build directory
693 replay of individual compilations independent of the build system.
696 --add-export-compile-commands=<label_pattern>
707 --add-export-compile-commands=//tools:my_tool
708 --add-export-compile-commands="//base/*"
710 --export-compile-commands[=<target_name1,target_name2...>]
712 Please use --add-export-compile-commands for per-user configuration, and
713 the "export_compile_commands" value in the project-level .gn file (see
714 "gn help dotfile") for per-project configuration.
717 "gn help dotfile") as well as the --add-export-compile-commands switch.
722 - "//path/to/src:foo"
723 - "//other/path:foo"
724 - "//foo:foo"
726 - "//foo:bar"
733 Err(Location(), "Need exactly one build directory to generate.",
743 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kArgs)) {
744 setup->set_gen_empty_args(true);
746 if (!setup->DoSetup(args[0], true))
751 if (command_line->HasSwitch(kSwitchCheck)) {
752 setup->set_check_public_headers(true);
753 if (command_line->GetSwitchValueString(kSwitchCheck) == "system")
754 setup->set_check_system_includes(true);
757 // If this is a regeneration, replace existing build.ninja and build.ninja.d
758 // with just enough for ninja to call GN and regenerate ninja files. This
759 // removes any potential soon-to-be-dangling references and ensures that
761 if (command_line->HasSwitch(switches::kRegeneration)) {
762 if (!commands::PrepareForRegeneration(&setup->build_settings())) {
767 // Cause the load to also generate the ninja files for each target.
770 command_line->HasSwitch(kSwitchNinjaOutputsFile);
772 setup->builder().set_resolved_and_generated_callback(
777 // Do the actual load. This will also write out the target ninja files.
778 if (!setup->Run())
781 if (command_line->HasSwitch(switches::kVerbose))
782 OutputString("Build graph constructed in " +
787 // the ninja files have deterministic content.
792 return a.first->label() < b.first->label();
797 // Write the root ninja files.
798 if (!NinjaWriter::RunAndWriteFiles(&setup->build_settings(), setup->builder(),
805 &setup->build_settings(),
806 command_line->GetSwitchValuePath(switches::kNinjaExecutable),
807 command_line->HasSwitch(switches::kRegeneration),
808 command_line->HasSwitch(kSwitchCleanStale), &err)) {
816 command_line->GetSwitchValueString(kSwitchNinjaOutputsFile);
818 Err(Location(), "The --ninja-outputs-file argument cannot be empty!")
823 bool quiet = command_line->HasSwitch(switches::kQuiet);
826 command_line->GetSwitchValueString(kSwitchNinjaOutputsScript);
829 command_line->GetSwitchValueString(kSwitchNinjaOutputsScriptArgs);
832 write_info.ninja_outputs_map, &setup->build_settings(), file_name,
838 if (!command_line->HasSwitch(switches::kQuiet)) {
840 "Generating Ninja outputs file took %" PRId64 "ms\n",
845 if (!WriteRuntimeDepsFilesIfNecessary(&setup->build_settings(),
846 setup->builder(), &err)) {
854 if (command_line->HasSwitch(kSwitchIde) &&
855 !RunIdeWriter(command_line->GetSwitchValueString(kSwitchIde),
856 &setup->build_settings(), setup->builder(), &err)) {
866 if (command_line->HasSwitch(kSwitchExportRustProject) &&
867 !RunRustProjectWriter(&setup->build_settings(), setup->builder(), &err)) {
874 if (!command_line->HasSwitch(switches::kQuiet)) {
884 setup->scheduler().input_file_manager()->GetInputFileCount()) +
890 // Just like the build graph, leak the resolved data to avoid expensive