Eliminate / replace remaining cPickle references in test scripts.
[scons.git] / doc / user / run.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 <!--
27
28 =head1 Invoking Cons
29
30 The C<cons> command is usually invoked from the root of the build tree. A
31 F<Construct> file must exist in that directory. If the C<-f> argument is
32 used, then an alternate F<Construct> file may be used (and, possibly, an
33 alternate root, since C<cons> will cd to F<Construct> file's containing
34 directory).
35
36 If C<cons> is invoked from a child of the root of the build tree with
37 the C<-t> argument, it will walk up the directory hierarchy looking for a
38 F<Construct> file.  (An alternate name may still be specified with C<-f>.)
39 The targets supplied on the command line will be modified to be relative
40 to the discovered F<Construct> file.  For example, from a directory
41 containing a top-level F<Construct> file, the following invocation:
42
43   % cd libfoo/subdir
44   % cons -t target
45
46 is exactly equivalent to:
47
48   % cons libfoo/subdir/target
49
50 If there are any C<Default> targets specified in the directory hierarchy's
51 F<Construct> or F<Conscript> files, only the default targets at or below
52 the directory from which C<cons -t> was invoked will be built.
53
54 The command is invoked as follows:
55
56   cons <arguments> ,  <construct-args>
57
58 where I<arguments> can be any of the following, in any order:
59
60 =over 10
61
62 =item I<target>
63
64 Build the specified target. If I<target> is a directory, then recursively
65 build everything within that directory.
66
67 =item I<+pattern>
68
69 Limit the F<Conscript> files considered to just those that match I<pattern>,
70 which is a Perl regular expression. Multiple C<+> arguments are accepted.
71
72 =item I<name>=<val>
73
74 Sets I<name> to value I<val> in the C<ARG> hash passed to the top-level
75 F<Construct> file.
76
77 =item C<-cc>
78
79 Show command that would have been executed, when retrieving from cache. No
80 indication that the file has been retrieved is given; this is useful for
81 generating build logs that can be compared with real build logs.
82
83 =item C<-cd>
84
85 Disable all caching. Do not retrieve from cache nor flush to cache.
86
87 =item C<-cr>
88
89 Build dependencies in random order. This is useful when building multiple
90 similar trees with caching enabled.
91
92 =item C<-cs>
93
94 Synchronize existing build targets that are found to be up-to-date with
95 cache. This is useful if caching has been disabled with -cc or just recently
96 enabled with UseCache.
97
98 =item C<-d>
99
100 Enable dependency debugging.
101
102 =item C<-f> <file>
103
104 Use the specified file instead of F<Construct> (but first change to
105 containing directory of I<file>).
106
107 =item C<-h>
108
109 Show a help message local to the current build if one such is defined, and
110 exit.
111
112 =item C<-k>
113
114 Keep going as far as possible after errors.
115
116 =item C<-o> <file>
117
118 Read override file I<file>.
119
120 =item C<-p>
121
122 Show construction products in specified trees. No build is attempted.
123
124 =item C<-pa>
125
126 Show construction products and associated actions. No build is attempted.
127
128 =item C<-pw>
129
130 Show products and where they are defined. No build is attempted.
131
132 =item C<-q>
133
134 Make the build quiet.  Multiple C<-q> options may be specified.
135
136 A single C<-q> options suppress messages about Installing and Removing
137 targets.
138
139 Two C<-q> options suppress build command lines and target up-to-date
140 messages.
141
142 =item C<-r>
143
144 Remove construction products associated with <targets>. No build is
145 attempted.
146
147 =item C<-R> <repos>
148
149 Search for files in I<repos>.  Multiple B<-R> I<repos> directories are
150 searched in the order specified.
151
152 =item C<-S> <pkg>
153
154 Use the sig::<pkg> package to calculate.  Supported <pkg> values
155 include "md5" for MD5 signature calculation and "md5::debug" for debug
156 information about MD5 signature calculation.
157
158 If the specified package ends in <::debug>, signature debug information
159 will be printed to the file name specified in the C<CONS_SIG_DEBUG>
160 environment variable, or to standard output if the environment variable
161 is not set.
162
163 =item C<-t>
164
165 Traverse up the directory hierarchy looking for a F<Construct> file,
166 if none exists in the current directory.  Targets will be modified to
167 be relative to the F<Construct> file.
168
169 Internally, C<cons> will change its working directory to the directory
170 which contains the top-level F<Construct> file and report:
171
172   cons: Entering directory `top-level-directory'
173
174 This message indicates to an invoking editor (such as emacs) or build
175 environment that Cons will now report all file names relative to the
176 top-level directory.  This message can not be suppressed with the C<-q>
177 option.
178
179 =item C<-v>
180
181 Show C<cons> version and continue processing.
182
183 =item C<-V>
184
185 Show C<cons> version and exit.
186
187 =item C<-wf> <file>
188
189 Write all filenames considered into I<file>.
190
191 =item C<-x>
192
193 Show a help message similar to this one, and exit.
194
195 =back
196
197 And I<construct-args> can be any arguments that you wish to process in the
198 F<Construct> file. Note that there should be a B<-,-> separating the arguments
199 to cons and the arguments that you wish to process in the F<Construct> file.
200
201 Processing of I<construct-args> can be done by any standard package like
202 B<Getopt> or its variants, or any user defined package. B<cons> will pass in
203 the I<construct-args> as B<@ARGV> and will not attempt to interpret anything
204 after the B<-,->.
205
206   % cons -R /usr/local/repository -d os=solaris +driver -,- -c test -f DEBUG
207
208 would pass the following to cons
209
210   -R /usr/local/repository -d os=solaris +driver
211
212 and the following, to the top level F<Construct> file as B<@ARGV>
213
214   -c test -f DEBUG
215
216 Note that C<cons -r .> is equivalent to a full recursive C<make clean>,
217 but requires no support in the F<Construct> file or any F<Conscript>
218 files. This is most useful if you are compiling files into source
219 directories (if you separate the F<build> and F<export> directories,
220 then you can just remove the directories).
221
222 The options C<-p>, C<-pa>, and C<-pw> are extremely useful for use as an aid
223 in reading scripts or debugging them. If you want to know what script
224 installs F<export/include/foo.h>, for example, just type:
225
226   % cons -pw export/include/foo.h
227
228 =head1 Selective builds
229
230 Cons provides two methods for reducing the size of given build. The first is
231 by specifying targets on the command line, and the second is a method for
232 pruning the build tree. We'll consider target specification first.
233
234
235 =head2 Selective targeting
236
237 Like make, Cons allows the specification of ``targets'' on the command
238 line. Cons targets may be either files or directories. When a directory is
239 specified, this is simply a short-hand notation for every derivable
240 product-,-that Cons knows about-,-in the specified directory and below. For
241 example:
242
243   % cons build/hello/hello.o
244
245 means build F<hello.o> and everything that F<hello.o> might need. This is
246 from a previous version of the B<Hello, World!> program in which F<hello.o>
247 depended upon F<export/include/world.h>. If that file is not up-to-date
248 (because someone modified F<src/world/world.h)>, then it will be rebuilt,
249 even though it is in a directory remote from F<build/hello>.
250
251 In this example:
252
253   % cons build
254
255 Everything in the F<build> directory is built, if necessary. Again, this may
256 cause more files to be built. In particular, both F<export/include/world.h>
257 and F<export/lib/libworld.a> are required by the F<build/hello> directory,
258 and so they will be built if they are out-of-date.
259
260 If we do, instead:
261
262   % cons export
263
264 then only the files that should be installed in the export directory will be
265 rebuilt, if necessary, and then installed there. Note that C<cons build>
266 might build files that C<cons export> doesn't build, and vice-versa.
267
268
269 =head1 Build Pruning
270
271 In conjunction with target selection, B<build pruning> can be used to reduce
272 the scope of the build. In the previous peAcH and baNaNa example, we have
273 already seen how script-driven build pruning can be used to make only half
274 of the potential build available for any given invocation of C<cons>. Cons
275 also provides, as a convenience, a command line convention that allows you
276 to specify which F<Conscript> files actually get ``built''-,-that is,
277 incorporated into the build tree. For example:
278
279   % cons build +world
280
281 The C<+> argument introduces a Perl regular expression. This must, of
282 course, be quoted at the shell level if there are any shell meta-characters
283 within the expression. The expression is matched against each F<Conscript>
284 file which has been mentioned in a C<Build> statement, and only those
285 scripts with matching names are actually incorporated into the build
286 tree. Multiple such arguments are allowed, in which case a match against any
287 of them is sufficient to cause a script to be included.
288
289 In the example, above, the F<hello> program will not be built, since Cons
290 will have no knowledge of the script F<hello/Conscript>. The F<libworld.a>
291 archive will be built, however, if need be.
292
293 There are a couple of uses for build pruning via the command line. Perhaps
294 the most useful is the ability to make local changes, and then, with
295 sufficient knowledge of the consequences of those changes, restrict the size
296 of the build tree in order to speed up the rebuild time. A second use for
297 build pruning is to actively prevent the recompilation of certain files that
298 you know will recompile due to, for example, a modified header file. You may
299 know that either the changes to the header file are immaterial, or that the
300 changes may be safely ignored for most of the tree, for testing
301 purposes.With Cons, the view is that it is pragmatic to admit this type of
302 behavior, with the understanding that on the next full build everything that
303 needs to be rebuilt will be. There is no equivalent to a ``make touch''
304 command, to mark files as permanently up-to-date. So any risk that is
305 incurred by build pruning is mitigated. For release quality work, obviously,
306 we recommend that you do not use build pruning (it's perfectly OK to use
307 during integration, however, for checking compilation, etc. Just be sure to
308 do an unconstrained build before committing the integration).
309
310 -->
311
312   <para>
313
314     XXX
315
316   </para>
317
318   <section>
319   <title>Command-Line Options</title>
320
321     <para>
322
323     XXX
324
325     </para>
326
327   </section>
328
329   <section>
330   <title>Getting at Command-Line Arguments</title>
331
332     <para>
333
334     XXX
335
336     </para>
337
338   </section>
339
340   <section>
341   <title>Selective Builds</title>
342
343     <para>
344
345     XXX
346
347     </para>
348
349   </section>
350
351   <!--
352
353   <section>
354   <title>Build Pruning</title>
355
356     <para>
357
358     XXX
359
360     </para>
361
362   </section>
363
364   -->
365
366   <section>
367   <title>Overriding Construction Variables</title>
368
369     <para>
370
371     XXX
372
373     </para>
374
375   </section>