OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/ninja_build_writer.h" | 5 #include "tools/gn/ninja_build_writer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <fstream> | 9 #include <fstream> |
10 #include <map> | 10 #include <map> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // The last one we encountered. | 46 // The last one we encountered. |
47 const Target* last_seen; | 47 const Target* last_seen; |
48 }; | 48 }; |
49 | 49 |
50 std::string GetSelfInvocationCommand(const BuildSettings* build_settings) { | 50 std::string GetSelfInvocationCommand(const BuildSettings* build_settings) { |
51 base::FilePath executable; | 51 base::FilePath executable; |
52 PathService::Get(base::FILE_EXE, &executable); | 52 PathService::Get(base::FILE_EXE, &executable); |
53 | 53 |
54 base::CommandLine cmdline(executable.NormalizePathSeparatorsTo('/')); | 54 base::CommandLine cmdline(executable.NormalizePathSeparatorsTo('/')); |
| 55 |
| 56 // Use "." for the directory to generate. When Ninja runs the command it |
| 57 // will have the build directory as the current one. Coding it explicitly |
| 58 // will cause everything to get confused if the user renames the directory. |
55 cmdline.AppendArg("gen"); | 59 cmdline.AppendArg("gen"); |
56 cmdline.AppendArg(build_settings->build_dir().value()); | 60 cmdline.AppendArg("."); |
| 61 |
57 cmdline.AppendSwitchPath(std::string("--") + switches::kRoot, | 62 cmdline.AppendSwitchPath(std::string("--") + switches::kRoot, |
58 build_settings->root_path()); | 63 build_settings->root_path()); |
59 // Successful automatic invocations shouldn't print output. | 64 // Successful automatic invocations shouldn't print output. |
60 cmdline.AppendSwitch(std::string("-") + switches::kQuiet); | 65 cmdline.AppendSwitch(std::string("-") + switches::kQuiet); |
61 | 66 |
62 EscapeOptions escape_shell; | 67 EscapeOptions escape_shell; |
63 escape_shell.mode = ESCAPE_NINJA_COMMAND; | 68 escape_shell.mode = ESCAPE_NINJA_COMMAND; |
64 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
65 // The command line code quoting varies by platform. We have one string, | 70 // The command line code quoting varies by platform. We have one string, |
66 // possibly with spaces, that we want to quote. The Windows command line | 71 // possibly with spaces, that we want to quote. The Windows command line |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 EscapeOptions ninja_escape; | 451 EscapeOptions ninja_escape; |
447 ninja_escape.mode = ESCAPE_NINJA; | 452 ninja_escape.mode = ESCAPE_NINJA; |
448 | 453 |
449 // Escape for special chars Ninja will handle. | 454 // Escape for special chars Ninja will handle. |
450 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); | 455 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); |
451 | 456 |
452 out_ << "build " << escaped << ": phony "; | 457 out_ << "build " << escaped << ": phony "; |
453 path_output_.WriteFile(out_, target->dependency_output_file()); | 458 path_output_.WriteFile(out_, target->dependency_output_file()); |
454 out_ << std::endl; | 459 out_ << std::endl; |
455 } | 460 } |
OLD | NEW |