fully parallelize the Preprocess builder
This commit is contained in:
1 parent
178940cd5d
commit
80a80a7cb0
3 files changed
+31
-70
No files matched your search
@@ -79,8 +79,9 @@ module Rscons
|
||||
#
|
||||
# @param options [Hash] Builder run options.
|
||||
#
|
||||
# @return [ThreadedCommand]
|
||||
# Threaded command to execute.
|
||||
# @return [String, ThreadedCommand]
|
||||
# Target file name if target is up to date or a {ThreadedCommand}
|
||||
# to execute to build the target.
|
||||
def run(options)
|
||||
target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
|
||||
vars = vars.merge({
|
||||
@@ -88,14 +89,14 @@ module Rscons
|
||||
'_SOURCES' => sources,
|
||||
'_DEPFILE' => Rscons.set_suffix(target, env.expand_varref("${DEPFILESUFFIX}", vars)),
|
||||
})
|
||||
# Store vars back into options so new keys are accessible in #finalize.
|
||||
options[:vars] = vars
|
||||
com_prefix = KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
||||
sources.first.end_with?(*env.expand_varref("${#{suffix_var}}"))
|
||||
end.tap do |v|
|
||||
v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}"
|
||||
end.first
|
||||
command = env.build_command("${#{com_prefix}CMD}", vars)
|
||||
# Store vars back into options so new keys are accessible in #finalize.
|
||||
options[:vars] = vars
|
||||
standard_threaded_build("#{com_prefix} #{target}", target, command, sources, env, cache)
|
||||
end
|
||||
|
||||
@@ -103,7 +104,7 @@ module Rscons
|
||||
#
|
||||
# @param options [Hash] Builder finalize options.
|
||||
#
|
||||
# @return [String,nil]
|
||||
# @return [String, nil]
|
||||
# Name of the target file on success or nil on failure.
|
||||
def finalize(options)
|
||||
if options[:command_status]
|
||||
|
||||
@@ -20,15 +20,13 @@ module Rscons
|
||||
|
||||
# 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.
|
||||
# @param options [Hash] Builder run options.
|
||||
#
|
||||
# @return [String,false]
|
||||
# Name of the target file on success or false on failure.
|
||||
def run(target, sources, cache, env, vars)
|
||||
# @return [String, ThreadedCommand]
|
||||
# Target file name if target is up to date or a {ThreadedCommand}
|
||||
# to execute to build the target.
|
||||
def run(options)
|
||||
target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
|
||||
if sources.find {|s| s.end_with?(*env.expand_varref("${CXXSUFFIX}", vars))}
|
||||
pp_cc = "${CXX}"
|
||||
depgen = "${CXXDEPGEN}"
|
||||
@@ -42,17 +40,27 @@ module Rscons
|
||||
"_SOURCES" => sources,
|
||||
"_DEPFILE" => Rscons.set_suffix(target, env.expand_varref("${DEPFILESUFFIX}", vars)))
|
||||
command = env.build_command("${CPP_CMD}", vars)
|
||||
unless cache.up_to_date?(target, command, sources, env)
|
||||
cache.mkdir_p(File.dirname(target))
|
||||
return false unless env.execute("Preprocess #{target}", command)
|
||||
deps = sources
|
||||
if File.exists?(vars["_DEPFILE"])
|
||||
deps += Environment.parse_makefile_deps(vars["_DEPFILE"], nil)
|
||||
FileUtils.rm_f(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)
|
||||
end
|
||||
|
||||
# Finalize the build operation.
|
||||
#
|
||||
# @param options [Hash] Builder finalize options.
|
||||
#
|
||||
# @return [String, nil]
|
||||
# Name of the target file on success or nil on failure.
|
||||
def finalize(options)
|
||||
if options[:command_status]
|
||||
target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
|
||||
if File.exists?(vars['_DEPFILE'])
|
||||
deps += Environment.parse_makefile_deps(vars['_DEPFILE'], nil)
|
||||
FileUtils.rm_f(vars['_DEPFILE'])
|
||||
end
|
||||
cache.register_build(target, command, deps.uniq, env)
|
||||
cache.register_build(target, options[:tc].command, deps.uniq, env)
|
||||
target
|
||||
end
|
||||
target
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user