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