Merged revisions 2454-2525 via svnmerge from
[scons.git] / doc / user / help.in
1 <!--
2
3   __COPYRIGHT__
4
5   Permission is hereby granted, free of charge, to any person obtaining
6   a copy of this software and associated documentation files (the
7   "Software"), to deal in the Software without restriction, including
8   without limitation the rights to use, copy, modify, merge, publish,
9   distribute, sublicense, and/or sell copies of the Software, and to
10   permit persons to whom the Software is furnished to do so, subject to
11   the following conditions:
12
13   The above copyright notice and this permission notice shall be included
14   in all copies or substantial portions of the Software.
15
16   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17   KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18   WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 -->
25
26    <para>
27
28    It's often very useful to be able to give
29    users some help that describes the
30    specific targets, build options, etc.,
31    that can be used for your build.
32    &SCons; provides the &Help; function
33    to allow you to specify this help text:
34
35    </para>
36
37    <scons_example name="ex1">
38       <file name="SConstruct" printme="1">
39       Help("""
40       Type: 'scons program' to build the production program,
41             'scons debug' to build the debug version.
42       """)
43       </file>
44    </scons_example>
45
46    <para>
47
48    (Note the above use of the Python triple-quote syntax,
49    which comes in very handy for
50    specifying multi-line strings like help text.)
51
52    </para>
53
54    <para>
55
56    When the &SConstruct; or &SConscript; files
57    contain such a call to the &Help; function,
58    the specified help text will be displayed in response to
59    the &SCons; <literal>-h</literal> option:
60
61    </para>
62
63    <scons_output example="ex1">
64       <scons_output_command>scons -h</scons_output_command>
65    </scons_output>
66
67    <para>
68
69    The &SConscript; files may contain
70    multiple calls to the &Help; function,
71    in which case the specified text(s)
72    will be concatenated when displayed.
73    This allows you to split up the
74    help text across multiple &SConscript; files.
75    In this situation, the order in
76    which the &SConscript; files are called
77    will determine the order in which the &Help; functions are called,
78    which will determine the order in which
79    the various bits of text will get concatenated.
80
81    </para>
82
83    <para>
84
85    Another use would be to make the help text conditional
86    on some variable.
87    For example, suppose you only want to display
88    a line about building a Windows-only
89    version of a program when actually
90    run on Windows.
91    The following &SConstruct; file:
92
93    </para>
94
95    <scons_example name="ex2">
96       <file name="SConstruct" printme="1">
97       env = Environment()
98
99       Help("\nType: 'scons program' to build the production program.\n")
100
101       if env['PLATFORM'] == 'win32':
102           Help("\nType: 'scons windebug' to build the Windows debug version.\n")
103       </file>
104    </scons_example>
105
106    <para>
107
108    Will display the complete help text on Windows:
109
110    </para>
111
112    <scons_output example="ex2" os="win32">
113       <scons_output_command>scons -h</scons_output_command>
114    </scons_output>
115
116    <para>
117
118    But only show the relevant option on a Linux or UNIX system:
119
120    </para>
121
122    <scons_output example="ex2" os="posix">
123       <scons_output_command>scons -h</scons_output_command>
124    </scons_output>
125
126    <para>
127
128    If there is no &Help; text in the &SConstruct; or
129    &SConscript; files,
130    &SCons; will revert to displaying its
131    standard list that describes the &SCons; command-line
132    options.
133    This list is also always displayed whenever
134    the <literal>-H</literal> option is used.
135
136    </para>