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: Cabal/doc/developing-packages.rst
+55-12Lines changed: 55 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -2168,21 +2168,54 @@ system-dependent values for these fields.
2168
2168
.. pkg-field:: build-tool-depends: package:executable list
2169
2169
:since: 2.0
2170
2170
2171
-
A list of Haskell programs needed to build this component.
2172
-
Each is specified by the package containing the executable and the name of the executable itself, separated by a colon, and optionally followed by a version bound.
2173
-
It is fine for the package to be the current one, in which case this is termed an *internal*, rather than *external* executable dependency.
2171
+
A list of Haskell executables needed to build this component. Executables are provided
2172
+
during the whole duration of the component, so this field can be used for executables
2173
+
needed during :pkg-section:`test-suite` as well.
2174
+
2175
+
Each is specified by the package containing the executable and the name of the
2176
+
executable itself, separated by a colon, and optionally followed by a version bound.
2177
+
2178
+
All executables defined in the given Cabal file are termed as *internal* dependencies
2179
+
as opposed to the rest which are *external* dependencies.
2180
+
2181
+
Each of the two is handled differently:
2182
+
2183
+
1. External dependencies can (and should) contain a version bound like conventional
2184
+
:pkg-field:`build-depends` dependencies.
2185
+
2. Internal depenedencies should not contain a version bound, as they will be always
2186
+
resolved within the same configuration of the package in the build plan.
2187
+
Specifically, version bounds that include the package's version will be warned for
2188
+
being extraneous, and version bounds that exclude the package's version will raise
2189
+
an error for being impossible to follow.
2190
+
2191
+
For example (1) using a test-suite to make sure README.md Haskell snippets are tested using
For example (2) using a test-suite to test executable behaviour in the same package:
2199
+
2200
+
::
2201
+
2202
+
build-tool-depends: mypackage:executable
2203
+
2204
+
Cabal tries to make sure that all specified programs are atomically built and prepended
2205
+
on the ``$PATH`` shell variable before building the component in question, but can only do
2206
+
so for Nix-style builds. Specifically:
2207
+
2208
+
a) For Nix-style local builds, both internal and external dependencies.
2209
+
b) For old-style builds, only for internal dependencies [#old-style-build-tool-depends]_.
2210
+
It's up to the user to provide needed executables in this case under `$PATH.`
2174
2211
2175
-
External dependencies can (and should) contain a version bound like conventional :pkg-field:`build-depends` dependencies.
2176
-
Internal deps should not contain a version bound, as they will be always resolved within the same configuration of the package in the build plan.
2177
-
Specifically, version bounds that include the package's version will be warned for being extraneous, and version bounds that exclude the package's version will raise an error for being impossible to follow.
2178
2212
2179
-
Cabal can make sure that specified programs are built and on the ``PATH`` before building the component in question.
2180
-
It will always do so for internal dependencies, and also do so for external dependencies when using Nix-style local builds.
2213
+
.. note::
2181
2214
2182
-
:pkg-field:`build-tool-depends` was added in Cabal 2.0, and it will
2183
-
be ignored (with a warning) with old versions of Cabal. See
2184
-
:pkg-field:`build-tools` for more information about backwards
2185
-
compatibility.
2215
+
:pkg-field:`build-tool-depends` was added in Cabal 2.0, and it will
2216
+
be ignored (with a warning) with old versions of Cabal. See
2217
+
:pkg-field:`build-tools` for more information about backwards
2218
+
compatibility.
2186
2219
2187
2220
.. pkg-field:: build-tools: program list
2188
2221
:deprecated:
@@ -3589,3 +3622,13 @@ a few options:
3589
3622
3590
3623
3591
3624
.. include:: references.inc
3625
+
3626
+
.. rubric:: Footnotes
3627
+
3628
+
.. [#old-style-build-tool-depends]
3629
+
3630
+
Some packages (ab)use :pkg-field:`build-depends` on old-style builds, but this has a few major drawbacks:
3631
+
3632
+
- using Nix-style builds it's considered an error if you depend on a exe-only package via build-depends: the solver will refuse it.
3633
+
- it may or may not place the executable on $PATH.
3634
+
- it does not ensure the correct version of the package is installed, so you might end up overwriting versions with each other.
0 commit comments