summaryrefslogtreecommitdiffstats
path: root/tools/gn/path_output.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 17:19:03 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 17:19:03 +0000
commit97e39977482aaf3bcee30d64c632ad7272757a1d (patch)
tree6b36d45794e9e0f8a780652c24b21085ad73105d /tools/gn/path_output.cc
parent47600beff0c5d467201cca76757e039e0a863fdb (diff)
downloadchromium_src-97e39977482aaf3bcee30d64c632ad7272757a1d.zip
chromium_src-97e39977482aaf3bcee30d64c632ad7272757a1d.tar.gz
chromium_src-97e39977482aaf3bcee30d64c632ad7272757a1d.tar.bz2
Redo escaping in GN.
This makes Windows escaping more correct and handles Posix shell characters better as well. Now there are completely different codepaths for Windows and Posix escaping. I removed JSON escaping since this is no longer needed now that we no longer write GYP files. I no longer have a separate SHELL and NINJA modes. Instead, I have pure NINJA mode for writing file names for Ninja to interpret, and NINKA_FORK mode which does NINJA escaping plus the correct platform-specific rules for the method Ninja uses for running build steps on the current system. Includes used to always be quoted ("-I../..") which was ugly. Now they're not quoted unless necessary (which is almost never). If it requires quoting, it will do -I"foo bar" which looks a bit odd but saves a bunch of special casing in the output code. Previously defines weren't quoted at all. Now they work like include dirs. Removed the convert_slashes flag on PathOutput which is no longer used. Removed some backslash special-casing in the unit tests on Windows. These are no longer necessary since we changed path output on Windows to use forward-slashes. Fix base's StackString on GCC. Previously this was only used on Windows-specific code. Fix mesa Windows GN build. BUG=358764 R=scottmg@chromium.org Review URL: https://codereview.chromium.org/311733002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275174 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/path_output.cc')
-rw-r--r--tools/gn/path_output.cc16
1 files changed, 3 insertions, 13 deletions
diff --git a/tools/gn/path_output.cc b/tools/gn/path_output.cc
index 4e71f9b..7e739b6 100644
--- a/tools/gn/path_output.cc
+++ b/tools/gn/path_output.cc
@@ -9,9 +9,7 @@
#include "tools/gn/output_file.h"
#include "tools/gn/string_utils.h"
-PathOutput::PathOutput(const SourceDir& current_dir,
- EscapingMode escaping,
- bool convert_slashes)
+PathOutput::PathOutput(const SourceDir& current_dir, EscapingMode escaping)
: current_dir_(current_dir) {
CHECK(current_dir.is_source_absolute())
<< "Currently this only supports writing to output directories inside "
@@ -20,11 +18,6 @@ PathOutput::PathOutput(const SourceDir& current_dir,
inverse_current_dir_ = InvertDir(current_dir_);
options_.mode = escaping;
- options_.convert_slashes = convert_slashes;
- options_.inhibit_quoting = false;
-
- if (convert_slashes)
- ConvertPathToSystem(&inverse_current_dir_);
}
PathOutput::~PathOutput() {
@@ -91,12 +84,9 @@ void PathOutput::WriteFile(std::ostream& out,
void PathOutput::WriteSourceRelativeString(
std::ostream& out,
const base::StringPiece& str) const {
- if (options_.mode == ESCAPE_SHELL) {
+ if (options_.mode == ESCAPE_NINJA_COMMAND) {
// Shell escaping needs an intermediate string since it may end up
- // quoting the whole thing. On Windows, the slashes may already be
- // converted to backslashes in inverse_current_dir_, but we assume that on
- // Windows the escaper won't try to then escape the preconverted
- // backslashes and will just pass them, so this is fine.
+ // quoting the whole thing.
std::string intermediate;
intermediate.reserve(inverse_current_dir_.size() + str.size());
intermediate.assign(inverse_current_dir_.c_str(),