start on Builder/Environment/CC/Program
This commit is contained in:
parent
8ad6384237
commit
07579fea35
@ -1,5 +1,14 @@
|
||||
require "rscons/version"
|
||||
require "rscons/builder"
|
||||
require "rscons/environment"
|
||||
|
||||
# default builders
|
||||
require "rscons/builders/cc"
|
||||
require "rscons/builders/program"
|
||||
|
||||
module Rscons
|
||||
# Your code goes here...
|
||||
DEFAULT_BUILDERS = [
|
||||
CC,
|
||||
Program
|
||||
]
|
||||
end
|
||||
|
4
lib/rscons/builder.rb
Normal file
4
lib/rscons/builder.rb
Normal file
@ -0,0 +1,4 @@
|
||||
module Rscons
|
||||
class Builder
|
||||
end
|
||||
end
|
10
lib/rscons/builders/cc.rb
Normal file
10
lib/rscons/builders/cc.rb
Normal file
@ -0,0 +1,10 @@
|
||||
module Rscons
|
||||
class CC < Builder
|
||||
VARIABLE_DEFAULTS = {
|
||||
'CC' => 'gcc',
|
||||
'CFLAGS' => [],
|
||||
'CPPFLAGS' => [],
|
||||
'OBJSUFFIX' => '.o',
|
||||
}
|
||||
end
|
||||
end
|
11
lib/rscons/builders/program.rb
Normal file
11
lib/rscons/builders/program.rb
Normal file
@ -0,0 +1,11 @@
|
||||
module Rscons
|
||||
class Program < Builder
|
||||
VARIABLE_DEFAULTS = {
|
||||
'LD' => nil,
|
||||
'OBJSUFFIX' => '.o',
|
||||
'LIBSUFFIX' => '.a',
|
||||
'LDFLAGS' => [],
|
||||
'LIBS' => [],
|
||||
}
|
||||
end
|
||||
end
|
51
lib/rscons/environment.rb
Normal file
51
lib/rscons/environment.rb
Normal file
@ -0,0 +1,51 @@
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user