add Library default builder
This commit is contained in:
1 parent
e04e67698a
commit
64d15602cc
8 files changed
+63
No files matched your search
@@ -8,12 +8,14 @@ require "rscons/monkey/module"
|
||||
require "rscons/monkey/string"
|
||||
|
||||
# default builders
|
||||
require "rscons/builders/library"
|
||||
require "rscons/builders/object"
|
||||
require "rscons/builders/program"
|
||||
|
||||
# Namespace module for rscons classes
|
||||
module Rscons
|
||||
DEFAULT_BUILDERS = [
|
||||
Library,
|
||||
Object,
|
||||
Program,
|
||||
]
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
require 'fileutils'
|
||||
|
||||
module Rscons
|
||||
# A default RScons builder that produces a static library archive.
|
||||
class Library < Builder
|
||||
def default_variables(env)
|
||||
{
|
||||
'AR' => 'ar',
|
||||
'LIBSUFFIX' => '.a',
|
||||
'ARFLAGS' => [],
|
||||
'ARCOM' => ['$AR', 'rcs', '$ARFLAGS', '$TARGET', '$SOURCES']
|
||||
}
|
||||
end
|
||||
|
||||
def run(target, sources, cache, env, vars = {})
|
||||
# build sources to linkable objects
|
||||
objects = env.build_sources(sources, [env['OBJSUFFIX'], env['LIBSUFFIX']].flatten, cache, vars)
|
||||
if objects
|
||||
vars = vars.merge({
|
||||
'TARGET' => target,
|
||||
'SOURCES' => objects,
|
||||
})
|
||||
command = env.build_command(env['ARCOM'], vars)
|
||||
unless cache.up_to_date?(target, command, objects)
|
||||
FileUtils.rm_f(target)
|
||||
return false unless env.execute("AR #{target}", command)
|
||||
cache.register_build(target, command, objects)
|
||||
end
|
||||
target
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -194,6 +194,9 @@ module Rscons
|
||||
def method_missing(method, *args)
|
||||
if @builders.has_key?(method.to_s)
|
||||
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],
|
||||
|
||||
Reference in new issue
Block a user