Pre-build hooks do not respect modified key values for old-style builders

This commit is contained in:
Michael Metivier committed 2017-06-09 19:50:12 -04:00
1 parent f1b24ee8ba
commit 387c40176b
3 files changed
+35 -1

No files matched your search

@@ -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