begin transitioning builders to using instance variables instead of #run options Hash fields

This commit is contained in:
josh committed 2019-02-11 22:53:41 -05:00
1 parent ea25f62f7c
commit 86594c62b6
21 files changed
+149 -164

No files matched your search

+7 -8
View File
@@ -1,25 +1,24 @@
class DebugBuilder < Rscons::Builder
def run(options)
target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
command = %W[gcc -c -o #{target} #{sources.first}]
command = %W[gcc -c -o #{@target} #{@sources.first}]
if Rscons.vars["command_change"]
command += %w[-Wall]
end
if Rscons.vars["new_dep"]
sources += ["extra"]
@sources += ["extra"]
end
if Rscons.vars["strict_deps1"]
sources += ["extra"]
@sources += ["extra"]
strict_deps = true
end
if Rscons.vars["strict_deps2"]
sources = ["extra"] + sources
@sources = ["extra"] + @sources
strict_deps = true
end
if cache.up_to_date?(target, command, sources, env, debug: true, strict_deps: strict_deps)
target
if @cache.up_to_date?(@target, command, @sources, @env, debug: true, strict_deps: strict_deps)
@target
else
ThreadedCommand.new(command, short_description: "#{name} #{target}")
ThreadedCommand.new(command, short_description: "#{name} #{@target}")
end
end
+6 -7
View File
@@ -1,16 +1,15 @@
class TestBuilder < Rscons::Builder
def run(options)
target, sources, cache, env = options.values_at(:target, :sources, :cache, :env)
command = Rscons::VarSet.new("A" => "a", "B" => "b")
unless cache.up_to_date?(target, command, sources, env)
File.open(target, "w") do |fh|
unless @cache.up_to_date?(@target, command, @sources, @env)
File.open(@target, "w") do |fh|
fh.puts("hi")
end
msg = "#{name} #{target}"
env.print_builder_run_message(msg, msg)
cache.register_build(target, command, sources, env)
msg = "#{name} #{@target}"
@env.print_builder_run_message(msg, msg)
@cache.register_build(@target, command, @sources, @env)
end
target
@target
end
end
+4 -5
View File
@@ -1,12 +1,11 @@
class TestBuilder < Rscons::Builder
def run(options)
target, env, vars, cache = options.values_at(:target, :env, :vars, :cache)
if target == "two"
if @target == "two"
return false unless File.exists?("one")
end
wait_time = env.expand_varref("${wait_time}", vars)
command = ["ruby", "-e", "require 'fileutils'; sleep #{wait_time}; FileUtils.touch('#{target}');"]
standard_threaded_build("TestBuilder", target, command, [], env, cache)
wait_time = @env.expand_varref("${wait_time}", @vars)
command = ["ruby", "-e", "require 'fileutils'; sleep #{wait_time}; FileUtils.touch('#{@target}');"]
standard_threaded_build("TestBuilder", @target, command, [], @env, @cache)
end
def finalize(options)
@@ -1,10 +1,9 @@
class Fail < Rscons::Builder
def run(options)
target, cache, env, vars = options.values_at(:target, :cache, :env, :vars)
wait_time = env.expand_varref("${wait_time}", vars)
wait_time = @env.expand_varref("${wait_time}", @vars)
ruby_command = %[sleep #{wait_time}; exit 2]
command = %W[ruby -e #{ruby_command}]
standard_threaded_build("Fail #{target}", target, command, [], env, cache)
standard_threaded_build("Fail #{@target}", @target, command, [], @env, @cache)
end
def finalize(options)
standard_finalize(options)