Skip to content

Commit

Permalink
Fix cc_configure include path for Frameworks on OS X.
Browse files Browse the repository at this point in the history
cc_configure assumed the paths returned by $(CC) -E -xc++ -v
where not containing any extra information but clang on OS X
adds " (framework directory)" for path from Frameworks. This
change strip this out.

--
Change-Id: I90617e825100f86a1f0991e128755802da2c7afd
Reviewed-on: https://bazel-review.googlesource.com/3389
MOS_MIGRATED_REVID=120210800
  • Loading branch information
damienmg committed Apr 19, 2016
1 parent 0e689d9 commit 97e5ab0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/cpp/cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ def _get_cpu_value(repository_ctx):
_INC_DIR_MARKER_BEGIN = "#include <...> search starts here:"
_INC_DIR_MARKER_END = "End of search list."

# OSX add " (framework directory)" at the end of line, strip it.
_OSX_FRAMEWORK_SUFFIX = " (framework directory)"
_OSX_FRAMEWORK_SUFFIX_LEN = len(_OSX_FRAMEWORK_SUFFIX)
def _cxx_inc_convert(path):
"""Convert path returned by cc -E xc++ in a complete path."""
path = path.strip()
if path.endswith(_OSX_FRAMEWORK_SUFFIX):
path = path[:-_OSX_FRAMEWORK_SUFFIX_LEN].strip()
return path

def _get_cxx_inc_directories(repository_ctx, cc):
"""Compute the list of default C++ include directories."""
Expand All @@ -120,8 +129,8 @@ def _get_cxx_inc_directories(repository_ctx, cc):
if index2 == -1:
return []
inc_dirs = result.stderr[index1 + len(_INC_DIR_MARKER_BEGIN):index2].strip()
return [repository_ctx.path(p.strip()) for p in inc_dirs.split("\n")]

return [repository_ctx.path(_cxx_inc_convert(p))
for p in inc_dirs.split("\n")]

def _add_option_if_supported(repository_ctx, cc, option):
"""Checks that `option` is supported by the C compiler."""
Expand Down

0 comments on commit 97e5ab0

Please sign in to comment.