Skip to content

Commit b1cea20

Browse files
authored
Merge pull request #1291 from tweag/ch/complete-tutorial-wrt-workspace-file
Tutorial: highlight necessary content of the WORKSPACE file
2 parents 9a52a45 + 45a7e99 commit b1cea20

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

docs/haskell-use-cases.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ is known to be compatible with rules_haskell and creates a new Bazel
1515
workspace in the current working directory with a few dummy build
1616
targets. See the following sections about customizing the workspace.
1717

18+
Making rules_haskell available
19+
----------------------------------
20+
21+
First of all, the ``WORKSPACE`` file must specify how to obtain
22+
rules_haskell. To use a released version, do the following::
23+
24+
load(
25+
"@bazel_tools//tools/build_defs/repo:http.bzl",
26+
"http_archive"
27+
)
28+
29+
http_archive(
30+
name = "rules_haskell",
31+
strip_prefix = "rules_haskell-0.12",
32+
urls = ["https://github.com/tweag/rules_haskell/archive/v0.12.tar.gz"],
33+
sha256 = "56a8e6337df8802f1e0e7d2b3d12d12d5d96c929c8daecccc5738a0f41d9c1e4",
34+
)
35+
1836
Picking a compiler
1937
------------------
2038

docs/haskell.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ On a Unix system you will need the following tools installed.
3232
* ``libgmp``
3333
* ``libtinfo5``
3434
* ``make``
35-
* ``python3`` (``python`` also needs to be available in ``$PATH``. Depending on your distro, this might require installing the ``python`` meta-package, which might use Python 2 or 3, ``rules_haskell`` works with both.)
35+
* ``python3`` (``python`` also needs to be available in ``$PATH``. Depending on your distribution, this might require installing the ``python`` meta-package, which might use Python 2 or 3, ``rules_haskell`` works with both.)
3636

3737
On Ubuntu you can obtain them by installing the following packages. ::
3838

@@ -89,14 +89,27 @@ special:
8989
contains a ``BUILD.bazel`` file is a *package*. You will learn about
9090
packages later in this tutorial.)
9191

92-
To designate a directory as a Bazel workspace, create an empty file
92+
To designate a directory as a Bazel workspace, create a file
9393
named ``WORKSPACE`` in that directory.
94+
This file defines `external dependencies`_.
9495

9596
When Bazel builds the project, all inputs and dependencies must be in
9697
the same workspace. Files residing in different workspaces are
9798
independent of one another unless linked, which is beyond the scope of
9899
this tutorial.
99100

101+
Understand the WORKSPACE file
102+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103+
104+
The file ``tutorial/WORKSPACE`` defines how to obtain ``rules_haskell``.
105+
This file only works within the ``rules_haskell``
106+
repository: for your own project, run the start_ script
107+
to create a ``WORKSPACE`` file that makes ``rules_haskell`` available
108+
by `downloading it`_.
109+
110+
The ``WORKSPACE`` file also defines how to obtain the compiler toolchain,
111+
as detailed in section `picking a compiler`_.
112+
100113
Understand the BUILD file
101114
^^^^^^^^^^^^^^^^^^^^^^^^^
102115

@@ -379,6 +392,9 @@ Happy building!
379392
.. _haskell_toolchain_library: http://api.haskell.build/haskell/haskell.html#haskell_toolchain_library
380393
.. _haskell_library: http://api.haskell.build/haskell/haskell.html#haskell_library
381394
.. _graphviz: https://www.graphviz.org/
395+
.. _start: https://rules-haskell.readthedocs.io/en/latest/haskell-use-cases.html#starting-a-new-project
396+
.. _downloading it: https://rules-haskell.readthedocs.io/en/latest/haskell-use-cases.html#making-rules-haskell-available
397+
.. _picking a compiler: https://rules-haskell.readthedocs.io/en/latest/haskell-use-cases.html#picking-a-compiler
382398
.. _external dependencies: https://docs.bazel.build/versions/master/external.html
383399
.. _build encyclopedia: https://docs.bazel.build/versions/master/be/overview.html
384400
.. _C++ build tutorial: https://docs.bazel.build/versions/master/tutorial/cpp.html

0 commit comments

Comments
 (0)