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 <fstream> | 7 #include <fstream> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" |
11 #include "base/process/process_handle.h" | 12 #include "base/process/process_handle.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "tools/gn/build_settings.h" | 15 #include "tools/gn/build_settings.h" |
15 #include "tools/gn/escape.h" | 16 #include "tools/gn/escape.h" |
16 #include "tools/gn/filesystem_utils.h" | 17 #include "tools/gn/filesystem_utils.h" |
17 #include "tools/gn/input_file_manager.h" | 18 #include "tools/gn/input_file_manager.h" |
18 #include "tools/gn/scheduler.h" | 19 #include "tools/gn/scheduler.h" |
19 #include "tools/gn/target.h" | 20 #include "tools/gn/target.h" |
20 #include "tools/gn/trace.h" | 21 #include "tools/gn/trace.h" |
21 | 22 |
22 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
23 #include <windows.h> | 24 #include <windows.h> |
24 #endif | 25 #endif |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 std::string GetSelfInvocationCommand(const BuildSettings* build_settings) { | 29 std::string GetSelfInvocationCommand(const BuildSettings* build_settings) { |
29 #if defined(OS_WIN) | 30 base::FilePath executable; |
30 wchar_t module[MAX_PATH]; | 31 PathService::Get(base::FILE_EXE, &executable); |
31 GetModuleFileName(NULL, module, MAX_PATH); | |
32 //result = "\"" + base::WideToUTF8(module) + "\""; | |
33 base::FilePath executable(module); | |
34 #elif defined(OS_MACOSX) | |
35 // FIXME(brettw) write this on Mac! | |
36 base::FilePath executable("../Debug/gn"); | |
37 #else | |
38 base::FilePath executable = | |
39 base::GetProcessExecutablePath(base::GetCurrentProcessHandle()); | |
40 #endif | |
41 | |
42 /* | |
43 // Append the root path. | |
44 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | |
45 result += " --root=\"" + FilePathToUTF8(settings->root_path()) + "\""; | |
46 */ | |
47 | 32 |
48 CommandLine cmdline(executable); | 33 CommandLine cmdline(executable); |
49 cmdline.AppendSwitchPath("--root", build_settings->root_path()); | 34 cmdline.AppendSwitchPath("--root", build_settings->root_path()); |
50 cmdline.AppendSwitch("-q"); // Don't write output. | 35 cmdline.AppendSwitch("-q"); // Don't write output. |
51 | 36 |
52 EscapeOptions escape_shell; | 37 EscapeOptions escape_shell; |
53 escape_shell.mode = ESCAPE_SHELL; | 38 escape_shell.mode = ESCAPE_SHELL; |
54 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
55 // The command line code quoting varies by platform. We have one string, | 40 // The command line code quoting varies by platform. We have one string, |
56 // possibly with spaces, that we want to quote. The Windows command line | 41 // possibly with spaces, that we want to quote. The Windows command line |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 all_rules.append(" $\n "); | 190 all_rules.append(" $\n "); |
206 all_rules.append(target_file.value()); | 191 all_rules.append(target_file.value()); |
207 } | 192 } |
208 | 193 |
209 if (!all_rules.empty()) { | 194 if (!all_rules.empty()) { |
210 out_ << "\nbuild all: phony " << all_rules << std::endl; | 195 out_ << "\nbuild all: phony " << all_rules << std::endl; |
211 out_ << "default all" << std::endl; | 196 out_ << "default all" << std::endl; |
212 } | 197 } |
213 } | 198 } |
214 | 199 |
OLD | NEW |