Skip to content

Commit 0039ff1

Browse files
committed
Merge branch 'stable'
2 parents d663339 + b2844cf commit 0039ff1

13 files changed

+744
-632
lines changed

doc/GUIDE.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,17 +1343,20 @@ stack exec ghci
13431343
~~~
13441344

13451345
But that won't load up locally written modules for access. For that, use the
1346-
`stack ghci` command or its synonym `stack repl`. To then load modules from your
1347-
project, use the `:m` command (for "module") followed by the module name.
1346+
`stack ghci` or `stack repl` commands, which are equivalent. To then load
1347+
modules from your project in GHCi, use the `:module` command (`:m` for short)
1348+
followed by the module name.
13481349

13491350
!!! note
13501351

1351-
If you have added upstream packages to your project please make sure to mark
1352-
them as *dependency package*s for faster and reliable usage of `stack ghci`.
1353-
Otherwise GHCi may have trouble due to conflicts of compilation flags or
1354-
having to unnecessarily interpret too many modules. See
1355-
[stack.yaml documentation](yaml_configuration.md#packages) to learn how to
1356-
mark a package as a *dependency package*.
1352+
If you have added packages to your project please make sure to mark them as
1353+
extra deps for faster and reliable usage of `stack ghci`. Otherwise GHCi may
1354+
have trouble due to conflicts of compilation flags or having to
1355+
unnecessarily interpret too many modules. See Stack's project-level
1356+
[configuration](yaml_configuration.md#extra-deps) to learn how to
1357+
configure a package as an extra-dep.
1358+
1359+
For further information, see the [REPL environment](ghci.md) documentation.
13571360

13581361
## The `stack ghc` and `stack runghc` commands
13591362

doc/build_command.md

Lines changed: 141 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -125,62 +125,169 @@ about how these dependencies get specified.
125125
In addition to specifying targets, you can also control what gets built, or
126126
retained, with the following flags:
127127

128-
* `--haddock`, to build documentation. This may cause a lot of packages to get
129-
re-built, so that the documentation links work.
128+
### The `stack build --dependencies-only` flag
130129

131-
* `--force-dirty`, to force rebuild of packages even when it doesn't seem
132-
necessary based on file dirtiness.
130+
Pass the flag to skip building the targets. The flag `--only-dependencies` has
131+
the same effect.
133132

134-
* `--reconfigure`, to force reconfiguration even when it doesn't seem necessary
135-
based on file dirtiness. This is sometimes useful with custom `Setup.hs`
136-
files, in particular when they depend on external data files.
133+
### The `stack build --[no-]dry-run` flag
137134

138-
* `--dry-run`, to build nothing and output information about the build plan.
135+
Default: Disabled
139136

140-
* `--only-dependencies`, to skip building the targets.
137+
Set the flag to build nothing and output information about the build plan.
141138

142-
* `--only-snapshot`, to only build snapshot dependencies, which are cached and
143-
shared with other projects.
139+
### The `stack build --flag` option
144140

145-
* `--keep-going`, to continue building packages even after some build step
146-
fails. The packages which depend upon the failed build won't get built.
141+
`stack build --flag <package_name>:[-]<flag_name>` sets (or unsets) the
142+
specified Cabal flag for the specified package.
147143

148-
* `--keep-tmp-files`, to keep intermediate files and build directories that
149-
would otherwise be considered temporary and deleted. It may be useful to
150-
inspect these, if a build fails. By default, they are not kept.
144+
This option can be specified multiple times to set (or unset) multiple Cabal
145+
flags.
151146

152-
* `--skip`, to skip building components of a local package. It allows
153-
you to skip test suites and benchmark without specifying other components
154-
(e.g. `stack test --skip long-test-suite` will run the tests without the
155-
`long-test-suite` test suite). Be aware that skipping executables won't work
156-
the first time the package is built due to
157-
[an issue in cabal](https://github.com/commercialhaskell/stack/issues/3229).
158-
This option can be specified multiple times to skip multiple components.
147+
The same Cabal flag name can be set (or unset) for multiple packages (at the
148+
command line only) with:
159149

160-
## Flags
150+
~~~text
151+
stack build --flag *:[-]<flag)name>
152+
~~~
153+
154+
!!! note
155+
156+
Currently you needs to list all of your modules that interpret flags in the
157+
`other-modules` section of a Cabal file. Cabal (the tool) has a different
158+
behavior currently and doesn't require that the modules be listed. This may
159+
change in a future release.
160+
161+
### The `stack build --[no-]force-dirty` flag
162+
163+
Default: Disabled
164+
165+
Set the flag to force rebuild of packages even when it doesn't seem necessary
166+
based on file dirtiness.
167+
168+
### The `stack build --[no-]haddock` flag
169+
170+
Default: Disabled
171+
172+
Set the flag to build Haddock documentation. This may cause a lot of packages to
173+
get re-built, so that the documentation links work.
174+
175+
### The `stack build --[no-]keep-going` flag
176+
177+
Default (`stack build`): Disabled
178+
179+
Default (`stack test` or `stack bench`): Enabled
180+
181+
Set the flag to continue building packages even after some build step fails.
182+
The packages which depend upon the failed build won't get built.
183+
184+
### The `stack build --[no-]keep-tmp-files` flag
185+
186+
Default: Disabled
187+
188+
Set the flag to keep intermediate files and build directories that would
189+
otherwise be considered temporary and deleted. It may be useful to inspect
190+
these, if a build fails. By default, they are not kept.
191+
192+
### The `stack build --only-dependencies` flag
193+
194+
Pass the flag to skip building the targets. The flag `--dependencies-only` has
195+
the same effect.
196+
197+
### The `stack build --[no-]reconfigure` flag
198+
199+
Default: Disabled
200+
201+
Set the flag to force reconfiguration even when it doesn't seem necessary based
202+
on file dirtiness. This is sometimes useful with custom `Setup.hs` files, in
203+
particular when they depend on external data files.
204+
205+
### The `stack build --skip` option
206+
207+
`stack build --skip <component>` skips building the specified components of a
208+
local package. It allows you to skip test suites and benchmark without
209+
specifying other components (e.g. `stack test --skip long-test-suite` will run
210+
the tests without the `long-test-suite` test suite). Be aware that skipping
211+
executables won't work the first time the package is built due to an issue in
212+
[Cabal](https://github.com/commercialhaskell/stack/issues/3229).
213+
214+
This option can be specified multiple times to skip multiple components.
215+
216+
### The `stack build --only-snapshot` flag
217+
218+
Pass the flag to build only snapshot dependencies, which are cached and shared
219+
with other projects.
220+
221+
## Other flags and options
161222

162223
There are a number of other flags accepted by `stack build`. Instead of listing
163224
all of them, please use `stack build --help`. Some particularly convenient ones
164225
worth mentioning here since they compose well with the rest of the build system
165226
as described:
166227

167-
* `--file-watch` will rebuild your project every time a file changes, by default
168-
it will take into account all files belonging to the targets you specify,
169-
alternatively one could specify `--watch-all` which will make Stack watch
170-
any local files (from project packages or from local dependencies)
171-
* `--exec "cmd [args]"` will run a command after a successful build
228+
### The `stack build --coverage` flag
172229

173-
To come back to the composable approach described above, consider this final
174-
example (which uses the [wai repository](https://github.com/yesodweb/wai/)). The
230+
Pass the flag to generate a code coverage report. For further information, see
231+
the [code coverage](coverage.md) documentation.
232+
233+
### The `stack build --exec` option
234+
235+
`stack build --exec "<command> [<arguments>]"` will run a command after a
236+
successful build.
237+
238+
### The `stack build --file-watch` flag
239+
240+
Pass the flag to rebuild your project every time a file changes. By default it
241+
will take into account all files belonging to the targets you specify. See also
242+
the `--watch-all` flag.
243+
244+
### The `stack build --[no-]interleaved-output` flag
245+
246+
[:octicons-tag-24: 2.1.1](https://github.com/commercialhaskell/stack/releases/tag/v2.1.1)
247+
248+
Default: Enabled
249+
250+
Set the flag to have the output of all packages being built scroll by in a
251+
streaming fashion. The output from each package built will be prefixed by the
252+
package name, e.g. `mtl> Building ...`. This will include the output from
253+
dependencies being built, not just targets.
254+
255+
Unset the flag to disable this behaviour. When disabled:
256+
257+
* When building a single target package (e.g., `stack build` in a project
258+
with only one package, or `stack build <package_name>` in a multi-package
259+
project), the build output from GHC will be hidden for building all
260+
dependencies, and will be displayed for the one target package.
261+
* By default, when building multiple target packages, the output from these
262+
will end up in a log file instead of on the console unless it contains
263+
errors or warnings, to avoid problems of interleaved output and decrease
264+
console noise. If you would like to see this content instead, you can use
265+
the `dump-logs` option.
266+
267+
### The `stack build --pedantic` flag
268+
269+
Pass the flag to build your project with the GHC options `-Wall` and `-Werror`.
270+
`-Wall` turns on all warning options that indicate potentially suspicious code.
271+
`-Werror` makes any warning into a fatal error.
272+
273+
### The `stack build --watch-all` flag
274+
275+
Pass the flag to rebuild your project every time any local file changes (from
276+
project packages or from local dependencies). See also the `--file-watch` flag.
277+
278+
## Composition
279+
280+
To come back to the composable approach described above, consider this example
281+
(which uses the `wai` [repository](https://github.com/yesodweb/wai/)). The
175282
command:
176283

177284
~~~text
178285
stack build --file-watch --test --copy-bins --haddock wai-extra :warp warp:doctest --exec 'echo Yay, it worked!'
179286
~~~
180287

181-
This command will start Stack up in file watch mode, waiting for files in your
182-
project to change. When first starting, and each time a file changes, it will do
183-
all of the following.
288+
will start Stack up in file watch mode, waiting for files in your project to
289+
change. When first starting, and each time a file changes, it will do all of the
290+
following.
184291

185292
* Build the wai-extra package and its test suites
186293
* Build the `warp` executable
@@ -191,25 +298,3 @@ all of the following.
191298
* If all of that succeeds:
192299
* Copy generated executables to the local bin path
193300
* Run the command `echo Yay, it worked!`
194-
195-
## Build output
196-
197-
Starting with Stack 2.1, output of all packages being built scrolls by in a
198-
streaming fashion. The output from each package built will be prefixed by the
199-
package name, e.g. `mtl> Building ...`. This will include the output from
200-
dependencies being built, not just targets.
201-
202-
To disable this behaviour, you can pass `--no-interleaved-output`, or add
203-
`interleaved-output: false` to your `stack.yaml` file. When disabled:
204-
205-
* When building a single target package (e.g., `stack build` in a project
206-
with only one package, or `stack build package-name` in a multi-package
207-
project), the build output from GHC will be hidden for building all
208-
dependencies, and will be displayed for the one target package.
209-
210-
* By default, when building multiple target packages, the output from these
211-
will end up in a log file instead of on the console unless it contains
212-
errors or warnings, to avoid problems of interleaved output and decrease
213-
console noise. If you would like to see this content instead, you can use
214-
the `--dump-logs` command line option, or add `dump-logs: all` to your
215-
YAML configuration file (`stack.yaml` or `config.yaml`).

doc/build_overview.md

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<div class="hidden-warning"><a href="https://docs.haskellstack.org/"><img src="https://rawgit.com/commercialhaskell/stack/master/doc/img/hidden-warning.svg"></a></div>
22

3-
# Build Overview
3+
# Build overview
44

5-
__NOTE__ This document should *not be considered accurate* until this
6-
note is removed.
5+
!!! warning
76

8-
This is a work-in-progress document covering the build process used by Stack.
9-
It was started following the Pantry rewrite work in Stack (likely to
10-
land as Stack 2.0), and contains some significant changes/simplifications from
11-
how things used to work. This document will likely not fully be reflected in
12-
the behavior of Stack itself until late in the Stack 2.0 development cycle.
7+
This document should not be considered accurate until this warning is
8+
removed.
9+
10+
This is a work-in-progress document covering the build process used by
11+
Stack. It was started following the Pantry rewrite work in Stack 2.1.1, and
12+
contains some significant changes/simplifications from how things used to
13+
work. This document will likely not fully be reflected in the behavior of
14+
Stack itself until late in the Stack 2.0 development cycle.
1315

1416
## Terminology
1517

@@ -65,7 +67,8 @@ This file is parsed to provide the following config values:
6567
* `ghc-options` (optional field, defaults to `{}`)
6668

6769
`flags` and `ghc-options` break down into both _by name_ (applied to a
68-
specific package) and _general_ (general option `*` for flags is only available in CLI).
70+
specific package) and _general_ (general option `*` for flags is only available
71+
in CLI).
6972

7073
## Wanted compiler, dependencies, and project packages
7174

@@ -95,9 +98,12 @@ specific package) and _general_ (general option `*` for flags is only available
9598
in the corresponding package cabal file, it's an error.
9699
* We are now left with the following:
97100
* A wanted compiler version
98-
* A map from package name to immutable packages with package config (flags, GHC options, hidden)
99-
* A map from package name to mutable packages as dependencies with package config
100-
* A map from package name to mutable packages as project packages with package config
101+
* A map from package name to immutable packages with package config (flags,
102+
GHC options, hidden)
103+
* A map from package name to mutable packages as dependencies with package
104+
config
105+
* A map from package name to mutable packages as project packages with
106+
package config
101107

102108
## Get actual compiler
103109

@@ -202,8 +208,10 @@ a hash of the following information:
202208
Motivation: Any package built from the immutable dependency map and
203209
installed in this database will never need to be rebuilt.
204210

205-
*FIXME* Caveat: do we need to take profiling settings into account
206-
here? How about Haddock status?
211+
!!! bug "To do"
212+
213+
Caveat: do we need to take profiling settings into account here? How about
214+
Haddock status?
207215

208216
## Determine actual target components
209217

@@ -233,10 +241,12 @@ We now have a set of tasks of packages/components to build, with full
233241
config information for each package, and dependencies that must be
234242
built first.
235243

236-
*FIXME* There's some logic to deal with cyclic dependencies between
237-
test suites and benchmarks, where a task can be broken up into
238-
individual components versus be kept as a single task. Need to
239-
document this better. Currently it's the "all in one" logic.
244+
!!! bug "To do"
245+
246+
There's some logic to deal with cyclic dependencies between test suites and
247+
benchmarks, where a task can be broken up into individual components versus
248+
be kept as a single task. Need to document this better. Currently it's the
249+
"all in one" logic.
240250

241251
## Unregister local modified packages
242252

0 commit comments

Comments
 (0)