Drop support for 5-argument form of Builder#run - #84

This commit is contained in:
Josh Holtrop 2019-02-10 21:47:34 -05:00
parent b41a368da1
commit 7992450383
12 changed files with 36 additions and 93 deletions

View File

@ -1,11 +1,11 @@
class MySource < Rscons::Builder class MySource < Rscons::Builder
def run(target, sources, cache, env, vars) def run(options)
File.open(target, 'w') do |fh| File.open(@target, 'w') do |fh|
fh.puts <<EOF fh.puts <<EOF
#define THE_VALUE 5678 #define THE_VALUE 5678
EOF EOF
end end
target @target
end end
end end

View File

@ -1,11 +1,11 @@
class MySource < Rscons::Builder class MySource < Rscons::Builder
def run(target, sources, cache, env, vars) def run(options)
File.open(target, 'w') do |fh| File.open(@target, 'w') do |fh|
fh.puts <<EOF fh.puts <<EOF
#define THE_VALUE 678 #define THE_VALUE 678
EOF EOF
end end
target @target
end end
end end

View File

@ -1,11 +1,11 @@
class MySource < Rscons::Builder class MySource < Rscons::Builder
def run(target, sources, cache, env, vars) def run(options)
File.open(target, 'w') do |fh| File.open(@target, 'w') do |fh|
fh.puts <<EOF fh.puts <<EOF
#define THE_VALUE #{env.expand_varref("${the_value}")} #define THE_VALUE #{@env.expand_varref("${the_value}")}
EOF EOF
end end
target @target
end end
end end

View File

@ -1,5 +1,6 @@
class CHGen < Rscons::Builder class CHGen < Rscons::Builder
def run(target, sources, cache, env, vars) def run(options)
target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
c_fname = target c_fname = target
h_fname = target.sub(/\.c$/, ".h") h_fname = target.sub(/\.c$/, ".h")
unless cache.up_to_date?([c_fname, h_fname], "", sources, env) unless cache.up_to_date?([c_fname, h_fname], "", sources, env)

View File

@ -1,5 +1,5 @@
class TestBuilder < Rscons::Builder class TestBuilder < Rscons::Builder
def run(target, sources, cache, env, vars) def run(options)
target target
end end
end end

View File

@ -1,5 +1,6 @@
class MyObject < Rscons::Builder class MyObject < Rscons::Builder
def run(target, sources, cache, env, vars) def run(options)
target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
env.run_builder(env.builders["Object"].new(target: target, sources: sources, cache: cache, env: env, vars: vars), target, sources, cache, vars) env.run_builder(env.builders["Object"].new(target: target, sources: sources, cache: cache, env: env, vars: vars), target, sources, cache, vars)
end end
end end

View File

@ -86,29 +86,6 @@ module Rscons
# Run the builder to produce a build target. # Run the builder to produce a build target.
# #
# The run method supports two different signatures - an older signature
# with five separate arguments, and a newer one with one Hash argument. A
# builder author can use either signature, and Rscons will automatically
# determine which arguments to pass when invoking the run method based on
# the method's arity.
#
# @overload run(target, sources, cache, env, vars)
#
# @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.
#
# @overload run(options)
#
# @since 1.10.0
#
# @param options [Hash] # @param options [Hash]
# Run options. # Run options.
# @option options [String] :target # @option options [String] :target

View File

@ -20,16 +20,8 @@ module Rscons
) )
# Run the builder to produce a build target. # Run the builder to produce a build target.
# def run(options)
# @param target [String] Target file name. target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
# @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.
#
# @return [String,false]
# Name of the target file on success or false on failure.
def run(target, sources, cache, env, vars)
vars = vars.merge({ vars = vars.merge({
"_TARGET" => target, "_TARGET" => target,
"_SOURCES" => sources, "_SOURCES" => sources,

View File

@ -4,16 +4,8 @@ module Rscons
class Directory < Builder class Directory < Builder
# Run the builder to produce a build target. # Run the builder to produce a build target.
# def run(options)
# @param target [String] Target file name. target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
# @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.
#
# @return [String,false]
# Name of the target file on success or false on failure.
def run(target, sources, cache, env, vars)
if File.directory?(target) if File.directory?(target)
target target
elsif File.exists?(target) elsif File.exists?(target)

View File

@ -10,16 +10,8 @@ module Rscons
) )
# Run the builder to produce a build target. # Run the builder to produce a build target.
# def run(options)
# @param target [String] Target file name. target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
# @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.
#
# @return [String,false]
# Name of the target file on success or false on failure.
def run(target, sources, cache, env, vars)
vars = vars.merge("_SOURCES" => sources) vars = vars.merge("_SOURCES" => sources)
command = env.build_command("${DISASM_CMD}", vars) command = env.build_command("${DISASM_CMD}", vars)
if cache.up_to_date?(target, command, sources, env) if cache.up_to_date?(target, command, sources, env)

View File

@ -6,16 +6,8 @@ module Rscons
class Install < Builder class Install < Builder
# Run the builder to produce a build target. # Run the builder to produce a build target.
# def run(options)
# @param target [String] Target file name. target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
# @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.
#
# @return [String,false]
# Name of the target file on success or false on failure.
def run(target, sources, cache, env, vars)
target_is_dir = (sources.length > 1) || target_is_dir = (sources.length > 1) ||
Dir.exists?(sources.first) || Dir.exists?(sources.first) ||
Dir.exists?(target) Dir.exists?(target)

View File

@ -541,11 +541,7 @@ module Rscons
call_build_hooks[:pre] call_build_hooks[:pre]
# Call the builder's #run method. # Call the builder's #run method.
if builder.method(:run).arity == 5
rv = builder.run(*build_operation.values_at(:target, :sources, :cache, :env, :vars))
else
rv = builder.run(build_operation) rv = builder.run(build_operation)
end
(@side_effects[build_operation[:target]] || []).each do |side_effect_file| (@side_effects[build_operation[:target]] || []).each do |side_effect_file|
# Register side-effect files as build targets so that a Cache clean # Register side-effect files as build targets so that a Cache clean