Providing Help for Command-Line Build Options

To make command-line build options most useful, you ideally want to provide some help text that will describe the available options when the user runs scons -h. You could write this text by hand, but SCons provides an easier way. Options objects support a GenerateHelpText method that will, as its name indicates, generate text that describes the various options that have been added to it. You then pass the output from this method to the Help function:

         opts = Options('custom.py')
         opts.Add('RELEASE', 'Set to 1 to build for release', 0)
         env = Environment(options = opts)
         Help(opts.GenerateHelpText(env))
    

SCons will now display some useful text when the -h option is used:

      % scons -Q -h
      
      RELEASE: Set to 1 to build for release
          default: 0
          actual: 0
      
      Use scons -H for help about command-line options.
    

Notice that the help output shows the default value, and the current actual value of the build option.