ed2b5ded1f13104e11a07348a8416e059c527152
[scons.git] / doc / user / help.xml
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    <programlisting>
38       Help("""
39       Type: 'scons program' to build the production program,
40             'scons debug' to build the debug version.
41       """)
42    </programlisting>
43
44    <para>
45
46    (Note the above use of the Python triple-quote syntax,
47    which comes in very handy for
48    specifying multi-line strings like help text.)
49
50    </para>
51
52    <para>
53
54    When the &SConstruct; or &SConscript; files
55    contain such a call to the &Help; function,
56    the specified help text will be displayed in response to
57    the &SCons; <literal>-h</literal> option:
58
59    </para>
60
61    <screen>
62       % <userinput>scons -h</userinput>
63       scons: Reading SConscript files ...
64       scons: done reading SConscript files.
65       
66       Type: 'scons program' to build the production program,
67             'scons debug' to build the debug version.
68       
69       Use scons -H for help about command-line options.
70    </screen>
71
72    <para>
73
74    The &SConscript; files may contain
75    multiple calls to the &Help; function,
76    in which case the specified text(s)
77    will be concatenated when displayed.
78    This allows you to split up the
79    help text across multiple &SConscript; files.
80    In this situation, the order in
81    which the &SConscript; files are called
82    will determine the order in which the &Help; functions are called,
83    which will determine the order in which
84    the various bits of text will get concatenated.
85
86    </para>
87
88    <para>
89
90    Another use would be to make the help text conditional
91    on some variable.
92    For example, suppose you only want to display
93    a line about building a Windows-only
94    version of a program when actually
95    run on Windows.
96    The following &SConstruct; file:
97
98    </para>
99
100    <programlisting>
101       env = Environment()
102
103       Help("\nType: 'scons program' to build the production program.\n")
104
105       if env['PLATFORM'] == 'win32':
106           Help("\nType: 'scons windebug' to build the Windows debug version.\n")
107    </programlisting>
108
109    <para>
110
111    Will display the complete help text on Windows:
112
113    </para>
114
115    <screen>
116       C:\><userinput>scons -h</userinput>
117       scons: Reading SConscript files ...
118       scons: done reading SConscript files.
119       
120       Type: 'scons program' to build the production program.
121       
122       Type: 'scons windebug' to build the Windows debug version.
123       
124       Use scons -H for help about command-line options.
125    </screen>
126
127    <para>
128
129    But only show the relevant option on a Linux or UNIX system:
130
131    </para>
132
133    <screen>
134       % <userinput>scons -h</userinput>
135       scons: Reading SConscript files ...
136       scons: done reading SConscript files.
137       
138       Type: 'scons program' to build the production program.
139       
140       Use scons -H for help about command-line options.
141    </screen>
142
143    <para>
144
145    If there is no &Help; text in the &SConstruct; or
146    &SConscript; files,
147    &SCons; will revert to displaying its
148    standard list that describes the &SCons; command-line
149    options.
150    This list is also always displayed whenever
151    the <literal>-H</literal> option is used.
152
153    </para>