diff options
| author | Jack Nagel | 2012-12-23 19:44:56 -0600 |
|---|---|---|
| committer | Jack Nagel | 2012-12-26 14:37:03 -0600 |
| commit | bb03a39ad88a367f2ad17c496038652610a8e3cc (patch) | |
| tree | 03e678535764654bcf916ab98dba197a05ca91e2 | |
| parent | 5639cc7f3803fe79e6385779040927c3f5b99730 (diff) | |
| download | homebrew-bb03a39ad88a367f2ad17c496038652610a8e3cc.tar.bz2 | |
Allow requirements to specify env options
| -rwxr-xr-x | Library/Homebrew/build.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/dependencies.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/requirements.rb | 2 |
4 files changed, 21 insertions, 3 deletions
diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index aa5be6540..2ce16b32c 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -57,9 +57,8 @@ end def post_superenv_hacks f # Only allow Homebrew-approved directories into the PATH, unless # a formula opts-in to allowing the user's path. - if f.env.userpaths? - paths = ORIGINAL_PATHS.map{|pn| pn.realpath.to_s rescue nil } - %w{/usr/X11/bin /opt/X11/bin} - ENV['PATH'] = "#{ENV['PATH']}:#{paths.join(':')}" + if f.env.userpaths? or f.recursive_requirements.any? { |rq| rq.env.userpaths? } + ENV.userpaths! end end diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb index be6e0cf9d..8e6c7afdf 100644 --- a/Library/Homebrew/dependencies.rb +++ b/Library/Homebrew/dependencies.rb @@ -1,3 +1,5 @@ +require 'build_environment' + ## This file defines dependencies and requirements. ## ## A dependency is a formula that another formula needs to install. @@ -169,6 +171,10 @@ class Requirement # See X11Dependency def modify_build_environment; nil end + def env + @env ||= self.class.env + end + def eql?(other) other.is_a? self.class and hash == other.hash end @@ -181,6 +187,12 @@ class Requirement def fatal(val=nil) val.nil? ? @fatal : @fatal = val end + + def env(*settings) + @env ||= BuildEnvironment.new + settings.each { |s| @env << s } + @env + end end end diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index 668fd29bd..b3b8d26b3 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -431,6 +431,11 @@ class << ENV append 'CPPFLAGS', "-DNCURSES_OPAQUE=0" end + def userpaths! + paths = ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w{/usr/X11/bin /opt/X11/bin} + self['PATH'] = paths.unshift(*self['PATH'].split(":")).uniq.join(":") + end + def fortran fc_flag_vars = %w{FCFLAGS FFLAGS} diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb index dcf9afcd7..9dc8e0660 100644 --- a/Library/Homebrew/requirements.rb +++ b/Library/Homebrew/requirements.rb @@ -102,6 +102,8 @@ class MPIDependency < Requirement fatal true + env :userpaths + def initialize *lang_list @lang_list = lang_list @non_functional = [] |
