test build hooks overwriting entire vars hash as a non-backwards-compatiblity test
This commit is contained in:
1 parent
7992450383
commit
a1f5f022d1
3 files changed
+29
-37
No files matched your search
@@ -1,25 +0,0 @@
|
||||
class MyObject < Rscons::Builder
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
build do
|
||||
Environment.new(echo: :command) do |env|
|
||||
env.add_builder(MyObject)
|
||||
env.append('CPPPATH' => Rscons.glob('src/**'))
|
||||
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
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
build do
|
||||
Environment.new(echo: :command) do |env|
|
||||
env.append('CPPPATH' => Rscons.glob('src/**'))
|
||||
env.add_build_hook do |build_op|
|
||||
if build_op[:builder].name == "Object" && build_op[:sources].first =~ %r{one\.c}
|
||||
build_op[:vars]["CFLAGS"] << "-O1"
|
||||
build_op[:sources] = ['src/two/two.c']
|
||||
elsif build_op[:builder].name == "Object" && build_op[:target] =~ %r{two\.o}
|
||||
new_vars = build_op[:vars].clone
|
||||
new_vars["CFLAGS"] << "-O2"
|
||||
build_op[:vars] = new_vars
|
||||
end
|
||||
end
|
||||
env.Object('one.o', 'src/one/one.c')
|
||||
env.Object('two.o', 'src/two/two.c')
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user