52 lines
1.2 KiB
Ruby
52 lines
1.2 KiB
Ruby
module Rscons
|
|
class Environment
|
|
# Values:
|
|
# :none - do not print anything
|
|
# :short - rscons will print a short representation of the step
|
|
# being performed
|
|
# :command (default) - print the full command being executed
|
|
attr_accessor :echo
|
|
|
|
def initialize(options = {})
|
|
@echo = :command
|
|
@variables = options.reject { |key, val| not key[0] =~ /[A-Z]/ }
|
|
@builders = {}
|
|
@build_dirs = {}
|
|
unless @variables[:omit_default_builders]
|
|
DEFAULT_BUILDERS.each do |builder_class|
|
|
add_builder(builder_class)
|
|
end
|
|
end
|
|
@echo = options[:echo] if options[:echo]
|
|
end
|
|
|
|
def add_builder(builder_class)
|
|
var_defs = builder_class.const_get('VARIABLE_DEFAULTS')
|
|
if var_defs
|
|
var_defs.each_pair do |var, val|
|
|
unless @variables.has_key?(var)
|
|
@variables[var] = val
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
def [](key)
|
|
@variables[key]
|
|
end
|
|
|
|
def []=(key, val)
|
|
@variables[key] = val
|
|
end
|
|
|
|
def build_dir(src_dir, build_dir)
|
|
@build_dirs[src_dir] = build_dir
|
|
end
|
|
|
|
def method_missing(method, *args)
|
|
if @builders.has_key?(method.to_s)
|
|
end
|
|
end
|
|
end
|
|
end
|