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

Unified Diff: tools/gn/ninja_binary_target_writer.cc

Issue 576293003: gn: Escape include path strings for shell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_binary_target_writer.cc
diff --git a/tools/gn/ninja_binary_target_writer.cc b/tools/gn/ninja_binary_target_writer.cc
index 2c07ca8030871f21099b472309ee15e27a34a9d0..1480f69212430678f32f12d115fe18493537187e 100644
--- a/tools/gn/ninja_binary_target_writer.cc
+++ b/tools/gn/ninja_binary_target_writer.cc
@@ -5,6 +5,7 @@
#include "tools/gn/ninja_binary_target_writer.h"
#include <set>
+#include <sstream>
#include "base/strings/string_util.h"
#include "tools/gn/config_values_extractors.h"
@@ -52,8 +53,13 @@ struct IncludeWriter {
}
void operator()(const SourceDir& d, std::ostream& out) const {
- out << " -I";
- path_output_.WriteDir(out, d, PathOutput::DIR_NO_LAST_SLASH);
+ std::ostringstream path_out;
+ path_output_.WriteDir(path_out, d, PathOutput::DIR_NO_LAST_SLASH);
+ const std::string& path = path_out.str();
+ if (path[0] == '"')
+ out << " \"-I" << path.substr(1);
+ else
+ out << " -I" << path;
}
PathOutput& path_output_;
@@ -96,9 +102,11 @@ void NinjaBinaryTargetWriter::WriteCompilerVars() {
// Include directories.
if (subst.used[SUBSTITUTION_INCLUDE_DIRS]) {
out_ << kSubstitutionNinjaNames[SUBSTITUTION_INCLUDE_DIRS] << " =";
+ PathOutput include_path_output(path_output_.current_dir(),
+ ESCAPE_NINJA_COMMAND);
RecursiveTargetConfigToStream<SourceDir>(
target_, &ConfigValues::include_dirs,
- IncludeWriter(path_output_), out_);
+ IncludeWriter(include_path_output), out_);
out_ << std::endl;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698