Pre-build hooks do not respect modified key values for old-style builders
This commit is contained in:
parent
f1b24ee8ba
commit
387c40176b
22
build_tests/build_dir/backward_compatible_build_hooks.rb
Normal file
22
build_tests/build_dir/backward_compatible_build_hooks.rb
Normal file
@ -0,0 +1,22 @@
|
||||
class MyObject < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
env.run_builder(env.builders["Object"], target, sources, cache, vars)
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.add_builder(MyObject.new)
|
||||
env.append('CPPPATH' => Dir['src/**/*/'].sort)
|
||||
env.add_build_hook do |build_op|
|
||||
if build_op[:builder].name == "MyObject" && build_op[:sources].first =~ %r{one\.c}
|
||||
build_op[:vars]["CFLAGS"] << "-O1"
|
||||
build_op[:sources] = ['src/two/two.c']
|
||||
elsif build_op[:builder].name == "MyObject" && build_op[:target] =~ %r{two\.o}
|
||||
new_vars = build_op[:vars].clone
|
||||
new_vars["CFLAGS"] << "-O2"
|
||||
build_op[:vars] = new_vars
|
||||
end
|
||||
end
|
||||
env.MyObject('one.o', 'src/one/one.c')
|
||||
env.MyObject('two.o', 'src/two/two.c')
|
||||
end
|
@ -615,7 +615,7 @@ module Rscons
|
||||
|
||||
# Call the builder's #run method.
|
||||
if builder.method(:run).arity == 5
|
||||
rv = builder.run(target, sources, cache, self, vars)
|
||||
rv = builder.run(*build_operation.values_at(:target, :sources, :cache, :env, :vars))
|
||||
else
|
||||
rv = builder.run(build_operation)
|
||||
end
|
||||
|
@ -776,6 +776,18 @@ EOF
|
||||
result = run_test(rsconsfile: "bc_produces.rb")
|
||||
expect(result.stderr).to eq ""
|
||||
end
|
||||
|
||||
it 'supports build hooks to override construction variables' do
|
||||
test_dir("build_dir")
|
||||
result = run_test(rsconsfile: "backward_compatible_build_hooks.rb")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(Set[*lines(result.stdout)]).to eq Set[
|
||||
'gcc -c -o one.o -MMD -MF one.mf -Isrc/one/ -Isrc/two/ -O1 src/two/two.c',
|
||||
'gcc -c -o two.o -MMD -MF two.mf -Isrc/one/ -Isrc/two/ -O2 src/two/two.c'
|
||||
]
|
||||
expect(File.exists?('one.o')).to be_truthy
|
||||
expect(File.exists?('two.o')).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context "CFile builder" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user