|
|
1
|
+#!/usr/bin/env bash
|
|
|
2
|
+
|
|
|
3
|
+:;# When run, this program will output a list of arguments which are necessary to
|
|
|
4
|
+:;# load the GHC library component into GHCi. The program is used by `ghcide` in
|
|
|
5
|
+:;# order to automatically set up the correct GHC API session for a project.
|
|
|
6
|
+
|
|
|
7
|
+:;# This is a POSIX shell/Windows batch polyglot script, which allows hie-bios
|
|
|
8
|
+:;# to use a single hie.yaml file for both platforms.
|
|
|
9
|
+:;#
|
|
|
10
|
+:;# 1. The file extension is '.bat', because Windows requires this.
|
|
|
11
|
+:;# On POSIX, the extension doesn't matter, because the #! is what makes
|
|
|
12
|
+:;# the script runnable. On Windows, this shebang makes cmd.exe complain on
|
|
|
13
|
+:;# stderr, but this doesn't break anything; we add 'Please ignore the #! error'
|
|
|
14
|
+:;# to stderr as a courtesy.
|
|
|
15
|
+:;# 2. On Windows, cmd.exe interprets lines starting with ':' as (goto) labels,
|
|
|
16
|
+:;# essentially ignoring them (for our purposes).
|
|
|
17
|
+:;# On POSIX, ':' is the no-op command, which we terminate with ';'.
|
|
|
18
|
+:;# As '#' is used for shell comment syntax, ':;#' behaves like a comment
|
|
|
19
|
+:;# marker in the polyglot language.
|
|
|
20
|
+:;# 3. The line endings are LF-only, to make this POSIX-compliant.
|
|
|
21
|
+
|
|
|
22
|
+:;# The POSIX part. Ignored on Windows as it starts with ':'.
|
|
|
23
|
+:; TERM=dumb CABFLAGS=-v0 TOOL_OUTPUT=$HIE_BIOS_OUTPUT exec "$PWD/hadrian/build-cabal" tool:"$1" -q --build-root=.hie-bios --flavour=ghc-in-ghci -j
|
|
|
24
|
+
|
|
|
25
|
+:;# The Windows part. Ignored on POSIX, because the above command execs.
|
|
|
26
|
+@echo off
|
|
|
27
|
+>&2 echo Please ignore the above error that '#!' is not recognised.
|
|
1
|
28
|
set TERM=dumb
|
|
2
|
29
|
set CABFLAGS=-v0
|
|
3
|
30
|
set TOOL_OUTPUT=%HIE_BIOS_OUTPUT%
|
|
4
|
|
-%CD%\hadrian\build-cabal.bat tool:%1 --build-root=.hie-bios --flavour=ghc-in-ghci -j |
|
|
31
|
+%CD%\hadrian\build-cabal.bat tool:%1 -q --build-root=.hie-bios --flavour=ghc-in-ghci -j |