diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index bb4325e5bd..6d812ea68d 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -34,7 +34,7 @@ def main require 'hardware' require 'keg' - require 'superenv' + require 'extend/ENV' # Force any future invocations of sudo to require the user's password to be # re-entered. This is in-case any build script call sudo. Certainly this is diff --git a/Library/Homebrew/cmd/--env.rb b/Library/Homebrew/cmd/--env.rb index 8cc1b1b407..d0dda1d8bb 100644 --- a/Library/Homebrew/cmd/--env.rb +++ b/Library/Homebrew/cmd/--env.rb @@ -1,4 +1,4 @@ -require 'superenv' +require 'extend/ENV' require 'hardware' module Homebrew extend self diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index 492291ab9b..060285d7ef 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -1,6 +1,6 @@ require 'formula' require 'utils' -require 'superenv' +require 'extend/ENV' require 'formula_cellar_checks' module Homebrew extend self diff --git a/Library/Homebrew/cmd/sh.rb b/Library/Homebrew/cmd/sh.rb index 5e8f26580a..a1ff30dfcd 100644 --- a/Library/Homebrew/cmd/sh.rb +++ b/Library/Homebrew/cmd/sh.rb @@ -1,4 +1,4 @@ -require 'superenv' +require 'extend/ENV' require 'formula' module Homebrew extend self diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index 41850fef8a..5e35bace53 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -1,4 +1,25 @@ require 'hardware' +require 'superenv' + +def superenv? + return false if MacOS::Xcode.without_clt? && MacOS.sdk_path.nil? + return false unless Superenv.bin && Superenv.bin.directory? + return false if ARGV.include? "--env=std" + true +end + +module EnvActivation + def activate_extensions! + if superenv? + extend(Superenv) + else + extend(HomebrewEnvExtension) + prepend 'PATH', "#{HOMEBREW_PREFIX}/bin", ':' unless ORIGINAL_PATHS.include? HOMEBREW_PREFIX/'bin' + end + end +end + +ENV.extend(EnvActivation) module HomebrewEnvExtension SAFE_CFLAGS_FLAGS = "-w -pipe" diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index f710fd0215..0e021a959a 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -1,6 +1,7 @@ require 'dependable' require 'dependency' require 'build_environment' +require 'extend/ENV' # A base class for non-formula requirements needed by formulae. # A "fatal" requirement is one that will fail the build if it is not present. @@ -117,7 +118,6 @@ class Requirement if instance_variable_defined?(:@satisfied) @satisfied elsif @options[:build_env] - require 'superenv' ENV.with_build_environment do ENV.userpaths! yield @proc diff --git a/Library/Homebrew/superenv.rb b/Library/Homebrew/superenv.rb index 17ffddd08d..3fb42b74b5 100644 --- a/Library/Homebrew/superenv.rb +++ b/Library/Homebrew/superenv.rb @@ -1,4 +1,3 @@ -require 'extend/ENV' require 'macos' ### Why `superenv`? @@ -11,26 +10,6 @@ require 'macos' # 7) Simpler formula that *just work* # 8) Build-system agnostic configuration of the tool-chain -def superenv? - return false if MacOS::Xcode.without_clt? && MacOS.sdk_path.nil? - return false unless Superenv.bin && Superenv.bin.directory? - return false if ARGV.include? "--env=std" - true -end - -module EnvActivation - def activate_extensions! - if superenv? - extend(Superenv) - else - extend(HomebrewEnvExtension) - prepend 'PATH', "#{HOMEBREW_PREFIX}/bin", ':' unless ORIGINAL_PATHS.include? HOMEBREW_PREFIX/'bin' - end - end -end - -ENV.extend(EnvActivation) - module Superenv attr_accessor :keg_only_deps, :deps, :x11 alias_method :x11?, :x11