superenv: port to generic OS. (#457)
This commit is contained in:
		
							parent
							
								
									498e81c9fc
								
							
						
					
					
						commit
						0d189fae57
					
				@ -13,7 +13,7 @@ module Homebrew
 | 
			
		||||
    ENV.activate_extensions!
 | 
			
		||||
 | 
			
		||||
    if superenv?
 | 
			
		||||
      ENV.x11 = MacOS::X11.installed?
 | 
			
		||||
      ENV.set_x11_env_if_installed
 | 
			
		||||
      ENV.deps = Formula.installed.select { |f| f.keg_only? && f.opt_prefix.directory? }
 | 
			
		||||
    end
 | 
			
		||||
    ENV.setup_build_environment
 | 
			
		||||
 | 
			
		||||
@ -27,10 +27,6 @@ module Superenv
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
  def self.bin
 | 
			
		||||
    return unless DevelopmentTools.installed?
 | 
			
		||||
 | 
			
		||||
    bin = HOMEBREW_ENV_PATH.subdirs.reject { |d| d.basename.to_s > MacOS::Xcode.version }.max
 | 
			
		||||
    bin.realpath unless bin.nil?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def reset
 | 
			
		||||
@ -56,7 +52,6 @@ module Superenv
 | 
			
		||||
    self["HOMEBREW_CELLAR"] = HOMEBREW_CELLAR.to_s
 | 
			
		||||
    self["HOMEBREW_OPT"] = "#{HOMEBREW_PREFIX}/opt"
 | 
			
		||||
    self["HOMEBREW_TEMP"] = HOMEBREW_TEMP.to_s
 | 
			
		||||
    self["HOMEBREW_SDKROOT"] = effective_sysroot
 | 
			
		||||
    self["HOMEBREW_OPTFLAGS"] = determine_optflags
 | 
			
		||||
    self["HOMEBREW_ARCHFLAGS"] = ""
 | 
			
		||||
    self["CMAKE_PREFIX_PATH"] = determine_cmake_prefix_path
 | 
			
		||||
@ -73,15 +68,6 @@ module Superenv
 | 
			
		||||
      self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if MacOS::Xcode.without_clt? || (MacOS::Xcode.installed? && MacOS::Xcode.version.to_i >= 7)
 | 
			
		||||
      self["MACOSX_DEPLOYMENT_TARGET"] = MacOS.version.to_s
 | 
			
		||||
      self["SDKROOT"] = MacOS.sdk_path
 | 
			
		||||
    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.
 | 
			
		||||
    self["HOMEBREW_PREFER_CLT_PROXIES"] = "1" if MacOS.version >= "10.9"
 | 
			
		||||
 | 
			
		||||
    # The HOMEBREW_CCCFG ENV variable is used by the ENV/cc tool to control
 | 
			
		||||
    # compiler flag stripping. It consists of a string of characters which act
 | 
			
		||||
    # as flags. Some of these flags are mutually exclusive.
 | 
			
		||||
@ -97,6 +83,7 @@ module Superenv
 | 
			
		||||
    # s - apply fix for sed's Unicode support
 | 
			
		||||
    # a - apply fix for apr-1-config path
 | 
			
		||||
  end
 | 
			
		||||
  alias_method :generic_setup_build_environment, :setup_build_environment
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
@ -109,27 +96,23 @@ module Superenv
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def effective_sysroot
 | 
			
		||||
    MacOS::Xcode.without_clt? ? MacOS.sdk_path.to_s : nil
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_cxx
 | 
			
		||||
    determine_cc.to_s.gsub("gcc", "g++").gsub("clang", "clang++")
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_paths
 | 
			
		||||
    []
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_path
 | 
			
		||||
    paths = [Superenv.bin]
 | 
			
		||||
 | 
			
		||||
    # Formula dependencies can override standard tools.
 | 
			
		||||
    paths += deps.map { |d| d.opt_bin.to_s }
 | 
			
		||||
 | 
			
		||||
    # On 10.9, there are shims for all tools in /usr/bin.
 | 
			
		||||
    # On 10.7 and 10.8 we need to add these directories ourselves.
 | 
			
		||||
    if MacOS::Xcode.without_clt? && MacOS.version <= "10.8"
 | 
			
		||||
      paths << "#{MacOS::Xcode.prefix}/usr/bin"
 | 
			
		||||
      paths << "#{MacOS::Xcode.toolchain_path}/usr/bin"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    paths << MacOS::X11.bin.to_s if x11?
 | 
			
		||||
    paths += homebrew_extra_paths
 | 
			
		||||
    paths += %w[/usr/bin /bin /usr/sbin /sbin]
 | 
			
		||||
 | 
			
		||||
    # Homebrew's apple-gcc42 will be outside the PATH in superenv,
 | 
			
		||||
@ -149,6 +132,10 @@ module Superenv
 | 
			
		||||
    paths.to_path_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_pkg_config_paths
 | 
			
		||||
    []
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_pkg_config_path
 | 
			
		||||
    paths  = deps.map { |d| "#{d.opt_lib}/pkgconfig" }
 | 
			
		||||
    paths += deps.map { |d| "#{d.opt_share}/pkgconfig" }
 | 
			
		||||
@ -156,25 +143,29 @@ module Superenv
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_pkg_config_libdir
 | 
			
		||||
    paths = %W[/usr/lib/pkgconfig #{HOMEBREW_ENV_PATH}/pkgconfig/#{MacOS.version}]
 | 
			
		||||
    paths << "#{MacOS::X11.lib}/pkgconfig" << "#{MacOS::X11.share}/pkgconfig" if x11?
 | 
			
		||||
    paths = %W[/usr/lib/pkgconfig]
 | 
			
		||||
    paths += homebrew_extra_pkg_config_paths
 | 
			
		||||
    paths.to_path_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_aclocal_paths
 | 
			
		||||
    []
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_aclocal_path
 | 
			
		||||
    paths = keg_only_deps.map { |d| "#{d.opt_share}/aclocal" }
 | 
			
		||||
    paths << "#{HOMEBREW_PREFIX}/share/aclocal"
 | 
			
		||||
    paths << "#{MacOS::X11.share}/aclocal" if x11?
 | 
			
		||||
    paths += homebrew_extra_aclocal_paths
 | 
			
		||||
    paths.to_path_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_isystem_paths
 | 
			
		||||
    []
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_isystem_paths
 | 
			
		||||
    paths = []
 | 
			
		||||
    paths << "#{HOMEBREW_PREFIX}/include"
 | 
			
		||||
    paths << "#{effective_sysroot}/usr/include/libxml2" unless deps.any? { |d| d.name == "libxml2" }
 | 
			
		||||
    paths << "#{effective_sysroot}/usr/include/apache2" if MacOS::Xcode.without_clt?
 | 
			
		||||
    paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11?
 | 
			
		||||
    paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
 | 
			
		||||
    paths = ["#{HOMEBREW_PREFIX}/include"]
 | 
			
		||||
    paths += homebrew_extra_isystem_paths
 | 
			
		||||
    paths.to_path_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -182,11 +173,13 @@ module Superenv
 | 
			
		||||
    keg_only_deps.map { |d| d.opt_include.to_s }.to_path_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_library_paths
 | 
			
		||||
    []
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_library_paths
 | 
			
		||||
    paths = keg_only_deps.map { |d| d.opt_lib.to_s }
 | 
			
		||||
    paths << "#{HOMEBREW_PREFIX}/lib"
 | 
			
		||||
    paths << MacOS::X11.lib.to_s if x11?
 | 
			
		||||
    paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
 | 
			
		||||
    paths += homebrew_extra_library_paths
 | 
			
		||||
    paths.to_path_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -200,25 +193,34 @@ module Superenv
 | 
			
		||||
    paths.to_path_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_cmake_include_paths
 | 
			
		||||
    []
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_cmake_include_path
 | 
			
		||||
    paths = []
 | 
			
		||||
    paths << "#{effective_sysroot}/usr/include/libxml2" unless deps.any? { |d| d.name == "libxml2" }
 | 
			
		||||
    paths << "#{effective_sysroot}/usr/include/apache2" if MacOS::Xcode.without_clt?
 | 
			
		||||
    paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11?
 | 
			
		||||
    paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
 | 
			
		||||
    paths += homebrew_extra_cmake_include_paths
 | 
			
		||||
    paths.to_path_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_cmake_library_paths
 | 
			
		||||
    []
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_cmake_library_path
 | 
			
		||||
    paths = []
 | 
			
		||||
    paths << MacOS::X11.lib.to_s if x11?
 | 
			
		||||
    paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
 | 
			
		||||
    paths += homebrew_extra_cmake_library_paths
 | 
			
		||||
    paths.to_path_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_cmake_frameworks_paths
 | 
			
		||||
    []
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_cmake_frameworks_path
 | 
			
		||||
    paths = deps.map { |d| d.opt_frameworks.to_s }
 | 
			
		||||
    paths << "#{effective_sysroot}/System/Library/Frameworks" if MacOS::Xcode.without_clt?
 | 
			
		||||
    paths += homebrew_extra_cmake_frameworks_paths
 | 
			
		||||
    paths.to_path_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -245,12 +247,7 @@ module Superenv
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_cccfg
 | 
			
		||||
    s = ""
 | 
			
		||||
    # Fix issue with sed barfing on unicode characters on Mountain Lion
 | 
			
		||||
    s << "s" if MacOS.version >= :mountain_lion
 | 
			
		||||
    # Fix issue with >= 10.8 apr-1-config having broken paths
 | 
			
		||||
    s << "a" if MacOS.version >= :mountain_lion
 | 
			
		||||
    s
 | 
			
		||||
    ""
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  public
 | 
			
		||||
@ -333,19 +330,26 @@ module Superenv
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_x11_env_if_installed
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
  def noop(*_args); end
 | 
			
		||||
  noops = []
 | 
			
		||||
 | 
			
		||||
  # These methods are no longer necessary under superenv, but are needed to
 | 
			
		||||
  # maintain an interface compatible with stdenv.
 | 
			
		||||
  noops.concat %w[fast O4 Og libxml2 set_cpu_flags macosxsdk remove_macosxsdk]
 | 
			
		||||
  alias_method :fast, :noop
 | 
			
		||||
  alias_method :O4, :noop
 | 
			
		||||
  alias_method :Og, :noop
 | 
			
		||||
  alias_method :libxml2, :noop
 | 
			
		||||
  alias_method :set_cpu_flags, :noop
 | 
			
		||||
 | 
			
		||||
  # These methods provide functionality that has not yet been ported to
 | 
			
		||||
  # superenv.
 | 
			
		||||
  noops.concat %w[gcc_4_0_1 minimal_optimization no_optimization enable_warnings]
 | 
			
		||||
 | 
			
		||||
  noops.each { |m| alias_method m, :noop }
 | 
			
		||||
  alias_method :gcc_4_0_1, :noop
 | 
			
		||||
  alias_method :minimal_optimization, :noop
 | 
			
		||||
  alias_method :no_optimization, :noop
 | 
			
		||||
  alias_method :enable_warnings, :noop
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
class Array
 | 
			
		||||
@ -353,3 +357,5 @@ class Array
 | 
			
		||||
    map(&:to_s).uniq.select { |s| File.directory? s }.join(File::PATH_SEPARATOR).chuzzle
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
require "extend/os/extend/ENV/super"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								Library/Homebrew/extend/os/extend/ENV/super.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								Library/Homebrew/extend/os/extend/ENV/super.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
require "extend/ENV/super"
 | 
			
		||||
 | 
			
		||||
if OS.mac?
 | 
			
		||||
  require "extend/os/mac/extend/ENV/super"
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										105
									
								
								Library/Homebrew/extend/os/mac/extend/ENV/super.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								Library/Homebrew/extend/os/mac/extend/ENV/super.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,105 @@
 | 
			
		||||
module Superenv
 | 
			
		||||
  # @private
 | 
			
		||||
  def self.bin
 | 
			
		||||
    return unless DevelopmentTools.installed?
 | 
			
		||||
 | 
			
		||||
    bin = HOMEBREW_ENV_PATH.subdirs.reject { |d| d.basename.to_s > MacOS::Xcode.version }.max
 | 
			
		||||
    bin.realpath unless bin.nil?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_paths
 | 
			
		||||
    paths = []
 | 
			
		||||
    # On 10.9, there are shims for all tools in /usr/bin.
 | 
			
		||||
    # On 10.7 and 10.8 we need to add these directories ourselves.
 | 
			
		||||
    if MacOS::Xcode.without_clt? && MacOS.version <= "10.8"
 | 
			
		||||
      paths << "#{MacOS::Xcode.prefix}/usr/bin"
 | 
			
		||||
      paths << "#{MacOS::Xcode.toolchain_path}/usr/bin"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    paths << MacOS::X11.bin.to_s if x11?
 | 
			
		||||
    paths
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
  def homebrew_extra_pkg_config_paths
 | 
			
		||||
    paths = ["#{HOMEBREW_ENV_PATH}/pkgconfig/#{MacOS.version}"]
 | 
			
		||||
    paths << "#{MacOS::X11.lib}/pkgconfig" << "#{MacOS::X11.share}/pkgconfig" if x11?
 | 
			
		||||
    paths
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_aclocal_paths
 | 
			
		||||
    paths = []
 | 
			
		||||
    paths << "#{MacOS::X11.share}/aclocal" if x11?
 | 
			
		||||
    paths
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_isystem_paths
 | 
			
		||||
    paths = []
 | 
			
		||||
    paths << "#{effective_sysroot}/usr/include/libxml2" unless deps.any? { |d| d.name == "libxml2" }
 | 
			
		||||
    paths << "#{effective_sysroot}/usr/include/apache2" if MacOS::Xcode.without_clt?
 | 
			
		||||
    paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11?
 | 
			
		||||
    paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
 | 
			
		||||
    paths
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_library_paths
 | 
			
		||||
    paths = []
 | 
			
		||||
    paths << MacOS::X11.lib.to_s if x11?
 | 
			
		||||
    paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
 | 
			
		||||
    paths
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_cmake_include_paths
 | 
			
		||||
    paths = []
 | 
			
		||||
    paths << "#{effective_sysroot}/usr/include/apache2" if MacOS::Xcode.without_clt?
 | 
			
		||||
    paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11?
 | 
			
		||||
    paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
 | 
			
		||||
    paths
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_cmake_library_paths
 | 
			
		||||
    paths = []
 | 
			
		||||
    paths << MacOS::X11.lib.to_s if x11?
 | 
			
		||||
    paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
 | 
			
		||||
    paths
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_cmake_frameworks_paths
 | 
			
		||||
    paths = []
 | 
			
		||||
    paths << "#{effective_sysroot}/System/Library/Frameworks" if MacOS::Xcode.without_clt?
 | 
			
		||||
    paths
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_cccfg
 | 
			
		||||
    s = ""
 | 
			
		||||
    # Fix issue with sed barfing on unicode characters on Mountain Lion
 | 
			
		||||
    s << "s" if MacOS.version >= :mountain_lion
 | 
			
		||||
    # Fix issue with >= 10.8 apr-1-config having broken paths
 | 
			
		||||
    s << "a" if MacOS.version >= :mountain_lion
 | 
			
		||||
    s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
  def setup_build_environment(formula = nil)
 | 
			
		||||
    generic_setup_build_environment(formula)
 | 
			
		||||
    self["HOMEBREW_SDKROOT"] = effective_sysroot
 | 
			
		||||
 | 
			
		||||
    if MacOS::Xcode.without_clt? || (MacOS::Xcode.installed? && MacOS::Xcode.version.to_i >= 7)
 | 
			
		||||
      self["MACOSX_DEPLOYMENT_TARGET"] = MacOS.version.to_s
 | 
			
		||||
      self["SDKROOT"] = MacOS.sdk_path
 | 
			
		||||
    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.
 | 
			
		||||
    self["HOMEBREW_PREFER_CLT_PROXIES"] = "1" if MacOS.version >= "10.9"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_x11_env_if_installed
 | 
			
		||||
    ENV.x11 = MacOS::X11.installed?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # These methods are no longer necessary under superenv, but are needed to
 | 
			
		||||
  # maintain an interface compatible with stdenv.
 | 
			
		||||
  alias_method :macosxsdk, :noop
 | 
			
		||||
  alias_method :remove_macosxsdk, :noop
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user