Rework builder interface to only use #run method - close #91

The builder's #run method will be called repeatedly until it returns
true or false. The Builder#wait_for method can be used to cause a
builder to wait for a Thread, Command, or another Builder.
This commit is contained in:
josh committed 2019-02-17 22:08:39 -05:00
1 parent 8426a54a57
commit b882f8de99
38 files changed
+580 -665

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
class TestBuilder < Rscons::Builder
def run(options)
target
true
end
end
build do
+22 -22
View File
@@ -1,30 +1,30 @@
class DebugBuilder < Rscons::Builder
def run(options)
command = %W[gcc -c -o #{@target} #{@sources.first}]
if Rscons.vars["command_change"]
command += %w[-Wall]
end
if Rscons.vars["new_dep"]
@sources += ["extra"]
end
if Rscons.vars["strict_deps1"]
@sources += ["extra"]
strict_deps = true
end
if Rscons.vars["strict_deps2"]
@sources = ["extra"] + @sources
strict_deps = true
end
if @cache.up_to_date?(@target, command, @sources, @env, debug: true, strict_deps: strict_deps)
@target
if @command
finalize_command
else
ThreadedCommand.new(command, short_description: "#{name} #{@target}")
@command = %W[gcc -c -o #{@target} #{@sources.first}]
if Rscons.vars["command_change"]
@command += %w[-Wall]
end
if Rscons.vars["new_dep"]
@sources += ["extra"]
end
if Rscons.vars["strict_deps1"]
@sources += ["extra"]
strict_deps = true
end
if Rscons.vars["strict_deps2"]
@sources = ["extra"] + @sources
strict_deps = true
end
if @cache.up_to_date?(@target, @command, @sources, @env, debug: true, strict_deps: strict_deps)
true
else
register_command("#{name} #{target}", @command)
end
end
end
def finalize(options)
standard_finalize(options)
end
end
build do
+1 -1
View File
@@ -9,7 +9,7 @@ class TestBuilder < Rscons::Builder
@env.print_builder_run_message(msg, msg)
@cache.register_build(@target, command, @sources, @env)
end
@target
true
end
end
+1 -1
View File
@@ -5,7 +5,7 @@ build do
puts "Checker #{@sources.first}" if @env.echo != :off
@cache.register_build(@target, :Checker, @sources, @env)
end
@target
true
end
env.Program("simple.exe", "simple.c")
env.Checker(:checker, "simple.exe")
+7 -8
View File
@@ -1,12 +1,11 @@
class ThreadedTestBuilder < Rscons::Builder
def run(options)
command = ["ruby", "-e", %[sleep 1]]
Rscons::ThreadedCommand.new(
command,
short_description: "ThreadedTestBuilder #{@target}")
end
def finalize(options)
true
if @command
true
else
@command = ["ruby", "-e", %[sleep 1]]
register_command("ThreadedTestBuilder #{@target}", @command)
end
end
end
@@ -14,7 +13,7 @@ class NonThreadedTestBuilder < Rscons::Builder
def run(options)
puts "NonThreadedTestBuilder #{@target}"
sleep 1
@target
true
end
end
+9 -9
View File
@@ -1,15 +1,15 @@
class TestBuilder < Rscons::Builder
def run(options)
if @target == "two"
return false unless File.exists?("one")
if @command
true
else
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}');"]
register_command("TestBuilder", @command)
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)
end
def finalize(options)
standard_finalize(options)
end
end
@@ -1,12 +1,13 @@
class Fail < Rscons::Builder
def run(options)
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)
end
def finalize(options)
standard_finalize(options)
if @command
finalize_command
else
wait_time = @env.expand_varref("${wait_time}", @vars)
ruby_command = %[sleep #{wait_time}; exit 2]
@command = %W[ruby -e #{ruby_command}]
register_command("Fail #{@target}", @command)
end
end
end