diff options
| author | Jack Nagel | 2014-05-19 14:18:23 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-05-19 14:41:02 -0500 |
| commit | 8a6c747cbdcd2bb1c4a6f39dc44d967548e7f967 (patch) | |
| tree | a729cf727c2f62a039e291e2efe7f2289bd0cd4c /Library/ENV/4.3 | |
| parent | 5d7954143a0b762fbeed1d44134951f658e5f8af (diff) | |
| download | homebrew-8a6c747cbdcd2bb1c4a6f39dc44d967548e7f967.tar.bz2 | |
Reorganize superenv include and library path setup
I found the dual use of CMAKE_*_PATH variables to make it difficult to
reason about this code. Now a separate set of variables are used to
communicate with the cc wrapper, and less work is performed in the
wrapper itself.
We no longer pass the SDK include path as a -isystem directory on
Xcode-only setups. Doing so is redundant with `--sysroot` and has other
side effects, namely changing the include path search order, which can
break compilation of some software (e.g. qemu).
On Xcode-only 10.9, we can additionally omit `--sysroot`, as the correct
paths are built into the tools.
A new variable, HOMEBREW_SYSROOT, is used to this information to the
wrapper. It will be unset on Xcode-only 10.9. HOMEBREW_SDKROOT will
continue to be set, as it is used for other things besides setting the
include search path.
Diffstat (limited to 'Library/ENV/4.3')
| -rwxr-xr-x | Library/ENV/4.3/cc | 68 |
1 files changed, 24 insertions, 44 deletions
diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc index 1c8db1238..aaf8360a4 100755 --- a/Library/ENV/4.3/cc +++ b/Library/ENV/4.3/cc @@ -26,14 +26,14 @@ end LOGGER = Logger.new class Cmd - attr_reader :brewfix, :brewtmp, :sdkroot + attr_reader :brewfix, :brewtmp, :sysroot def initialize path, args @arg0 = File.basename(path).freeze @args = args.freeze @brewfix = ENV['HOMEBREW_PREFIX'] @brewtmp = ENV['HOMEBREW_TEMP'] - @sdkroot = ENV['HOMEBREW_SDKROOT'] + @sysroot = ENV['HOMEBREW_SYSROOT'] end def mode @@ -89,11 +89,11 @@ class Cmd args = refurbished_args end - if sdkroot + if sysroot if tool == "ld" - args << "-syslibroot" << sdkroot + args << "-syslibroot" << sysroot else - args << "--sysroot=#{sdkroot}" + args << "--sysroot=#{sysroot}" end end @@ -118,8 +118,8 @@ class Cmd end def refurbished_args - @lset = Set.new(libpath + syslibpath) - @iset = Set.new(cpath.flatten) + @lset = Set.new(library_paths + system_library_paths) + @iset = Set.new(isystem_paths + include_paths) args = [] enum = @args.each @@ -241,40 +241,12 @@ class Cmd ENV["HOMEBREW_ARCHFLAGS"].split(" ") end - def syspath - if sdkroot - %W{#{sdkroot}/usr /usr/local} - else - %W{/usr /usr/local} - end - end - - def syslibpath - # We reject brew's lib as we explicitly add this as a -L flag, thus it - # is given higher priority by cc, so it surpasses the system libpath. - # NOTE this only counts if Homebrew is installed at /usr/local - syspath.reject { |d| d == brewfix }.map! { |d| File.join(d, "lib") } - end - - # Paths added as "-isystem<path>" and "-I<path>" flags - def cpath - cpath = path_split("CMAKE_PREFIX_PATH").map! { |d| File.join(d, "include") } - cpath += path_split("CMAKE_INCLUDE_PATH") - opt = cpath.grep(%r{^#{Regexp.escape(brewfix)}/opt}o) - sys = cpath - opt - [sys, opt] - end - - # Paths added as "-L<path>" flags - def libpath - libpath = path_split("CMAKE_PREFIX_PATH").map! { |d| File.join(d, "lib") } - libpath += path_split("CMAKE_LIBRARY_PATH") - libpath -= syslibpath - libpath + def cppflags + path_flags("-isystem", isystem_paths) + path_flags("-I", include_paths) end def ldflags - args = path_flags("-L", libpath) + args = path_flags("-L", library_paths) case mode when :ld args << "-headerpad_max_install_names" @@ -284,12 +256,20 @@ class Cmd args end - # Keg-only opt paths get the "-I" treatment since it has higher priority than - # "-isystem", and we want them to be searched before system directories as - # well as any directories added by the build system. - def cppflags - sys, opt = cpath - path_flags("-isystem", sys) + path_flags("-I", opt) + def isystem_paths + path_split("HOMEBREW_ISYSTEM_PATHS") + end + + def include_paths + path_split("HOMEBREW_INCLUDE_PATHS") + end + + def library_paths + path_split("HOMEBREW_LIBRARY_PATHS") + end + + def system_library_paths + %W{#{sysroot}/usr/lib /usr/local/lib} end def make_fuss args |
