4.3.1 Environments

An Environment includes:

All build targets must be registered within an Environment. If the user does not specify a name for the environment, a name will be automatically generated based on the Environment's internal ID, for example "e.1". The Environment's build root is a directory with the same name as the Environment, 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:

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

Rscons will place an object file and dependency file corresponding to each C source file under the Environment's build root. Assuming a top-level build directory of "build", the Environment's build root would be "build/myproj". This keeps the intermediate generated build artifacts separate from the source files. Source and target paths passed to a Builder (e.g. Program) can begin with "^/" to indicate that Rscons should expand those paths to be relative to the Environment's build root. If a source or target path passed to a Builder begins with "^^/", it is expanded to be relative to the Rscons top-level build directory (but outside the Environment's build root).