diff options
| author | Adam Vandenberg | 2012-09-14 07:54:14 -0700 | 
|---|---|---|
| committer | Adam Vandenberg | 2012-09-14 09:14:48 -0700 | 
| commit | 88ad4c061d8d2bf7fe1bce29cf474b0bd854df2a (patch) | |
| tree | 91db8bde1571a776416c78183a002ddcc4be379e /Library | |
| parent | 4bf72a3e622f458c421999595ff9c92050b63814 (diff) | |
| download | brew-88ad4c061d8d2bf7fe1bce29cf474b0bd854df2a.tar.bz2 | |
Support env :std, :userpaths
Closes Homebrew/homebrew#14654.
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Homebrew/build.rb | 25 | ||||
| -rw-r--r-- | Library/Homebrew/build_environment.rb | 15 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 13 | 
3 files changed, 33 insertions, 20 deletions
diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index f40a7ef34..d3892819b 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -53,32 +53,17 @@ rescue Exception => e  end  def post_superenv_hacks f -  # TODO replace with Formula DSL -  # Python etc. build but then pip can't build stuff. -  # Scons resets ENV and then can't find superenv's build-tools. -  # In some cases we should only apply in the case of an option I suggest the -  # following: -  # -  # option 'with-passenger' do -  #   env :userpaths  # for superenv -  # end -  # option 'without-foo' do -  #  env :std, :x11 -  # end -  # -  # NOTE I think all ENV stuff should be specified with a DSL like this now. -  case f.name.to_sym -  when :lilypond, :nginx, :auctex +  # 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(':')}"    end  end  def pre_superenv_hacks f -  # fontforge needs 10.7 SDK, wine 32 bit, graphviz has mysteriously missing symbols -  # and ruby/python/ghc etc. create gem/pip that then won't work -  stdenvs = %w{fontforge python python3 ruby ruby-enterprise-edition jruby wine graphviz ghc} -  ARGV.unshift '--env=std' if (stdenvs.include?(f.name) or +  # Allow a formula to opt-in to the std environment. +  ARGV.unshift '--env=std' if (f.env.std? or      f.recursive_deps.detect{|d| d.name == 'scons' }) and      not ARGV.include? '--env=super'  end diff --git a/Library/Homebrew/build_environment.rb b/Library/Homebrew/build_environment.rb new file mode 100644 index 000000000..0beee6c25 --- /dev/null +++ b/Library/Homebrew/build_environment.rb @@ -0,0 +1,15 @@ +require 'set' + +class BuildEnvironment +  def initialize settings +    @settings = Set.new(settings) +  end + +  def std? +    @settings.include? :std +  end + +  def userpaths? +    @settings.include? :userpaths +  end +end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 2fbfbe201..184775835 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -6,6 +6,7 @@ require 'bottles'  require 'extend/fileutils'  require 'patches'  require 'compilers' +require 'build_environment'  class Formula @@ -436,6 +437,10 @@ class Formula    def deps;         self.class.dependencies.deps;         end    def requirements; self.class.dependencies.requirements; end +  def env +    @env ||= BuildEnvironment.new(self.class.environments) +  end +    def conflicts      requirements.select { |r| r.is_a? ConflictRequirement }    end @@ -646,6 +651,14 @@ private        @stable.mirror(val)      end +    def environments +      @environments ||= [] +    end + +    def env *settings +      environments.concat [settings].flatten +    end +      def dependencies        @dependencies ||= DependencyCollector.new      end  | 
