Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: tools/gn/ninja_build_writer.cc

Issue 819223002: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/gn_main.cc ('k') | tools/gn/scheduler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 17 matching lines...) Expand all
28 #if defined(OS_WIN) 28 #if defined(OS_WIN)
29 #include <windows.h> 29 #include <windows.h>
30 #endif 30 #endif
31 31
32 namespace { 32 namespace {
33 33
34 std::string GetSelfInvocationCommand(const BuildSettings* build_settings) { 34 std::string GetSelfInvocationCommand(const BuildSettings* build_settings) {
35 base::FilePath executable; 35 base::FilePath executable;
36 PathService::Get(base::FILE_EXE, &executable); 36 PathService::Get(base::FILE_EXE, &executable);
37 37
38 CommandLine cmdline(executable.NormalizePathSeparatorsTo('/')); 38 base::CommandLine cmdline(executable.NormalizePathSeparatorsTo('/'));
39 cmdline.AppendArg("gen"); 39 cmdline.AppendArg("gen");
40 cmdline.AppendArg(build_settings->build_dir().value()); 40 cmdline.AppendArg(build_settings->build_dir().value());
41 cmdline.AppendSwitchPath(std::string("--") + switches::kRoot, 41 cmdline.AppendSwitchPath(std::string("--") + switches::kRoot,
42 build_settings->root_path()); 42 build_settings->root_path());
43 // Successful automatic invocations shouldn't print output. 43 // Successful automatic invocations shouldn't print output.
44 cmdline.AppendSwitch(std::string("-") + switches::kQuiet); 44 cmdline.AppendSwitch(std::string("-") + switches::kQuiet);
45 45
46 EscapeOptions escape_shell; 46 EscapeOptions escape_shell;
47 escape_shell.mode = ESCAPE_NINJA_COMMAND; 47 escape_shell.mode = ESCAPE_NINJA_COMMAND;
48 #if defined(OS_WIN) 48 #if defined(OS_WIN)
49 // The command line code quoting varies by platform. We have one string, 49 // The command line code quoting varies by platform. We have one string,
50 // possibly with spaces, that we want to quote. The Windows command line 50 // possibly with spaces, that we want to quote. The Windows command line
51 // quotes again, so we don't want quoting. The Posix one doesn't. 51 // quotes again, so we don't want quoting. The Posix one doesn't.
52 escape_shell.inhibit_quoting = true; 52 escape_shell.inhibit_quoting = true;
53 #endif 53 #endif
54 54
55 const CommandLine& our_cmdline = *CommandLine::ForCurrentProcess(); 55 const base::CommandLine& our_cmdline =
56 const CommandLine::SwitchMap& switches = our_cmdline.GetSwitches(); 56 *base::CommandLine::ForCurrentProcess();
57 for (CommandLine::SwitchMap::const_iterator i = switches.begin(); 57 const base::CommandLine::SwitchMap& switches = our_cmdline.GetSwitches();
58 for (base::CommandLine::SwitchMap::const_iterator i = switches.begin();
58 i != switches.end(); ++i) { 59 i != switches.end(); ++i) {
59 // Only write arguments we haven't already written. Always skip "args" 60 // Only write arguments we haven't already written. Always skip "args"
60 // since those will have been written to the file and will be used 61 // since those will have been written to the file and will be used
61 // implicitly in the future. Keeping --args would mean changes to the file 62 // implicitly in the future. Keeping --args would mean changes to the file
62 // would be ignored. 63 // would be ignored.
63 if (i->first != switches::kQuiet && 64 if (i->first != switches::kQuiet &&
64 i->first != switches::kRoot && 65 i->first != switches::kRoot &&
65 i->first != switches::kArgs) { 66 i->first != switches::kArgs) {
66 std::string escaped_value = 67 std::string escaped_value =
67 EscapeString(FilePathToUTF8(i->second), escape_shell, NULL); 68 EscapeString(FilePathToUTF8(i->second), escape_shell, NULL);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 EscapeOptions ninja_escape; 289 EscapeOptions ninja_escape;
289 ninja_escape.mode = ESCAPE_NINJA; 290 ninja_escape.mode = ESCAPE_NINJA;
290 291
291 // Escape for special chars Ninja will handle. 292 // Escape for special chars Ninja will handle.
292 std::string escaped = EscapeString(phony_name, ninja_escape, NULL); 293 std::string escaped = EscapeString(phony_name, ninja_escape, NULL);
293 294
294 out_ << "build " << escaped << ": phony "; 295 out_ << "build " << escaped << ": phony ";
295 path_output_.WriteFile(out_, target_file); 296 path_output_.WriteFile(out_, target_file);
296 out_ << std::endl; 297 out_ << std::endl;
297 } 298 }
OLDNEW
« no previous file with comments | « tools/gn/gn_main.cc ('k') | tools/gn/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698