GN: use the correct directory for self-invocation. GN writes a Ninja command to re-invoke GN when a build file changes. Previously this hardcoded the build directory. But if the user renames the build directory, Ninja will think the files are out of date but GN will keep regenerating files in another directory. This changes the directory to "." because Ninja will invoke all commands with the build directory as the current one. BUG=639965 Review-Url: https://codereview.chromium.org/2389133003 Cr-Original-Commit-Position: refs/heads/master@{#422995} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: eceed2e7c13045dcabfa07e7b7d7b4cd2807a0ec
diff --git a/tools/gn/ninja_build_writer.cc b/tools/gn/ninja_build_writer.cc index fba1ccb..a0dd8ce 100644 --- a/tools/gn/ninja_build_writer.cc +++ b/tools/gn/ninja_build_writer.cc
@@ -52,8 +52,13 @@ PathService::Get(base::FILE_EXE, &executable); base::CommandLine cmdline(executable.NormalizePathSeparatorsTo('/')); + + // Use "." for the directory to generate. When Ninja runs the command it + // will have the build directory as the current one. Coding it explicitly + // will cause everything to get confused if the user renames the directory. cmdline.AppendArg("gen"); - cmdline.AppendArg(build_settings->build_dir().value()); + cmdline.AppendArg("."); + cmdline.AppendSwitchPath(std::string("--") + switches::kRoot, build_settings->root_path()); // Successful automatic invocations shouldn't print output.