move default builder classes into Rscons::Builders namespace module
This commit is contained in:
parent
cdb3352b4e
commit
5362f761e6
@ -14,9 +14,9 @@ require "rscons/builders/program"
|
||||
# Namespace module for rscons classes
|
||||
module Rscons
|
||||
DEFAULT_BUILDERS = [
|
||||
Library,
|
||||
Object,
|
||||
Program,
|
||||
:Library,
|
||||
:Object,
|
||||
:Program,
|
||||
]
|
||||
|
||||
class BuildError < RuntimeError; end
|
||||
|
@ -1,6 +1,9 @@
|
||||
require "fileutils"
|
||||
|
||||
module Rscons
|
||||
# Namespace module in which to store builders for convenient grouping
|
||||
module Builders; end
|
||||
|
||||
# Class to hold an object that knows how to build a certain type of file.
|
||||
class Builder
|
||||
# Return the name of the builder.
|
||||
|
@ -1,8 +1,7 @@
|
||||
require 'fileutils'
|
||||
|
||||
module Rscons
|
||||
module Builders
|
||||
# A default RScons builder that produces a static library archive.
|
||||
class Library < Builder
|
||||
class Rscons::Builders::Library < Rscons::Builder
|
||||
def default_variables(env)
|
||||
{
|
||||
'AR' => 'ar',
|
||||
@ -26,3 +25,4 @@ module Rscons
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
module Rscons
|
||||
module Builders
|
||||
# A default RScons builder which knows how to produce an object file from
|
||||
# various types of source files.
|
||||
class Object < Builder
|
||||
@ -77,3 +78,4 @@ module Rscons
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,8 @@
|
||||
module Rscons
|
||||
module Builders
|
||||
# A default RScons builder that knows how to link object files into an
|
||||
# executable program.
|
||||
class Program < Builder
|
||||
class Rscons::Builders::Program < Rscons::Builder
|
||||
def default_variables(env)
|
||||
{
|
||||
'LD' => nil,
|
||||
@ -37,3 +38,4 @@ module Rscons
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -34,7 +34,9 @@ module Rscons
|
||||
@build_dirs = []
|
||||
@build_hooks = []
|
||||
unless options[:exclude_builders]
|
||||
DEFAULT_BUILDERS.each do |builder_class|
|
||||
DEFAULT_BUILDERS.each do |builder_class_name|
|
||||
builder_class = Builders.const_get(builder_class_name)
|
||||
builder_class or raise "Could not find builder class #{builder_class_name}"
|
||||
add_builder(builder_class.new)
|
||||
end
|
||||
end
|
||||
|
@ -48,7 +48,7 @@ module Rscons
|
||||
it "adds the builder to the list of builders" do
|
||||
env = Environment.new(exclude_builders: true)
|
||||
env.builders.keys.should == []
|
||||
env.add_builder(Rscons::Object.new)
|
||||
env.add_builder(Rscons::Builders::Object.new)
|
||||
env.builders.keys.should == ["Object"]
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user