4.2.1 Environments

An Environment includes:

  • a collection of construction variables
  • a collection of build hooks
  • a collection of user-registered build targets
  • a build root

All build targets must be registered within an Environment. The Environment's build root is a directory created within the top-level Rscons build directory. By default it holds all intermediate files generated by Rscons that are needed to produce a user-specified build target. For example, for the Rsconscript:

build do
  Environment.new do |env|
    env.Program("myprog.exe", glob("src/**/*.c"))
  end
end

Rscons will place an object file and dependency file corresponding to each C source file under the Environment's build root. This keeps the intermediate generated build artifacts separate from the source files.