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/Homebrew/extend | |
| 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/Homebrew/extend')
| -rw-r--r-- | Library/Homebrew/extend/ENV/super.rb | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index cb05ec964..0c6d10547 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -66,6 +66,15 @@ module Superenv self['CMAKE_LIBRARY_PATH'] = determine_cmake_library_path self['ACLOCAL_PATH'] = determine_aclocal_path self['M4'] = MacOS.locate("m4") if deps.include? "autoconf" + self["HOMEBREW_ISYSTEM_PATHS"] = determine_isystem_paths + self["HOMEBREW_INCLUDE_PATHS"] = determine_include_paths + self["HOMEBREW_LIBRARY_PATHS"] = determine_library_paths + + # On 10.9 the developer tools honor the correct sysroot by default. + # On 10.7 and 10.8 we need to set it ourselves. + if MacOS::Xcode.without_clt? && MacOS.version <= "10.8" + self["HOMEBREW_SYSROOT"] = effective_sysroot + end # On 10.9, the tools in /usr/bin proxy to the active developer directory. # This means we can use them for any combination of CLT and Xcode. @@ -100,6 +109,10 @@ module Superenv self["HOMEBREW_CXX"] = super end + def effective_sysroot + if MacOS::Xcode.without_clt? then MacOS.sdk_path.to_s else "" end + end + def determine_cc cc = compiler COMPILER_SYMBOL_MAP.invert.fetch(cc, cc) @@ -159,40 +172,53 @@ module Superenv paths.to_path_s end - def determine_cmake_prefix_path - paths = keg_only_deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}" } - paths << HOMEBREW_PREFIX.to_s # put ourselves ahead of everything else - paths << "#{MacOS.sdk_path}/usr" if MacOS::Xcode.without_clt? + def determine_isystem_paths + paths = [] + paths << "#{HOMEBREW_PREFIX}/include" + paths << "#{effective_sysroot}/usr/include/libxml2" unless deps.include? "libxml2" + paths << "#{effective_sysroot}/usr/include/apache2" if MacOS::Xcode.without_clt? + paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers" + paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11? paths.to_path_s end - def determine_cmake_frameworks_path - paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/Frameworks" } - paths << "#{MacOS.sdk_path}/System/Library/Frameworks" if MacOS::Xcode.without_clt? + def determine_include_paths + keg_only_deps.map { |dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/include" }.to_path_s + end + + def determine_library_paths + paths = keg_only_deps.map { |dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/lib" } + paths << "#{HOMEBREW_PREFIX}/lib" + paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries" + paths << MacOS::X11.lib.to_s if x11? + paths.to_path_s + end + + def determine_cmake_prefix_path + paths = keg_only_deps.map { |dep| "#{HOMEBREW_PREFIX}/opt/#{dep}" } + paths << HOMEBREW_PREFIX.to_s paths.to_path_s end def determine_cmake_include_path - sdk = MacOS.sdk_path if MacOS::Xcode.without_clt? paths = [] - paths << "#{sdk}/usr/include/libxml2" unless deps.include? 'libxml2' - paths << "#{sdk}/usr/include/apache2" if MacOS::Xcode.without_clt? - if x11? - paths << MacOS::X11.include << "#{MacOS::X11.include}/freetype2" - else - paths << "#{sdk}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers" - end + paths << "#{effective_sysroot}/usr/include/libxml2" unless deps.include? "libxml2" + paths << "#{effective_sysroot}/usr/include/apache2" if MacOS::Xcode.without_clt? + paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers" + paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11? paths.to_path_s end def determine_cmake_library_path - sdk = MacOS.sdk_path if MacOS::Xcode.without_clt? paths = [] - if x11? - paths << MacOS::X11.lib - else - paths << "#{sdk}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries" - end + paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries" + paths << MacOS::X11.lib.to_s if x11? + paths.to_path_s + end + + def determine_cmake_frameworks_path + paths = deps.map { |dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/Frameworks" } + paths << "#{effective_sysroot}/System/Library/Frameworks" if MacOS::Xcode.without_clt? paths.to_path_s end |
