begin transitioning builders to using instance variables instead of #run options Hash fields
This commit is contained in:
1 parent
ea25f62f7c
commit
86594c62b6
21 files changed
+149
-164
No files matched your search
@@ -1,15 +1,14 @@
|
||||
class CHGen < Rscons::Builder
|
||||
def run(options)
|
||||
target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
|
||||
c_fname = target
|
||||
h_fname = target.sub(/\.c$/, ".h")
|
||||
unless cache.up_to_date?([c_fname, h_fname], "", sources, env)
|
||||
c_fname = @target
|
||||
h_fname = @target.sub(/\.c$/, ".h")
|
||||
unless @cache.up_to_date?([c_fname, h_fname], "", @sources, @env)
|
||||
puts "CHGen #{c_fname}"
|
||||
File.open(c_fname, "w") {|fh| fh.puts "int THE_VALUE = 42;"}
|
||||
File.open(h_fname, "w") {|fh| fh.puts "extern int THE_VALUE;"}
|
||||
cache.register_build([c_fname, h_fname], "", sources, env)
|
||||
@cache.register_build([c_fname, h_fname], "", @sources, @env)
|
||||
end
|
||||
target
|
||||
@target
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,15 +3,14 @@ build do
|
||||
require 'json'
|
||||
require 'yaml'
|
||||
env.add_builder(:JsonToYaml) do |params|
|
||||
target, sources, cache, env, vars = params.values_at(:target, :sources, :cache, :env, :vars)
|
||||
unless cache.up_to_date?(target, :JsonToYaml, sources, env)
|
||||
cache.mkdir_p(File.dirname(target))
|
||||
File.open(target, 'w') do |f|
|
||||
f.write(YAML.dump(JSON.load(IO.read(sources.first))))
|
||||
unless @cache.up_to_date?(@target, :JsonToYaml, @sources, @env)
|
||||
@cache.mkdir_p(File.dirname(@target))
|
||||
File.open(@target, 'w') do |f|
|
||||
f.write(YAML.dump(JSON.load(IO.read(@sources.first))))
|
||||
end
|
||||
cache.register_build(target, :JsonToYaml, sources, env)
|
||||
@cache.register_build(@target, :JsonToYaml, @sources, @env)
|
||||
end
|
||||
target
|
||||
@target
|
||||
end
|
||||
env.JsonToYaml('foo.yml', 'foo.json')
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
class StrictBuilder < Rscons::Builder
|
||||
def run(options)
|
||||
target, sources, cache, env = options.values_at(:target, :sources, :cache, :env)
|
||||
command = %W[gcc -o #{target}] + sources.sort
|
||||
if cache.up_to_date?(target, command, sources, env, strict_deps: true)
|
||||
target
|
||||
command = %W[gcc -o #{@target}] + @sources.sort
|
||||
if @cache.up_to_date?(@target, command, @sources, @env, strict_deps: true)
|
||||
@target
|
||||
else
|
||||
ThreadedCommand.new(command, short_description: "#{name} #{target}")
|
||||
ThreadedCommand.new(command, short_description: "#{name} #{@target}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user