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

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

Issue 311733002: Redo escaping in GN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 6 months 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 | Annotate | Revision Log
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 21 matching lines...) Expand all
32 base::FilePath executable; 32 base::FilePath executable;
33 PathService::Get(base::FILE_EXE, &executable); 33 PathService::Get(base::FILE_EXE, &executable);
34 34
35 CommandLine cmdline(executable.NormalizePathSeparatorsTo('/')); 35 CommandLine cmdline(executable.NormalizePathSeparatorsTo('/'));
36 cmdline.AppendArg("gen"); 36 cmdline.AppendArg("gen");
37 cmdline.AppendArg(build_settings->build_dir().value()); 37 cmdline.AppendArg(build_settings->build_dir().value());
38 cmdline.AppendSwitchPath("--root", build_settings->root_path()); 38 cmdline.AppendSwitchPath("--root", build_settings->root_path());
39 cmdline.AppendSwitch("-q"); // Don't write output. 39 cmdline.AppendSwitch("-q"); // Don't write output.
40 40
41 EscapeOptions escape_shell; 41 EscapeOptions escape_shell;
42 escape_shell.mode = ESCAPE_SHELL; 42 escape_shell.mode = ESCAPE_NINJA_COMMAND;
43 #if defined(OS_WIN) 43 #if defined(OS_WIN)
44 // The command line code quoting varies by platform. We have one string, 44 // The command line code quoting varies by platform. We have one string,
45 // possibly with spaces, that we want to quote. The Windows command line 45 // possibly with spaces, that we want to quote. The Windows command line
46 // quotes again, so we don't want quoting. The Posix one doesn't. 46 // quotes again, so we don't want quoting. The Posix one doesn't.
47 escape_shell.inhibit_quoting = true; 47 escape_shell.inhibit_quoting = true;
48 #endif 48 #endif
49 49
50 const CommandLine& our_cmdline = *CommandLine::ForCurrentProcess(); 50 const CommandLine& our_cmdline = *CommandLine::ForCurrentProcess();
51 const CommandLine::SwitchMap& switches = our_cmdline.GetSwitches(); 51 const CommandLine::SwitchMap& switches = our_cmdline.GetSwitches();
52 for (CommandLine::SwitchMap::const_iterator i = switches.begin(); 52 for (CommandLine::SwitchMap::const_iterator i = switches.begin();
(...skipping 22 matching lines...) Expand all
75 const BuildSettings* build_settings, 75 const BuildSettings* build_settings,
76 const std::vector<const Settings*>& all_settings, 76 const std::vector<const Settings*>& all_settings,
77 const std::vector<const Target*>& default_toolchain_targets, 77 const std::vector<const Target*>& default_toolchain_targets,
78 std::ostream& out, 78 std::ostream& out,
79 std::ostream& dep_out) 79 std::ostream& dep_out)
80 : build_settings_(build_settings), 80 : build_settings_(build_settings),
81 all_settings_(all_settings), 81 all_settings_(all_settings),
82 default_toolchain_targets_(default_toolchain_targets), 82 default_toolchain_targets_(default_toolchain_targets),
83 out_(out), 83 out_(out),
84 dep_out_(dep_out), 84 dep_out_(dep_out),
85 path_output_(build_settings->build_dir(), ESCAPE_NINJA, false), 85 path_output_(build_settings->build_dir(), ESCAPE_NINJA),
86 helper_(build_settings) { 86 helper_(build_settings) {
87 } 87 }
88 88
89 NinjaBuildWriter::~NinjaBuildWriter() { 89 NinjaBuildWriter::~NinjaBuildWriter() {
90 } 90 }
91 91
92 void NinjaBuildWriter::Run() { 92 void NinjaBuildWriter::Run() {
93 WriteNinjaRules(); 93 WriteNinjaRules();
94 WriteSubninjas(); 94 WriteSubninjas();
95 WritePhonyAndAllRules(); 95 WritePhonyAndAllRules();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 EscapeOptions ninja_escape; 244 EscapeOptions ninja_escape;
245 ninja_escape.mode = ESCAPE_NINJA; 245 ninja_escape.mode = ESCAPE_NINJA;
246 246
247 // Escape for special chars Ninja will handle. 247 // Escape for special chars Ninja will handle.
248 std::string escaped = EscapeString(phony_name, ninja_escape, NULL); 248 std::string escaped = EscapeString(phony_name, ninja_escape, NULL);
249 249
250 out_ << "build " << escaped << ": phony "; 250 out_ << "build " << escaped << ": phony ";
251 path_output_.WriteFile(out_, target_file); 251 path_output_.WriteFile(out_, target_file);
252 out_ << std::endl; 252 out_ << std::endl;
253 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698