start adding support for threaded commands in Environment#run_builder
This commit is contained in:
parent
e4adaab003
commit
9c13634eaf
@ -512,12 +512,15 @@ module Rscons
|
||||
# @param sources [Array<String>] List of source files.
|
||||
# @param cache [Cache] The Cache.
|
||||
# @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.
|
||||
def run_builder(builder, target, sources, cache, vars)
|
||||
def run_builder(builder, target, sources, cache, vars, options = {})
|
||||
vars = @varset.merge(vars)
|
||||
call_build_hooks = lambda do |sec|
|
||||
@build_hooks[sec].each do |build_hook_block|
|
||||
build_operation = {
|
||||
builder: builder,
|
||||
target: target,
|
||||
@ -525,16 +528,23 @@ module Rscons
|
||||
vars: vars,
|
||||
env: self,
|
||||
}
|
||||
call_build_hooks = lambda do |sec|
|
||||
@build_hooks[sec].each do |build_hook_block|
|
||||
build_hook_block.call(build_operation)
|
||||
end
|
||||
end
|
||||
|
||||
# Invoke pre-build hooks.
|
||||
call_build_hooks[:pre]
|
||||
|
||||
use_new_run_method_signature =
|
||||
begin
|
||||
builder.method(:run).arity == 1
|
||||
rescue NameError
|
||||
false
|
||||
end
|
||||
|
||||
# Call the builder's #run method.
|
||||
if use_new_run_method_signature
|
||||
rv = builder.run(
|
||||
target: target,
|
||||
@ -545,7 +555,23 @@ module Rscons
|
||||
else
|
||||
rv = builder.run(target, sources, cache, self, vars)
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
|
@ -13,6 +13,11 @@ module Rscons
|
||||
# be passed back into the builder's #finalize method.
|
||||
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.
|
||||
#
|
||||
# @param command [Array<String>]
|
||||
|
Loading…
x
Reference in New Issue
Block a user