add functionality to add builders to an Environment
This commit is contained in:
parent
02f2f635bf
commit
3ba3111a45
@ -2,7 +2,15 @@ require "rscons/builder"
|
||||
require "rscons/environment"
|
||||
require "rscons/version"
|
||||
|
||||
require "rscons/monkey/module"
|
||||
|
||||
# default builders
|
||||
require "rscons/builders/cc"
|
||||
require "rscons/builders/program"
|
||||
|
||||
module Rscons
|
||||
DEFAULT_BUILDERS = [
|
||||
CC,
|
||||
Program,
|
||||
]
|
||||
end
|
||||
|
4
lib/rscons/builders/cc.rb
Normal file
4
lib/rscons/builders/cc.rb
Normal file
@ -0,0 +1,4 @@
|
||||
module Rscons
|
||||
class CC < Builder
|
||||
end
|
||||
end
|
4
lib/rscons/builders/program.rb
Normal file
4
lib/rscons/builders/program.rb
Normal file
@ -0,0 +1,4 @@
|
||||
module Rscons
|
||||
class Program < Builder
|
||||
end
|
||||
end
|
@ -21,9 +21,41 @@ module Rscons
|
||||
# which are lowercase symbols (such as :echo).
|
||||
def initialize(variables = {})
|
||||
@variables = variables
|
||||
@targets = {}
|
||||
@builders = {}
|
||||
@variables[:exclude_builders] ||= []
|
||||
unless @variables[:exclude_builders] == :all
|
||||
exclude_builders = Set.new(@variables[:exclude_builders] || [])
|
||||
DEFAULT_BUILDERS.each do |builder_class|
|
||||
unless exclude_builders.include?(builder_class.short_name)
|
||||
add_builder(builder_class)
|
||||
end
|
||||
end
|
||||
end
|
||||
(@variables[:builders] || []).each do |builder_class|
|
||||
add_builder(builder_class)
|
||||
end
|
||||
end
|
||||
|
||||
def add_builder(builder_class)
|
||||
@builders[builder_class.short_name] = builder_class
|
||||
end
|
||||
|
||||
def process
|
||||
end
|
||||
|
||||
alias_method :orig_method_missing, :method_missing
|
||||
def method_missing(method, *args)
|
||||
if @builders.has_key?(method.to_s)
|
||||
target, source, *rest = args
|
||||
@targets[target] = {
|
||||
builder: method.to_s,
|
||||
source: source,
|
||||
args: rest,
|
||||
}
|
||||
else
|
||||
orig_method_missing(method, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
5
lib/rscons/monkey/module.rb
Normal file
5
lib/rscons/monkey/module.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class Module
|
||||
def short_name
|
||||
name.split(':').last
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user