@@ -143,23 +143,23 @@ about how these dependencies get specified.
143
143
In addition to specifying targets, you can also control what gets built, or
144
144
retained, with the following flags:
145
145
146
- ### The ` stack build --bench` flag
146
+ ### ` --bench ` flag
147
147
148
148
Pass the flag to add benchmark components to the targets, if specific components
149
149
are not identified. The ` stack bench ` synonym sets this flag.
150
150
151
- ### The ` stack build --dependencies-only` flag
151
+ ### ` --dependencies-only ` flag
152
152
153
153
Pass the flag to skip building the targets. The flag ` --only-dependencies ` has
154
154
the same effect.
155
155
156
- ### The ` stack build --[no-]dry-run` flag
156
+ ### ` --[no-]dry-run ` flag
157
157
158
158
Default: Disabled
159
159
160
160
Set the flag to build nothing and output information about the build plan.
161
161
162
- ### The ` stack build --flag` option
162
+ ### ` --flag ` option
163
163
164
164
` stack build --flag <package_name>:[-]<flag_name> ` sets (or unsets) the
165
165
specified Cabal flag for the specified package.
@@ -181,45 +181,45 @@ stack build --flag *:[-]<flag)name>
181
181
behavior currently and doesn't require that the modules be listed. This may
182
182
change in a future release.
183
183
184
- ### The ` stack build --[no-]force-dirty` flag
184
+ ### ` --[no-]force-dirty ` flag
185
185
186
186
Default: Disabled
187
187
188
188
Set the flag to force rebuild of packages even when it doesn't seem necessary
189
189
based on file dirtiness.
190
190
191
- ### The ` stack build --[no-]haddock` flag
191
+ ### ` --[no-]haddock ` flag
192
192
193
193
Default: Disabled
194
194
195
195
Set the flag to build Haddock documentation. This may cause a lot of packages to
196
196
get re-built, so that the documentation links work. The ` stack haddock ` synonym
197
197
sets this flag.
198
198
199
- ### The ` stack build --haddock-arguments` option
199
+ ### ` --haddock-arguments ` option
200
200
201
201
` stack haddock --haddock-arguments <haddock_arguments> ` passes the specified
202
202
arguments to the Haddock tool.
203
203
204
- ### The ` stack build --[no-]haddock-deps` flag
204
+ ### ` --[no-]haddock-deps ` flag
205
205
206
206
Default: Enabled (if building Haddock documnentation)
207
207
208
208
Unset the flag to disable building Haddock documentation for dependencies.
209
209
210
- ### The ` stack build --[no-]haddock-hyperlink-source` flag
210
+ ### ` --[no-]haddock-hyperlink-source ` flag
211
211
212
212
Default: Enabled
213
213
214
214
Unset the flag to disable building building hyperlinked source for Haddock.
215
215
216
- ### The ` stack build --[no-]haddock-internal` flag
216
+ ### ` --[no-]haddock-internal ` flag
217
217
218
218
Default: Disabled
219
219
220
220
Set the flag to enable building Haddock documentation for internal modules.
221
221
222
- ### The ` stack build --[no-]keep-going` flag
222
+ ### ` --[no-]keep-going ` flag
223
223
224
224
Default (` stack build ` ): Disabled
225
225
@@ -228,15 +228,15 @@ Default (`stack test` or `stack bench`): Enabled
228
228
Set the flag to continue building packages even after some build step fails.
229
229
The packages which depend upon the failed build won't get built.
230
230
231
- ### The ` stack build --[no-]keep-tmp-files` flag
231
+ ### ` --[no-]keep-tmp-files ` flag
232
232
233
233
Default: Disabled
234
234
235
235
Set the flag to keep intermediate files and build directories that would
236
236
otherwise be considered temporary and deleted. It may be useful to inspect
237
237
these, if a build fails. By default, they are not kept.
238
238
239
- ### The ` stack build --only-configure` flag
239
+ ### ` --only-configure ` flag
240
240
241
241
[ :octicons-tag-24: 0.1.4.0] ( https://github.com/commercialhaskell/stack/releases/tag/v0.1.4.0 )
242
242
@@ -248,30 +248,30 @@ intended for tool usage. It may break when used on multiple packages at once.
248
248
If there are downstream actions that require a package to be built then a
249
249
full build will occur, even if the flag is passed.
250
250
251
- ### The ` stack build --only-dependencies` flag
251
+ ### ` --only-dependencies ` flag
252
252
253
253
Pass the flag to skip building the targets. The flag ` --dependencies-only ` has
254
254
the same effect.
255
255
256
- ### The ` stack build --only-locals` flag
256
+ ### ` --only-locals ` flag
257
257
258
258
Pass the flag to build only packages in the local database. Fails if the build
259
259
plan includes packages in the snapshot database.
260
260
261
- ### The ` stack build --only-snapshot` flag
261
+ ### ` --only-snapshot ` flag
262
262
263
263
Pass the flag to build only snapshot dependencies, which are cached and shared
264
264
with other projects.
265
265
266
- ### The ` stack build --[no-]reconfigure` flag
266
+ ### ` --[no-]reconfigure ` flag
267
267
268
268
Default: Disabled
269
269
270
270
Set the flag to force reconfiguration even when it doesn't seem necessary based
271
271
on file dirtiness. This is sometimes useful with custom ` Setup.hs ` files, in
272
272
particular when they depend on external data files.
273
273
274
- ### The ` stack build --skip` option
274
+ ### ` --skip ` option
275
275
276
276
` stack build --skip <component> ` skips building the specified components of a
277
277
local package. It allows you to skip test suites and benchmark without
@@ -282,61 +282,86 @@ executables won't work the first time the package is built due to an issue in
282
282
283
283
This option can be specified multiple times to skip multiple components.
284
284
285
- ### The ` stack build --test` flag
285
+ ### ` --test ` flag
286
286
287
287
Pass the flag to add test suite components to the targets, if specific
288
288
components are not identified. The ` stack test ` synonym sets this flag.
289
289
290
+ ## Controlling when building occurs
291
+
292
+ ### ` --file-watch ` flag
293
+
294
+ Pass the flag to rebuild your project every time a file changes. By default it
295
+ will take into account all files belonging to the targets you specify. See also
296
+ the ` --watch-all ` flag.
297
+
298
+ ### ` --file-watch-poll ` flag
299
+
300
+ Like the ` --file-watch ` flag, but based on polling the file system instead of
301
+ using events to determine if a file has changed.
302
+
303
+ ### ` --watch-all ` flag
304
+
305
+ Pass the flag to rebuild your project every time any local file changes (from
306
+ project packages or from local dependencies). See also the ` --file-watch ` flag.
307
+
308
+ ## Controlling what happens after building
309
+
310
+ ### ` --exec ` option
311
+
312
+ ` stack build --exec "<command> [<arguments>]" ` will run the specified command
313
+ after a successful build.
314
+
290
315
## Flags affecting GHC's behaviour
291
316
292
- ### The ` stack build --[no-]executable-profiling` flag
317
+ ### ` --[no-]executable-profiling ` flag
293
318
294
319
Default: Disabled
295
320
296
321
Set the flag to enable executable profiling for TARGETs and all its
297
322
dependencies.
298
323
299
- ### The ` stack build --[no-]executable-stripping` flag
324
+ ### ` --[no-]executable-stripping ` flag
300
325
301
326
Default: Enabled
302
327
303
328
Unset the flag to disable executable stripping for TARGETs and all its
304
329
dependencies.
305
330
306
- ### The ` stack build --fast` flag
331
+ ### ` --fast ` flag
307
332
308
333
Pass the flag to build your project with the GHC option ` -O0 ` . ` -O0 ` disables
309
334
GHC's optimisations (which is GHC's default).
310
335
311
- ### The ` stack build --ghc-options` option
336
+ ### ` --ghc-options ` option
312
337
313
338
` stack build ghc-options <ghc_options> ` passes the specified options to GHC.
314
339
315
- ### The ` stack build --[no-]library-profiling` flag
340
+ ### ` --[no-]library-profiling ` flag
316
341
317
342
Default: Disabled
318
343
319
344
Set the flag to enable library profiling for TARGETs and all its dependencies.
320
345
321
- ### The ` stack build --[no-]library-stripping` flag
346
+ ### ` --[no-]library-stripping ` flag
322
347
323
348
Default: Enabled
324
349
325
350
Unset the flag to disable library stripping for TARGETs and all its
326
351
dependencies.
327
352
328
- ### The ` stack build --pedantic` flag
353
+ ### ` --pedantic ` flag
329
354
330
355
Pass the flag to build your project with the GHC options ` -Wall ` and ` -Werror ` .
331
356
` -Wall ` turns on all warning options that indicate potentially suspicious code.
332
357
` -Werror ` makes any warning into a fatal error.
333
358
334
- ### The ` stack build --profile` flag
359
+ ### ` --profile ` flag
335
360
336
361
Pass the flag to enable profiling in libraries, executables, etc. for all
337
362
expressions, and generate a profiling report in tests or benchmarks.
338
363
339
- ### The ` stack build --[no-]split-objs` flag
364
+ ### ` --[no-]split-objs ` flag
340
365
341
366
Default: Disabled
342
367
@@ -350,54 +375,54 @@ size (at the cost of build time).
350
375
dependencies with split-objs, you will need to delete the snapshot (and all
351
376
snapshots that could reference that snapshot).
352
377
353
- ### The ` stack build --no-strip` flag
378
+ ### ` --no-strip ` flag
354
379
355
380
Pass the flag to disable DWARF debugging symbol stripping in libraries,
356
381
executables, etc. for all expressions, producing larger executables but allowing
357
382
the use of standard debuggers/profiling tools/other utilities that use debugging
358
383
symbols.
359
384
360
- ### The ` stack build --trace` flag
385
+ ### ` --trace ` flag
361
386
362
387
Pass the flag to enable profiling in libraries, executables, etc. for all
363
388
expressions, and generate a backtrace on exception.
364
389
365
390
## Flags relating to build outputs
366
391
367
- ### The ` stack build --[no]-cabal-verbose` flag
392
+ ### ` --[no]-cabal-verbose ` flag
368
393
369
394
Default: Disabled
370
395
371
396
Set the flag to enable verbose output from Cabal (the library). This flag is an
372
397
alternative to the ` --cabal-verbosity ` option.
373
398
374
- ### The ` stack build --[no]-cabal-verbosity` option
399
+ ### ` --[no]-cabal-verbosity ` option
375
400
376
401
` stack build --cabal-verbosity <verbosity_level> ` sets the specified verbosity
377
402
level for output from Cabal (the library). It accepts Cabal's numerical and
378
403
extended syntax. This option is an alternative to setting the ` --cabal-verbose `
379
404
flag.
380
405
381
- ### The ` stack build --[no-]copy-bins` flag
406
+ ### ` --[no-]copy-bins ` flag
382
407
383
408
Default: Disabled
384
409
385
410
Set the flag to enable copying binaries to Stack's local binary directory (see
386
411
` stack path --local-bin ` ). The ` stack install ` synonym sets this flag.
387
412
388
- ### The ` stack build --[no-]copy-compiler-tool` flag
413
+ ### ` --[no-]copy-compiler-tool ` flag
389
414
390
415
Default: Disabled
391
416
392
417
Set the flag to enable copying binaries of targets to Stack's compiler tools
393
418
binary directory (see ` stack path --compiler-tools-bin ` ).
394
419
395
- ### The ` stack build --coverage` flag
420
+ ### ` --coverage ` flag
396
421
397
422
Pass the flag to generate a code coverage report. For further information, see
398
423
the [ code coverage] ( hpc_command.md ) documentation.
399
424
400
- ### The ` stack build --ddump-dir` option
425
+ ### ` --ddump-dir ` option
401
426
402
427
GHC has a number of ` ddump-* ` flags and options to allow dumping out of
403
428
intermediate structures produced by the compiler. They include the
@@ -414,7 +439,7 @@ For example:
414
439
stack build --ghc-options "-ddump-to-file -ddump-timings" --ddump-dir my-ddump-dir
415
440
~~~
416
441
417
- ### The ` stack build --[no-]interleaved-output` flag
442
+ ### ` --[no-]interleaved-output ` flag
418
443
419
444
[ :octicons-tag-24: 2.1.1] ( https://github.com/commercialhaskell/stack/releases/tag/v2.1.1 )
420
445
@@ -468,43 +493,22 @@ package is targetted in a multi-package project (for example, using
468
493
default ` dump-logs ` mode is to output the contents of the log files that are
469
494
warnings.
470
495
471
- ### The ` stack build --[no]-open` flag
496
+ ### ` --[no]-open ` flag
472
497
473
498
Default: Disabled
474
499
475
500
Set the flag to enable opening the local Haddock documentation in the browser.
476
501
477
502
## Other flags and options
478
503
479
- There are a number of other flags accepted by ` stack build ` . Instead of listing
480
- all of them, please use ` stack build --help ` . Some particularly convenient ones
481
- worth mentioning here since they compose well with the rest of the build system
482
- as described:
483
-
484
- ### The ` stack build --exec ` option
485
-
486
- ` stack build --exec "<command> [<arguments>]" ` will run a command after a
487
- successful build.
488
-
489
- ### The ` stack build --file-watch ` flag
490
-
491
- Pass the flag to rebuild your project every time a file changes. By default it
492
- will take into account all files belonging to the targets you specify. See also
493
- the ` --watch-all ` flag.
494
-
495
- ### The ` stack build --file-watch-poll ` flag
496
-
497
- Like the ` --file-watch ` flag, but based on polling the file system instead of
498
- using events to determine if a file has changed.
499
-
500
- ### The ` stack build --[no]-prefetch ` flag
504
+ ### ` --[no]-prefetch ` flag
501
505
502
506
Default: Disabled
503
507
504
508
Set the flag to enable fetching packages necessary for the build immediately.
505
509
This can be useful with ` stack build --dry-run ` .
506
510
507
- ### The ` stack build --tests-allow-stdin` flag
511
+ ### ` --tests-allow-stdin ` flag
508
512
509
513
[ :octicons-tag-24: 2.9.3] ( https://github.com/commercialhaskell/stack/releases/tag/v2.9.3 )
510
514
@@ -518,11 +522,6 @@ specification and allow the executable to receive input on that channel. If you
518
522
pass ` --no-tests-allow-stdin ` and the executable seeks input on the standard
519
523
input channel, an exception will be thown.
520
524
521
- ### The ` stack build --watch-all ` flag
522
-
523
- Pass the flag to rebuild your project every time any local file changes (from
524
- project packages or from local dependencies). See also the ` --file-watch ` flag.
525
-
526
525
## Examples
527
526
528
527
* ` stack build --test --copy-bins ` or, equivalently, ` stack test --copy-bins `
0 commit comments