diff options
author | Oscar Bonilla <6f6231@gmail.com> | 2018-06-12 12:21:44 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-12 12:24:49 -0700 |
commit | 56d98ae42c5a9626e3a749c27637a2ddb9b69d3d (patch) | |
tree | 42e0be02080173d27c8fc39527a111a10d4f2225 /tools/osx | |
parent | 400fffe8b2df50c5b57ced5d9a8b46e40d529d4e (diff) |
CROSSTOOLS wrapped_clang: handle spaces in paths
When bazel calls wrapped_clang, it single-quotes all arguments. However
it passes flags with arguments quoted as a whole. That is, wrapped_clang
will be called with arguments like these:
wrapped_clang '-isysroot /a/path/with spaces' '/a/file with spaces.m'
Before this commit, wrapped_clang was blindly splitting on space and
calling clang with invalid arguments. Now it only splits on the _first_
space, and only if the argument starts with '-'.
Closes #5147.
PiperOrigin-RevId: 200259496
Diffstat (limited to 'tools/osx')
-rw-r--r-- | tools/osx/crosstool/wrapped_clang.cc | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/tools/osx/crosstool/wrapped_clang.cc b/tools/osx/crosstool/wrapped_clang.cc index 0f92db9b3c..1fcdb53587 100644 --- a/tools/osx/crosstool/wrapped_clang.cc +++ b/tools/osx/crosstool/wrapped_clang.cc @@ -118,17 +118,6 @@ void RunSubProcess(const std::vector<std::string> &args) { } } -// Splits txt using whitespace delimiter, pushing each substring into strs. -void SplitAndAdd(const std::string &txt, std::vector<std::string> &strs) { - for (std::istringstream stream(txt); !stream.eof();) { - std::string substring; - stream >> substring; - if (!substring.empty()) { - strs.push_back(substring); - } - } -} - // Finds and replaces all instances of oldsub with newsub, in-place on str. void FindAndReplace(const std::string &oldsub, const std::string &newsub, std::string *str) { @@ -207,7 +196,7 @@ int main(int argc, char *argv[]) { } FindAndReplace("__BAZEL_XCODE_DEVELOPER_DIR__", developer_dir, &arg); FindAndReplace("__BAZEL_XCODE_SDKROOT__", sdk_root, &arg); - SplitAndAdd(arg, processed_args); + processed_args.push_back(arg); } // Check to see if we should postprocess with dsymutil. |