create Builder instance for each build operation - close #88
This commit is contained in:
1 parent
12f1909d35
commit
aac32d20b0
28 files changed
+181
-147
No files matched your search
@@ -43,7 +43,7 @@ module Rscons
|
||||
# Check the cache and copy if necessary
|
||||
unless cache.up_to_date?(dest, :Copy, [src], env)
|
||||
unless printed_message
|
||||
env.print_builder_run_message("#{name} #{target}", nil)
|
||||
env.print_builder_run_message("#{self.class.name} #{target}", nil)
|
||||
printed_message = true
|
||||
end
|
||||
cache.mkdir_p(File.dirname(dest))
|
||||
|
||||
@@ -53,24 +53,26 @@ module Rscons
|
||||
'DCCMD' => ['${DC}', '-c', '-o', '${_TARGET}', '${DDEPGEN}', '${INCPREFIX}${D_IMPORT_PATH}', '${DFLAGS}', '${_SOURCES}'],
|
||||
)
|
||||
|
||||
# Return whether this builder object is capable of producing a given target
|
||||
# file name from a given source file name.
|
||||
#
|
||||
# @param target [String]
|
||||
# The target file name.
|
||||
# @param source [String]
|
||||
# The source file name.
|
||||
# @param env [Environment]
|
||||
# The Environment.
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Whether this builder object is capable of producing a given target
|
||||
# file name from a given source file name.
|
||||
def produces?(target, source, env)
|
||||
target.end_with?(*env['OBJSUFFIX']) and
|
||||
KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
||||
source.end_with?(*env[suffix_var])
|
||||
end
|
||||
class << self
|
||||
# Return whether this builder object is capable of producing a given target
|
||||
# file name from a given source file name.
|
||||
#
|
||||
# @param target [String]
|
||||
# The target file name.
|
||||
# @param source [String]
|
||||
# The source file name.
|
||||
# @param env [Environment]
|
||||
# The Environment.
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Whether this builder object is capable of producing a given target
|
||||
# file name from a given source file name.
|
||||
def produces?(target, source, env)
|
||||
target.end_with?(*env['OBJSUFFIX']) and
|
||||
KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
||||
source.end_with?(*env[suffix_var])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Run the builder to produce a build target.
|
||||
|
||||
@@ -36,7 +36,7 @@ module Rscons
|
||||
env.produces(target, vars['_DEPFILE'])
|
||||
# Store vars back into options so new keys are accessible in #finalize.
|
||||
options[:vars] = vars
|
||||
standard_threaded_build("#{name} #{target}", target, command, sources, env, cache)
|
||||
standard_threaded_build("#{self.class.name} #{target}", target, command, sources, env, cache)
|
||||
end
|
||||
|
||||
# Finalize the build operation.
|
||||
|
||||
@@ -14,12 +14,14 @@ module Rscons
|
||||
'SHLDCMD' => ['${SHLD}', '-o', '${_TARGET}', '${SHLDFLAGS}', '${_SOURCES}', '${SHLIBDIRPREFIX}${LIBPATH}', '${SHLIBLINKPREFIX}${LIBS}']
|
||||
)
|
||||
|
||||
# Return a set of build features that this builder provides.
|
||||
#
|
||||
# @return [Array<String>]
|
||||
# Set of build features that this builder provides.
|
||||
def features
|
||||
%w[shared]
|
||||
class << self
|
||||
# Return a set of build features that this builder provides.
|
||||
#
|
||||
# @return [Array<String>]
|
||||
# Set of build features that this builder provides.
|
||||
def features
|
||||
%w[shared]
|
||||
end
|
||||
end
|
||||
|
||||
# Create a BuildTarget object for this build target.
|
||||
|
||||
@@ -30,32 +30,34 @@ module Rscons
|
||||
'SHDCCMD' => ['${SHDC}', '-c', '-o', '${_TARGET}', '${INCPREFIX}${D_IMPORT_PATH}', '${SHDFLAGS}', '${_SOURCES}'],
|
||||
)
|
||||
|
||||
# Return a set of build features that this builder provides.
|
||||
#
|
||||
# @return [Array<String>]
|
||||
# Set of build features that this builder provides.
|
||||
def features
|
||||
%w[shared]
|
||||
end
|
||||
class << self
|
||||
# Return a set of build features that this builder provides.
|
||||
#
|
||||
# @return [Array<String>]
|
||||
# Set of build features that this builder provides.
|
||||
def features
|
||||
%w[shared]
|
||||
end
|
||||
|
||||
# Return whether this builder object is capable of producing a given target
|
||||
# file name from a given source file name.
|
||||
#
|
||||
# @param target [String]
|
||||
# The target file name.
|
||||
# @param source [String]
|
||||
# The source file name.
|
||||
# @param env [Environment]
|
||||
# The Environment.
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Whether this builder object is capable of producing a given target
|
||||
# file name from a given source file name.
|
||||
def produces?(target, source, env)
|
||||
target.end_with?(*env['OBJSUFFIX']) and
|
||||
KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
||||
source.end_with?(*env[suffix_var])
|
||||
end
|
||||
# Return whether this builder object is capable of producing a given target
|
||||
# file name from a given source file name.
|
||||
#
|
||||
# @param target [String]
|
||||
# The target file name.
|
||||
# @param source [String]
|
||||
# The source file name.
|
||||
# @param env [Environment]
|
||||
# The Environment.
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Whether this builder object is capable of producing a given target
|
||||
# file name from a given source file name.
|
||||
def produces?(target, source, env)
|
||||
target.end_with?(*env['OBJSUFFIX']) and
|
||||
KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
||||
source.end_with?(*env[suffix_var])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Run the builder to produce a build target.
|
||||
|
||||
@@ -1,39 +1,26 @@
|
||||
module Rscons
|
||||
module Builders
|
||||
# A Generic builder class whose name and operation is defined at
|
||||
# instantiation.
|
||||
# A Generic builder which has its operation is defined at instantiation.
|
||||
#
|
||||
# @since 1.8.0
|
||||
class SimpleBuilder < Builder
|
||||
# @return [String] The name of this builder.
|
||||
attr_reader :name
|
||||
|
||||
# Create a new builder with the given name and action.
|
||||
# Create a new builder with the given action.
|
||||
#
|
||||
# @param name [String,Symbol] The name of the builder when registered.
|
||||
# @param block [Block]
|
||||
# The action to perform when the builder is processed. The provided
|
||||
# block must return the target file on success or false on failure.
|
||||
# The provided block should have the same signature as {Builder#run}.
|
||||
def initialize(name, &block)
|
||||
@name = name.to_s
|
||||
@block = block
|
||||
# @param run_proc [Proc]
|
||||
# A Proc to execute when the builder runs. The provided block must
|
||||
# provide the have the same signature as {Builder#run}.
|
||||
def initialize(&run_proc)
|
||||
@run_proc = run_proc
|
||||
end
|
||||
|
||||
# Run the builder to produce a build target.
|
||||
#
|
||||
# @param target [String] Target file name.
|
||||
# @param sources [Array<String>] Source file name(s).
|
||||
# @param cache [Cache] The Cache object.
|
||||
# @param env [Environment] The Environment executing the builder.
|
||||
# @param vars [Hash,VarSet] Extra construction variables.
|
||||
#
|
||||
# @return [String,false]
|
||||
# Name of the target file on success or false on failure.
|
||||
def run(target, sources, cache, env, vars)
|
||||
@block.call(target, sources, cache, env, vars)
|
||||
# Method signature described by {Builder#run}.
|
||||
def run(*args)
|
||||
@run_proc.call(*args)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user