Skip to content

Commit 6ec9fab

Browse files
committed
Wire in the build command documentation
1 parent 84d3397 commit 6ec9fab

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

doc/GUIDE_advanced.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Some of Stack's features will not be needed regularly or by all users. This part
66
of the guide provides information about those features. Some of the features are
77
complex and separate pages are dedicated to them.
88

9+
## The `stack build` command
10+
11+
The `stack build` command is introduced in the first part of
12+
[Stack's user guide](GUIDE.md#the-stack-build-command). For further information
13+
about the command, see the [build command](build_command.md) documentation.
14+
915
## The `stack dot` command
1016

1117
If you'd like to get some insight into the dependency tree of your packages, you

doc/build_command.md

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
## Overview
66

7-
The primary command you use in stack is build. This page describes the build
7+
The primary command you use in Stack is `build`. This page describes the `build`
88
command's interface. The goal of the interface is to do the right thing for
9-
simple input, and allow a lot of flexibility for more complicated goals. See the
10-
[build command section of the user guide](GUIDE.md#the-build-command) for info
11-
beyond the CLI aspects of the build command.
9+
simple input, and allow a lot of flexibility for more complicated goals.
10+
11+
See the introductory part of
12+
[Stack's user guide](GUIDE.md#the-stack-build-command) for an introduction to
13+
the command.
1214

1315
## Synonyms
1416

@@ -24,17 +26,17 @@ synonyms in the `--help` output. These commands are:
2426
* `stack install` is the same as `stack build --copy-bins`
2527

2628
The advantage of the synonym commands is that they're convenient and short. The
27-
advantage of the options is that they compose. For example, `stack build --test --copy-bins`
28-
will build libraries, executables, and test suites, run the test
29-
suites, and then copy the executables to your local bin path (more on this
30-
below).
29+
advantage of the options is that they compose. For example,
30+
`stack build --test --copy-bins` will build libraries, executables, and test
31+
suites, run the test suites, and then copy the executables to your local bin
32+
path (more on this below).
3133

3234
## Components
3335

3436
Components are a subtle yet important point to how build operates under the
3537
surface. Every cabal package is made up of one or more components. It can have
3638
0 or 1 libraries, and then 0 or more of executable, test, and benchmark
37-
components. stack allows you to call out a specific component to be built, e.g.
39+
components. Stack allows you to call out a specific component to be built, e.g.
3840
`stack build mypackage:test:mytests` will build the `mytests` component of the
3941
`mypackage` package. `mytests` must be a test suite component.
4042

@@ -46,21 +48,21 @@ the previous command will in fact build the `mytests` test suite *and* run it,
4648
even though you haven't used the `stack test` command or the `--test` option.
4749
(We'll get to what exactly `--test` does below.)
4850

49-
This gives you a lot of flexibility in choosing what you want stack to do. You
51+
This gives you a lot of flexibility in choosing what you want Stack to do. You
5052
can run a single test component from a package, run a test component from one
5153
package and a benchmark from another package, etc.
5254

5355
One final note on components: you can only control components for local
54-
packages, not dependencies. With dependencies, stack will *always* build the
56+
packages, not dependencies. With dependencies, Stack will *always* build the
5557
library (if present) and all executables, and ignore test suites and
5658
benchmarks. If you want more control over a package, you must add it to your
57-
`packages` setting in your stack.yaml file.
59+
`packages` setting in your project-level configuration file (`stack.yaml`).
5860

5961
## Target syntax
6062

61-
In addition to a number of options (like the aforementioned `--test`), `stack build`
62-
takes a list of zero or more *targets* to be built. There are a number
63-
of different syntaxes supported for this list:
63+
In addition to a number of options (like the aforementioned `--test`),
64+
`stack build` takes a list of zero or more *targets* to be built. There are a
65+
number of different syntaxes supported for this list:
6466

6567
* *package*, e.g. `stack build foobar`, is the most commonly used target. It
6668
will try to find the package in the following locations: local packages,
@@ -80,15 +82,18 @@ of different syntaxes supported for this list:
8082
except instead of using the latest version from the index, the version
8183
specified is used.
8284

83-
* *component*. Instead of referring to an entire package and letting stack
85+
* *component*. Instead of referring to an entire package and letting Stack
8486
decide which components to build, you select individual components from
8587
inside a package. This can be done for more fine-grained control over which
8688
test suites to run, or to have a faster compilation cycle. There are
8789
multiple ways to refer to a specific component (provided for convenience):
8890

8991
* `packagename:comptype:compname` is the most explicit. The available
9092
comptypes are `exe`, `test`, and `bench`.
91-
* Side note: When any `exe` component is specified, all of the package's executable components will be built. This is due to limitations in all currently released versions of Cabal. See [issue#1046](https://github.com/commercialhaskell/stack/issues/1406)
93+
* Side note: When any `exe` component is specified, all of the package's
94+
executable components will be built. This is due to limitations in all
95+
currently released versions of Cabal. See
96+
[issue#1046](https://github.com/commercialhaskell/stack/issues/1406)
9297
* `packagename:compname` allows you to leave off the component type, as
9398
that will (almost?) always be redundant with the component name. For
9499
example, `stack build mypackage:mytestsuite`.
@@ -104,18 +109,18 @@ of different syntaxes supported for this list:
104109
will be treated as that. Explicitly starting your target with `./` can be a
105110
good way to avoid that, e.g. `stack build ./foo`
106111

107-
Finally: if you provide no targets (e.g., running `stack build`), stack will
112+
Finally: if you provide no targets (e.g., running `stack build`), Stack will
108113
implicitly pass in all of your local packages. If you only want to target
109-
packages in the current directory or deeper, you can pass in `.`, e.g. `stack build .`.
114+
packages in the current directory or deeper, you can pass in `.`, e.g.
115+
`stack build .`.
110116

111117
To get a list of the available targets in your project, use `stack ide targets`.
112118

113119
## Controlling what gets built
114120

115-
Stack will automatically build the necessary
116-
dependencies. See the
117-
[build command section of the user guide](GUIDE.md#the-build-command) for
118-
details of how these dependencies get specified.
121+
Stack will automatically build the necessary dependencies. See the introductory
122+
part of [Stack's user guide](GUIDE.md#the-stack-build-command) for information
123+
about how these dependencies get specified.
119124

120125
In addition to specifying targets, you can also control what gets built, or
121126
retained, with the following flags:
@@ -127,8 +132,8 @@ retained, with the following flags:
127132
necessary based on file dirtiness.
128133

129134
* `--reconfigure`, to force reconfiguration even when it doesn't seem necessary
130-
based on file dirtiness. This is sometimes useful with custom Setup.hs files,
131-
in particular when they depend on external data files.
135+
based on file dirtiness. This is sometimes useful with custom `Setup.hs`
136+
files, in particular when they depend on external data files.
132137

133138
* `--dry-run`, to build nothing and output information about the build plan.
134139

@@ -172,11 +177,10 @@ example (which uses the [wai repository](https://github.com/yesodweb/wai/)):
172177
stack build --file-watch --test --copy-bins --haddock wai-extra :warp warp:doctest --exec 'echo Yay, it worked!'
173178
```
174179

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

177-
* Start stack up in file watch mode, waiting for files in your project to
178-
change. When first starting, and each time a file changes, it will do all of
179-
the following.
180184
* Build the wai-extra package and its test suites
181185
* Build the `warp` executable
182186
* Build the warp package's doctest component (which, as you may guess, is a
@@ -207,4 +211,4 @@ To disable this behaviour, you can pass `--no-interleaved-output`, or add
207211
errors or warnings, to avoid problems of interleaved output and decrease
208212
console noise. If you would like to see this content instead, you can use
209213
the `--dump-logs` command line option, or add `dump-logs: all` to your
210-
`stack.yaml` file.
214+
YAML configuration file (`stack.yaml` or `config.yaml`).

0 commit comments

Comments
 (0)