Commit 6e697271 authored by ckocagil's avatar ckocagil Committed by Commit bot

gn: Escape include path strings for shell

BUG=414880
R=brettw

Review URL: https://codereview.chromium.org/576293003

Cr-Commit-Position: refs/heads/master@{#295620}
parent 1d8d9b48
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "tools/gn/ninja_binary_target_writer.h" #include "tools/gn/ninja_binary_target_writer.h"
#include <set> #include <set>
#include <sstream>
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "tools/gn/config_values_extractors.h" #include "tools/gn/config_values_extractors.h"
...@@ -52,8 +53,13 @@ struct IncludeWriter { ...@@ -52,8 +53,13 @@ struct IncludeWriter {
} }
void operator()(const SourceDir& d, std::ostream& out) const { void operator()(const SourceDir& d, std::ostream& out) const {
out << " -I"; std::ostringstream path_out;
path_output_.WriteDir(out, d, PathOutput::DIR_NO_LAST_SLASH); 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_; PathOutput& path_output_;
...@@ -96,9 +102,11 @@ void NinjaBinaryTargetWriter::WriteCompilerVars() { ...@@ -96,9 +102,11 @@ void NinjaBinaryTargetWriter::WriteCompilerVars() {
// Include directories. // Include directories.
if (subst.used[SUBSTITUTION_INCLUDE_DIRS]) { if (subst.used[SUBSTITUTION_INCLUDE_DIRS]) {
out_ << kSubstitutionNinjaNames[SUBSTITUTION_INCLUDE_DIRS] << " ="; out_ << kSubstitutionNinjaNames[SUBSTITUTION_INCLUDE_DIRS] << " =";
PathOutput include_path_output(path_output_.current_dir(),
ESCAPE_NINJA_COMMAND);
RecursiveTargetConfigToStream<SourceDir>( RecursiveTargetConfigToStream<SourceDir>(
target_, &ConfigValues::include_dirs, target_, &ConfigValues::include_dirs,
IncludeWriter(path_output_), out_); IncludeWriter(include_path_output), out_);
out_ << std::endl; out_ << std::endl;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment