4.2.6 Build HooksA build hook is a Ruby block that is called whenever Rscons is about to invoke a builder to produce a build target. Rscons also supports post-build hooks which are called after the builder has produced the build target. A build hook can be used to modify construction variables depending on the build target or source file names. Example: build do Environment.new do |env| env["CFLAGS"] << "-Wall" env.add_build_hook do |builder| # Compile sources from under src/tests without the -Wall flag. if builder.sources.first =~ %r{src/tests/} builder.vars["CFLAGS"] -= %w[-Wall] end end env.Program("program.exe", glob("src/**/*.c")) end end This example script would compile all C sources under the A post-build hook can be added with Build hooks and post-build hooks can register new build targets.
|