start adding support for threaded commands in Environment#run_builder
This commit is contained in:
parent
e4adaab003
commit
9c13634eaf
@ -512,29 +512,39 @@ module Rscons
|
|||||||
# @param sources [Array<String>] List of source files.
|
# @param sources [Array<String>] List of source files.
|
||||||
# @param cache [Cache] The Cache.
|
# @param cache [Cache] The Cache.
|
||||||
# @param vars [Hash] Extra variables to pass to the builder.
|
# @param vars [Hash] Extra variables to pass to the builder.
|
||||||
|
# @param options [Hash] Options.
|
||||||
|
# @option options [Boolean] :allow_delayed_execution
|
||||||
|
# @since 1.10.0
|
||||||
|
# Allow a threaded command to be scheduled but not yet completed before
|
||||||
|
# this method returns.
|
||||||
#
|
#
|
||||||
# @return [String,false] Return value from the {Builder}'s +run+ method.
|
# @return [String,false] Return value from the {Builder}'s +run+ method.
|
||||||
def run_builder(builder, target, sources, cache, vars)
|
def run_builder(builder, target, sources, cache, vars, options = {})
|
||||||
vars = @varset.merge(vars)
|
vars = @varset.merge(vars)
|
||||||
|
build_operation = {
|
||||||
|
builder: builder,
|
||||||
|
target: target,
|
||||||
|
sources: sources,
|
||||||
|
vars: vars,
|
||||||
|
env: self,
|
||||||
|
}
|
||||||
call_build_hooks = lambda do |sec|
|
call_build_hooks = lambda do |sec|
|
||||||
@build_hooks[sec].each do |build_hook_block|
|
@build_hooks[sec].each do |build_hook_block|
|
||||||
build_operation = {
|
|
||||||
builder: builder,
|
|
||||||
target: target,
|
|
||||||
sources: sources,
|
|
||||||
vars: vars,
|
|
||||||
env: self,
|
|
||||||
}
|
|
||||||
build_hook_block.call(build_operation)
|
build_hook_block.call(build_operation)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Invoke pre-build hooks.
|
||||||
call_build_hooks[:pre]
|
call_build_hooks[:pre]
|
||||||
|
|
||||||
use_new_run_method_signature =
|
use_new_run_method_signature =
|
||||||
begin
|
begin
|
||||||
builder.method(:run).arity == 1
|
builder.method(:run).arity == 1
|
||||||
rescue NameError
|
rescue NameError
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Call the builder's #run method.
|
||||||
if use_new_run_method_signature
|
if use_new_run_method_signature
|
||||||
rv = builder.run(
|
rv = builder.run(
|
||||||
target: target,
|
target: target,
|
||||||
@ -545,7 +555,23 @@ module Rscons
|
|||||||
else
|
else
|
||||||
rv = builder.run(target, sources, cache, self, vars)
|
rv = builder.run(target, sources, cache, self, vars)
|
||||||
end
|
end
|
||||||
call_build_hooks[:post] if rv
|
|
||||||
|
if rv.is_a?(ThreadedCommand)
|
||||||
|
if options[:allow_delayed_execution]
|
||||||
|
# Store the build operation so the post-build hooks can be called
|
||||||
|
# with it when the threaded command completes.
|
||||||
|
rv.build_operation = build_operation
|
||||||
|
else
|
||||||
|
# Delayed command execution is not allowed, so we need to execute
|
||||||
|
# the command and finalize the builder now.
|
||||||
|
# TODO
|
||||||
|
#rv = builder.finalize()
|
||||||
|
call_build_hooks[:post] if rv
|
||||||
|
end
|
||||||
|
else
|
||||||
|
call_build_hooks[:post] if rv
|
||||||
|
end
|
||||||
|
|
||||||
rv
|
rv
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,6 +13,11 @@ module Rscons
|
|||||||
# be passed back into the builder's #finalize method.
|
# be passed back into the builder's #finalize method.
|
||||||
attr_reader :builder_info
|
attr_reader :builder_info
|
||||||
|
|
||||||
|
# @return [Hash]
|
||||||
|
# Field for Rscons to store the build operation while this threaded
|
||||||
|
# command is executing.
|
||||||
|
attr_accessor :build_operation
|
||||||
|
|
||||||
# Create a ThreadedCommand object.
|
# Create a ThreadedCommand object.
|
||||||
#
|
#
|
||||||
# @param command [Array<String>]
|
# @param command [Array<String>]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user