4.4.1 Variant Groups

Variants may be grouped, which allows the build script author to define multiple combinations of desired variations to build with. For example:

variant_group "desktop-environment" do
  variant "kde"
  variant "gnome"
end

variant_group "debug" do
  variant "debug"
  variant "release"
end

with_variants do
  env "prog" do |env|
    if variant("kde")
      env["CPPDEFINES"] << "KDE"
    end
    if variant("gnome")
      env["CPPDEFINES"] << "GNOME"
    end
    if variant("debug")
      env["CPPDEFINES"] << "DEBUG"
    end
    if variant("release")
      env["CPPDEFINES"] << "NDEBUG"
    end
    env.Program("^/prog.exe", "prog.c")
  end
end

This build script executes the block given to with_variants four times and results in four Environments being created:

The command ./rscons -e-debug would build just "prog-kde-release" and "prog-gnome-release". The command ./rscons --variants kde,release would build just "prog-kde-release".