You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/build_command.md
+34-30Lines changed: 34 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,13 @@
4
4
5
5
## Overview
6
6
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`
8
8
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.
12
14
13
15
## Synonyms
14
16
@@ -24,17 +26,17 @@ synonyms in the `--help` output. These commands are:
24
26
*`stack install` is the same as `stack build --copy-bins`
25
27
26
28
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).
31
33
32
34
## Components
33
35
34
36
Components are a subtle yet important point to how build operates under the
35
37
surface. Every cabal package is made up of one or more components. It can have
36
38
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.
38
40
`stack build mypackage:test:mytests` will build the `mytests` component of the
39
41
`mypackage` package. `mytests` must be a test suite component.
40
42
@@ -46,21 +48,21 @@ the previous command will in fact build the `mytests` test suite *and* run it,
46
48
even though you haven't used the `stack test` command or the `--test` option.
47
49
(We'll get to what exactly `--test` does below.)
48
50
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
50
52
can run a single test component from a package, run a test component from one
51
53
package and a benchmark from another package, etc.
52
54
53
55
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
55
57
library (if present) and all executables, and ignore test suites and
56
58
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`).
58
60
59
61
## Target syntax
60
62
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:
64
66
65
67
**package*, e.g. `stack build foobar`, is the most commonly used target. It
66
68
will try to find the package in the following locations: local packages,
@@ -80,15 +82,18 @@ of different syntaxes supported for this list:
80
82
except instead of using the latest version from the index, the version
81
83
specified is used.
82
84
83
-
**component*. Instead of referring to an entire package and letting stack
85
+
**component*. Instead of referring to an entire package and letting Stack
84
86
decide which components to build, you select individual components from
85
87
inside a package. This can be done for more fine-grained control over which
86
88
test suites to run, or to have a faster compilation cycle. There are
87
89
multiple ways to refer to a specific component (provided for convenience):
88
90
89
91
*`packagename:comptype:compname` is the most explicit. The available
90
92
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
0 commit comments