mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

In addition to env :userpaths env :std requirements can now do env do append 'PATH', '/some/path/to/bin' # and more end
46 lines
726 B
Ruby
46 lines
726 B
Ruby
require 'set'
|
|
|
|
class BuildEnvironment
|
|
def initialize(*settings)
|
|
@settings = Set.new(settings)
|
|
end
|
|
|
|
def <<(o)
|
|
@settings << o
|
|
self
|
|
end
|
|
|
|
def std?
|
|
@settings.include? :std
|
|
end
|
|
|
|
def userpaths?
|
|
@settings.include? :userpaths
|
|
end
|
|
|
|
def modify_build_environment
|
|
p = @settings.find { |s| Proc === s }
|
|
ENV.instance_eval(&p) unless p.nil?
|
|
end
|
|
|
|
def _dump(*)
|
|
@settings.dup.reject { |s| Proc === s }.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
|