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
{{ message }}
This repository was archived by the owner on Oct 7, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: docs/Build.md
+47-19Lines changed: 47 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -10,41 +10,69 @@ The design of the build system has the following main goals:
10
10
11
11
* works identically on every platform
12
12
* has minimal run-time dependencies:
13
-
-a working installation of `stack`
13
+
-`stack`
14
14
-`git`
15
-
* is completely functional right after simple `git clone`
16
-
* one-stop-shop for building all executables required for using `hie` in IDEs.
15
+
* is completely functional right after a simple `git clone` and after every `git pull`
16
+
* one-stop-shop for building and naming all executables required for using `hie` in IDEs.
17
+
* prevents certain build failures by either identifying a failed precondition (such as wrong `stack` version) or by performing the necessary steps so users can't forget them (such as invoking `git` to update submodules)
18
+
19
+
20
+
* is able to modify the environment such that `hie` can be run
21
+
- setup `hoogle` database
22
+
- setup `hlint` data-files
17
23
18
24
See the project's `README` for detailed information about installing `hie`.
19
25
20
-
### Tradeoffs
26
+
### Targets
21
27
22
-
#### `shake.yaml`
28
+
The build script `install.hs` defines several targets using the `shake` build system. The targets are roughly:
23
29
24
-
A `shake.yaml` is required for executing the `install.hs` file.
30
+
*`hie-*`: builds and installs the `hie` binaries. Also renames the binaries to contain the correct version-number.
31
+
*`build`: builds and installs `hie` binaries for all supported `ghc` versions.
32
+
*`build-doc`: builds the hoogle-db required by `hie`
33
+
*`cabal-*`: execute the same task as the original target, but with `cabal` instead of `stack`
25
34
26
-
* It contains the required version of `shake`.
27
-
* In contrast to the other `*.yaml` it does not contain the submodules, which is necessary for `stack` to work even before the submodules have been initialized.
35
+
Each `stack-*.yaml` contains references to packages in the submodules. Calling `stack` with one of those causes the build to fail if the submodules have not been initialized already. The file `shake.yaml` solves this issue invoking the `git` binary itself to update the submodules. Moreover, it specifies the correct version of `shake` and is used for installing all run-time dependencies such as `cabal` and `hoogle` if necessary.
28
36
29
-
It is necessary to update the `resolver` field of the `shake.yaml` if the script should run with a different `GHC`.
37
+
### Run-time dependencies
30
38
31
-
#### `install.hs` installs a GHC
39
+
`hie` depends on a correct environment in order to function properly:
32
40
33
-
Before the code in `install.hs` can be executed, `stack` installs a `GHC`, depending on the `resolver` field in `shake.yaml`. This is necessary if `install.hs` should be completely functional right after a fresh `git clone` without further configuration.
41
+
*`cabal-install`: If no `cabal` executable can be found or has an outdated version, `cabal-install` is installed via `stack`.
42
+
* The `hoogle` database: `hoogle generate` needs to be called with the most-recent `hoogle` version.
34
43
35
-
This may lead to an extra `GHC` to be installed by `stack` if not all versions of `haskell-ide-engine` are installed.
3. ensure that `cabal-install` is installed in the correct version
51
+
4.`stack --stack-yaml=stack-<X>.yaml install` or `cabal new-install -w ghc-<X>`
52
+
5. rename `hie` binary to `hie-<X>` in `$HOME/.local/bin`, where `<X>` is the GHC version used
53
+
6. repeat step 4 and 5 for all desired GHC versions
54
+
55
+
This ensures that a complete install is always possible after each `git pull` or a `git clone`.
56
+
57
+
### Safety checks
58
+
59
+
The `install.hs` script performs some checks to ensure that a correct installation is possible and provide meaningful error messages for known issues.
60
+
61
+
*`stack` needs to be up-to-date. Version `1.9.3` is required
62
+
*`ghc-8.6.3` is broken on windows. Trying to install `hie-8.6.3` on windows is not possible.
63
+
*`cabal new-build` does not work on windows at the moment. All `cabal-*` targets exit with an error message about that.
64
+
* When the build fails, an error message, that suggests to remove `.stack-work` directory, is displayed.
65
+
66
+
### Tradeoffs
36
67
37
68
#### `stack` is a build dependency
38
69
39
70
Currently, it is not possible to build all `hie-*` executables automatically without `stack`, since the `install.hs` script is executed by `stack`.
40
71
41
-
Other parts of the script also depend on `stack`:
42
-
43
-
* finding the local install-dir `stack path --local-bin`
44
-
* finding and installing different `ghc` versions
72
+
We are open to suggestions of other build systems that honor the requirements above, but are executable without `stack`.
45
73
46
-
#### `install.hs`executes `cabal install Cabal`
74
+
#### `install.hs`installs a GHC before running
47
75
48
-
`ghc-mod` installs `cabal-helper` at runtime depending on the `ghc` used by the project, which can take a long time upon startup of `hie`. The `install.hs`script speeds up this process by calling `cabal install Cabal` upon build.
76
+
Before the code in `install.hs` can be executed, `stack` installs a `GHC`, depending on the `resolver` field in `shake.yaml`. This is necessary if `install.hs`should be completely functional right after a fresh `git clone` without further configuration.
49
77
50
-
Hopefully, this behaviour can be removed in the future.
78
+
This may lead to an extra `GHC` to be installed by `stack` if not all versions of `haskell-ide-engine` are installed.
0 commit comments