From d047a1bf29b46f95bdad935ed62f1657dc2fe7ae Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 16 Feb 2019 18:06:03 -0500 Subject: [PATCH] JobSet only stores builders instead of build info hashes --- lib/rscons/environment.rb | 44 +++++++++------------------------------ lib/rscons/job_set.rb | 20 ++++++------------ 2 files changed, 16 insertions(+), 48 deletions(-) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 748821c..b0f73fb 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -264,25 +264,22 @@ module Rscons if failure @job_set.clear! - job = nil + builder = nil else targets_still_building = @threaded_commands.map do |tc| tc.builder.target end - job = @job_set.get_next_job_to_run(targets_still_building) + builder = @job_set.get_next_job_to_run(targets_still_building) end # TODO: have Cache determine when checksums may be invalid based on # file size and/or timestamp. cache.clear_checksum_cache! - if job - result = run_builder(job[:builder], - job[:target], - job[:sources], - cache) + if builder + result = run_builder(builder, cache) unless result - failure = "Failed to build #{job[:target]}" + failure = "Failed to build #{builder.target}" Ansi.write($stderr, :red, failure, :reset, "\n") next end @@ -297,7 +294,7 @@ module Rscons # If needed, do a blocking wait. if (@threaded_commands.size > 0) and - ((completed_tcs.empty? and job.nil?) or (@threaded_commands.size >= n_threads)) + ((completed_tcs.empty? and builder.nil?) or (@threaded_commands.size >= n_threads)) completed_tcs << wait_for_threaded_commands end @@ -359,7 +356,7 @@ module Rscons cache: Cache.instance, env: self, vars: vars) - add_target(builder.target, builder, sources, vars) + @job_set.add_job(builder) builder else super @@ -511,20 +508,15 @@ module Rscons # Invoke a builder to build the given target based on the given sources. # # @param builder [Builder] The Builder to use. - # @param target [String] The target output file. - # @param sources [Array] List of source files. # @param cache [Cache] The Cache. - # @param options [Hash] - # @since 1.10.0 - # Options. # # @return [String,false] Return value from the {Builder}'s +run+ method. - def run_builder(builder, target, sources, cache, options = {}) + def run_builder(builder, cache) builder.vars = @varset.merge(builder.vars) build_operation = { builder: builder, - target: target, - sources: sources, + target: builder.target, + sources: builder.sources, cache: cache, env: self, vars: builder.vars, @@ -651,22 +643,6 @@ module Rscons private - # Add a build target. - # - # @param target [String] Build target file name. - # @param builder [Builder] The {Builder} to use to build the target. - # @param sources [Array] Source file name(s). - # @param vars [Hash] Construction variable overrides. - # - # @return [void] - def add_target(target, builder, sources, vars) - @job_set.add_job( - builder: builder, - target: target, - sources: sources, - vars: vars) - end - # Start a threaded command in a new thread. # # @param tc [ThreadedCommand] diff --git a/lib/rscons/job_set.rb b/lib/rscons/job_set.rb index 942c81b..6e4adf6 100644 --- a/lib/rscons/job_set.rb +++ b/lib/rscons/job_set.rb @@ -21,23 +21,15 @@ module Rscons # Add a job to the JobSet. # - # @param options [Hash] - # Options. - # @option options [Symbol, String] :target - # Build target name. - # @option options [Builder] :builder - # The {Builder} to use to build the target. - # @option options [Array] :sources - # Source file name(s). - # @option options [Hash] :vars - # Construction variable overrides. - def add_job(options) + # @param builder [Builder] + # The {Builder} that will produce the target. + def add_job(builder) # We allow multiple jobs to be registered per target for cases like: # env.Directory("dest") # env.Install("dest", "bin") # env.Install("dest", "share") - @jobs[options[:target]] ||= [] - @jobs[options[:target]] << options + @jobs[builder.target] ||= [] + @jobs[builder.target] << builder end # Get the next job that is ready to run from the JobSet. @@ -60,7 +52,7 @@ module Rscons @jobs.keys.each do |target| skip = false - (@jobs[target][0][:sources] + (@build_dependencies[target] || []).to_a).each do |src| + (@jobs[target][0].sources + (@build_dependencies[target] || []).to_a).each do |src| if targets_not_built_yet.include?(src) skip = true break