Skip to content
Snippets Groups Projects
Commit 5433a35e authored by Matthew Pickering's avatar Matthew Pickering Committed by Marge Bot
Browse files

hadrian/tool-args: Write output to intermediate file rather than via stdout

This allows us to see the output of hadrian while it is doing the setup.
parent 24b5bb61
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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
......@@ -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
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
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment