lib/rscons/environment.rb in rscons-0.0.5 vs lib/rscons/environment.rb in rscons-0.0.6
- old
+ new
@@ -139,11 +139,11 @@
end.all?
@targets[target][:builder].run(target,
@targets[target][:source],
cache,
self,
- *@targets[target][:args])
+ @targets[target][:vars] || {})
else
false
end
end
@targets.each do |target, info|
@@ -191,15 +191,19 @@
end
alias_method :orig_method_missing, :method_missing
def method_missing(method, *args)
if @builders.has_key?(method.to_s)
- target, source, *rest = args
+ target, source, vars, *rest = args
+ unless vars.nil? or vars.is_a?(Hash) or vars.is_a?(VarSet)
+ raise "Unexpected construction variable set: #{vars.inspect}"
+ end
source = [source] unless source.is_a?(Array)
@targets[target] = {
builder: @builders[method.to_s],
source: source,
+ vars: vars,
args: rest,
}
else
orig_method_missing(method, *args)
end
@@ -225,8 +229,35 @@
end
buildup = ''
end
end
deps
+ end
+
+ # Build a list of source files into files containing one of the suffixes
+ # given by suffixes.
+ # This method is used internally by RScons builders.
+ # @param sources [Array] List of source files to build.
+ # @param suffixes [Array] List of suffixes to try to convert source files into.
+ # @param cache [Cache] The Cache.
+ # Return a list of the converted file names.
+ def build_sources(sources, suffixes, cache, vars = {})
+ sources.map do |source|
+ if source.has_suffix?(suffixes)
+ source
+ else
+ converted = nil
+ suffixes.each do |suffix|
+ converted_fname = get_build_fname(source, suffix)
+ builder = @builders.values.find { |b| b.produces?(converted_fname, source, self) }
+ if builder
+ converted = builder.run(converted_fname, [source], cache, self, vars)
+ return nil unless converted
+ break
+ end
+ end
+ converted or raise "Could not find a builder to handle #{source.inspect}."
+ end
+ end
end
end
end