 1b0f0824fe
			
		
	
	
		1b0f0824fe
		
	
	
	
	
		
			
			This was meant to support:
  env do |req|
    append_path 'PATH', req.some_method
    ...
  end
i.e., the block was evaluated in the context of ENV. But it turned out
to be not so useful after all, so I'm ripping it out before something
actually depends on it.
		
	
			
		
			
				
	
	
		
			49 lines
		
	
	
		
			756 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			756 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require 'set'
 | |
| 
 | |
| class BuildEnvironment
 | |
|   def initialize(*settings)
 | |
|     @settings = Set.new(settings)
 | |
|     @procs = Set.new
 | |
|   end
 | |
| 
 | |
|   def <<(o)
 | |
|     case o
 | |
|     when Proc then @procs << o
 | |
|     else @settings << o
 | |
|     end
 | |
|     self
 | |
|   end
 | |
| 
 | |
|   def std?
 | |
|     @settings.include? :std
 | |
|   end
 | |
| 
 | |
|   def userpaths?
 | |
|     @settings.include? :userpaths
 | |
|   end
 | |
| 
 | |
|   def modify_build_environment(receiver)
 | |
|     @procs.each { |p| receiver.instance_eval(&p) }
 | |
|   end
 | |
| 
 | |
|   def _dump(*)
 | |
|     @settings.to_a.join(":")
 | |
|   end
 | |
| 
 | |
|   def self._load(s)
 | |
|     new(*s.split(":").map(&:to_sym))
 | |
|   end
 | |
| end
 | |
| 
 | |
| module BuildEnvironmentDSL
 | |
|   def env(*settings, &block)
 | |
|     @env ||= BuildEnvironment.new
 | |
|     if block_given?
 | |
|       @env << block
 | |
|     else
 | |
|       settings.each { |s| @env << s }
 | |
|     end
 | |
|     @env
 | |
|   end
 | |
| end
 |