summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-02-17 10:20:25 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2022-06-01 10:32:02 +0100
commit7e470cd6e07d840b032b5249dceb061a4d590fee (patch)
tree6bcf23933733e0842f9f0eed6d2cfd7f326804c7
parent15d42a7a1287b0466ea97bedf71f4a0b161b17b4 (diff)
downloadhaskell-wip/tool-args.tar.gz
hadrian/tool-args: Write output to intermediate file rather than via stdoutwip/tool-args
This allows us to see the output of hadrian while it is doing the setup.
-rwxr-xr-xhadrian/ghci-cabal.in5
-rwxr-xr-xhadrian/ghci-stack.in5
-rwxr-xr-xhadrian/hie-bios2
-rw-r--r--hadrian/hie-bios.bat3
-rw-r--r--hadrian/src/Rules/ToolArgs.hs7
5 files changed, 16 insertions, 6 deletions
diff --git a/hadrian/ghci-cabal.in b/hadrian/ghci-cabal.in
index 2a97b37180..0245ed6b09 100755
--- a/hadrian/ghci-cabal.in
+++ b/hadrian/ghci-cabal.in
@@ -3,7 +3,8 @@
# This file is generated by configure from ghci-cabal.in
set -e
-
+export TOOL_OUTPUT=.hadrian_ghci/ghci_args
# Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
-GHC_FLAGS="$GHC_FLAGS $(TERM=dumb CABFLAGS=-v0 "hadrian/build-cabal" tool:ghc/Main.hs -q --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS | tr '\n\r' ' ')"
+CABFLAGS=-v0 "hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
+GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')"
@WithGhc@ --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -hidir=.hadrian_ghci/interface -O0 +RTS -A128m
diff --git a/hadrian/ghci-stack.in b/hadrian/ghci-stack.in
index ef95552b64..12f3888205 100755
--- a/hadrian/ghci-stack.in
+++ b/hadrian/ghci-stack.in
@@ -4,6 +4,9 @@
set -e
+export TOOL_OUTPUT=.hadrian_ghci/ghci_args
+TERM=dumb CABFLAGS=-v0 "hadrian/build-cabal" tool:compiler/GHC.hs -q --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
+
# Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
-GHC_FLAGS="$GHC_FLAGS $(TERM=dumb CABFLAGS=-v0 "hadrian/build-stack" tool-args -q --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS | tr '\n\r' ' ')"
+GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')"
stack exec -- @WithGhc@ --interactive $GHC_FLAGS "$@" -fno-code -fwrite-interface -hidir=.hadrian_ghci/interface -O0 +RTS -A128m
diff --git a/hadrian/hie-bios b/hadrian/hie-bios
index 4def2e8823..49224253b8 100755
--- a/hadrian/hie-bios
+++ b/hadrian/hie-bios
@@ -3,5 +3,5 @@
# 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 $PWD/hadrian/build-cabal tool:$1 -q --build-root=.hie-bios --flavour=ghc-in-ghci > $HIE_BIOS_OUTPUT
+TERM=dumb CABFLAGS=-v0 TOOL_OUTPUT=$HIE_BIOS_OUTPUT $PWD/hadrian/build-cabal tool:$1 -q --build-root=.hie-bios --flavour=ghc-in-ghci
diff --git a/hadrian/hie-bios.bat b/hadrian/hie-bios.bat
index fda322af58..73bbea82be 100644
--- a/hadrian/hie-bios.bat
+++ b/hadrian/hie-bios.bat
@@ -1,3 +1,4 @@
set TERM=dumb
set CABFLAGS=-v0
-%CD%\hadrian\build-cabal.bat tool:%1 -q --build-root=_hie-bios --flavour=ghc-in-ghci > %HIE_BIOS_OUTPUT%
+set TOOL_OUTPUT=%HIE_BIOS_OUTPUT%
+%CD%\hadrian\build-cabal.bat tool:%1 --build-root=_hie-bios --flavour=ghc-in-ghci
diff --git a/hadrian/src/Rules/ToolArgs.hs b/hadrian/src/Rules/ToolArgs.hs
index 105ed8f15a..d0905d4548 100644
--- a/hadrian/src/Rules/ToolArgs.hs
+++ b/hadrian/src/Rules/ToolArgs.hs
@@ -12,6 +12,7 @@ import Settings
import Hadrian.Oracles.Cabal
import Hadrian.Haskell.Cabal.Type
import System.Directory (canonicalizePath)
+import System.Environment (lookupEnv)
-- | @tool:@ is used by tooling in order to get the arguments necessary
-- to set up a GHC API session which can compile modules from GHC. When
@@ -48,11 +49,15 @@ mkToolTarget :: [String] -> Package -> Action ()
mkToolTarget es p = do
-- This builds automatically generated dependencies. Not sure how to do
-- this generically yet.
+ putProgressInfo ("Computing arguments for " ++ pkgName p)
allDeps
let fake_target = target (Context stage0InTree p (if windowsHost then vanilla else dynamic))
(Ghc ToolArgs stage0InTree) [] ["ignored"]
arg_list <- interpret fake_target getArgs
- liftIO $ putStrLn (intercalate "\n" (arg_list ++ es))
+ liftIO $ lookupEnv "TOOL_OUTPUT" >>= \case
+ Nothing -> putStrLn (intercalate "\n" (arg_list ++ es))
+ Just out -> writeFile out (intercalate "\n" (arg_list ++ es))
+
allDeps :: Action ()
allDeps = do
do