haskell-ide-engine is built using the library shake. The build descriptions are defined in the file install.hs.
Previously, haskell-ide-engine was built using a Makefile on Unix systems and a PowerShell script on Windows. By replacing both scripts by a Haskell-based solution, the build process is unified.
The design of the build system has the following main goals:
-
works identically on every platform
-
has minimal run-time dependencies:
stackorcabalgit
-
is completely functional right after a simple
git cloneand after everygit pull -
prevents certain build failures by either identifying a failed precondition (such as wrong
stackversion) or by performing the necessary steps so users can't forget them (such as invokinggitto update submodules) -
is able to modify the environment such that
hiecan be run- setup
hoogledatabase - setup
hlintdata-files
- setup
See the project's README for detailed information about installing hie.
The build script install.hs defines several targets using the shake build system. The targets are roughly:
hie-*: builds and installs thehiebinaries. Also renames the binaries to contain the correct version-number.latest: builds and installshiefor the latest available and supportedghcversion.data: builds the hoogle-db required byhiehie: builds and installshiefor the latest supportedghcversion (likelatest) and the hoogle-db (likedata)
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 hoogle if necessary.
hie depends on a correct environment in order to function properly:
cabal-install: This dependency is required byhieto handle correctly projects that are notstackbased. You can install it using one of the methods listed here: https://www.haskell.org/cabal/#install-upgrade- The
hoogledatabase:hoogle generateneeds to be called with the most-recenthoogleversion.
Installing hie is a multi-step process:
git submodule sync && git submodule update --inithoogle generate(hoogle>=5.0.17to be safe)stack --stack-yaml=stack-<X>.yaml installorcabal v2-install -w ghc-<X>- rename
hiebinary tohie-<X>in$HOME/.local/bin, where<X>is the GHC version used - repeat step 3 and 4 for all desired GHC versions
This ensures that a complete install is always possible after each git pull or a git clone.
To build hie with profiling enabled cabal v2-install needs to be used instead of stack.
Configure cabal to enable profiling by setting profiling: True in cabal.project.local for all packages. If that file does not already exist, create it as follows:
cat << EOF > cabal.project.local
package *
profiling: True
EOFThen hie can be compiled for a specific GHC version:
- For cabal prior to 3.0.0.0
export GHCP=<path-to-ghc-binary>
cabal v2-install exe:hie -w $GHCP \
--write-ghc-environment-files=never --symlink-bindir=$HOME/.local/bin \
--overwrite-policy=always --reinstall- For cabal 3.0.0.0 or newer
export GHCP=<path-to-ghc-binary>
cabal v2-install exe:hie -w $GHCP \
--write-ghc-environment-files=never --installdir=$HOME/.local/bin \
--overwrite-policy=always --reinstall- For windows you will need cabal 3.0.0.0 and add the argument
--install-method=copy
The final step is to configure the hie client to use a custom hie-wrapper script that enables the runtime options for profiling. Such a script could look like this:
#!/bin/sh
~/.local/bin/hie-wrapper "$@" +RTS -xc(Note: If no profiling information is shown when using hie with a certain project, it may help to build that project itself with profiling support, e.g. stack build --profile.)
The install.hs script performs some checks to ensure that a correct installation is possible and provide meaningful error messages for known issues.
stackneeds to be up-to-date. Version2.1.1is requiredcabalneeds to be up-to-date. Version3.0.0.0is required for windows systems and2.4.1.0for other ones.ghc-8.6.3is broken on windows. Trying to installhie-8.6.3on windows is not possible.- When the build fails, an error message, that suggests to remove
.stack-workdirectory, is displayed.
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.
This may lead to an extra GHC to be installed by stack if not all versions of haskell-ide-engine are installed.
However, you always could change the resolver in shake.yaml to match the appropiate one.