Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9df24b7e by sheaf at 2026-08-10T14:28:30-04:00 hie.yaml: use a polyglot shell/batch script This commit merges hie-bios and hie-bios.bat into a single polyglot script. This avoids Windows users having to manually update hie.yaml in order to be able to use HLS. - - - - - 3 changed files: - − hadrian/hie-bios - hadrian/hie-bios.bat - hie.yaml Changes: ===================================== hadrian/hie-bios deleted ===================================== @@ -1,6 +0,0 @@ -#! /usr/bin/env bash - -# When run, this program will output a list of arguments which are necessary to -# load the GHC library component into GHCi. The program is used by `ghcide` in -# order to automatically set up the correct GHC API session for a project. -TERM=dumb CABFLAGS=-v0 TOOL_OUTPUT=$HIE_BIOS_OUTPUT $PWD/hadrian/build-cabal tool:$1 -q --build-root=.hie-bios --flavour=ghc-in-ghci -j ===================================== hadrian/hie-bios.bat ===================================== @@ -1,4 +1,31 @@ +#!/usr/bin/env bash + +:;# When run, this program will output a list of arguments which are necessary to +:;# load the GHC library component into GHCi. The program is used by `ghcide` in +:;# order to automatically set up the correct GHC API session for a project. + +:;# This is a POSIX shell/Windows batch polyglot script, which allows hie-bios +:;# to use a single hie.yaml file for both platforms. +:;# +:;# 1. The file extension is '.bat', because Windows requires this. +:;# On POSIX, the extension doesn't matter, because the #! is what makes +:;# the script runnable. On Windows, this shebang makes cmd.exe complain on +:;# stderr, but this doesn't break anything; we add 'Please ignore the #! error' +:;# to stderr as a courtesy. +:;# 2. On Windows, cmd.exe interprets lines starting with ':' as (goto) labels, +:;# essentially ignoring them (for our purposes). +:;# On POSIX, ':' is the no-op command, which we terminate with ';'. +:;# As '#' is used for shell comment syntax, ':;#' behaves like a comment +:;# marker in the polyglot language. +:;# 3. The line endings are LF-only, to make this POSIX-compliant. + +:;# The POSIX part. Ignored on Windows as it starts with ':'. +:; 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 + +:;# The Windows part. Ignored on POSIX, because the above command execs. +@echo off +>&2 echo Please ignore the above error that '#!' is not recognised. set TERM=dumb set CABFLAGS=-v0 set TOOL_OUTPUT=%HIE_BIOS_OUTPUT% -%CD%\hadrian\build-cabal.bat tool:%1 --build-root=.hie-bios --flavour=ghc-in-ghci -j +%CD%\hadrian\build-cabal.bat tool:%1 -q --build-root=.hie-bios --flavour=ghc-in-ghci -j ===================================== hie.yaml ===================================== @@ -1,8 +1,7 @@ # This is a IDE configuration file which tells IDEs such as `ghcide` how # to set up a GHC API session for this project. # -# To use it in windows systems replace the config with -# cradle: {bios: {program: "./hadrian/hie-bios.bat"}} -# # The format is documented here - https://github.com/mpickering/hie-bios -cradle: {bios: {program: "./hadrian/hie-bios"}} +cradle: {bios: {program: "./hadrian/hie-bios.bat"}} + # NB: hadrian/hie-bios.bat is a shell/batch polyglot script which runs + # on all platforms. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9df24b7e5fa8e76c01270ce1e708ab4c... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9df24b7e5fa8e76c01270ce1e708ab4c... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help