diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2020-04-29 15:14:10 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-04-30 07:30:50 -0400 |
commit | 014ef4a3d9ee30b8add9118950f1f5007143bd1c (patch) | |
tree | c96637d36e1ca0b38b282cc1f4b3b648d8f7384a /hadrian/src/Rules.hs | |
parent | 19b701c216246596710f0eba112ed5ee7b6bf870 (diff) | |
download | haskell-014ef4a3d9ee30b8add9118950f1f5007143bd1c.tar.gz |
Hadrian: Improve tool-args command to support more components
There is a new command to hadrian, tool:path/to/file.hs, which returns
the options needed to compile that file in GHCi.
This is now used in the ghci script with argument `ghc/Main.hs` but its
main purpose is to support the new multi-component branch of ghcide.
Diffstat (limited to 'hadrian/src/Rules.hs')
-rw-r--r-- | hadrian/src/Rules.hs | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/hadrian/src/Rules.hs b/hadrian/src/Rules.hs index db3b16bddd..eee14161cd 100644 --- a/hadrian/src/Rules.hs +++ b/hadrian/src/Rules.hs @@ -24,43 +24,12 @@ import qualified Rules.Program import qualified Rules.Register import qualified Rules.Rts import qualified Rules.SimpleTargets +import Rules.ToolArgs import Settings import Settings.Program (programContext) import Target import UserSettings --- | @tool-args@ 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 --- run, the target prints out the arguments that would be passed to @ghc@ --- during normal compilation to @stdout@. --- --- This target is called by the `ghci` script in order to load all of GHC's --- modules into GHCi. -toolArgsTarget :: Rules () -toolArgsTarget = do - "tool-args" ~> do - -- We can't build DLLs on Windows (yet). Actually we should only - -- include the dynamic way when we have a dynamic host GHC, but just - -- checking for Windows seems simpler for now. - let fake_target = target (Context Stage0 compiler (if windowsHost then vanilla else dynamic)) - (Ghc ToolArgs Stage0) [] ["ignored"] - - -- need the autogenerated files so that they are precompiled - includesDependencies Stage0 >>= need - interpret fake_target Rules.Generate.compilerDependencies >>= need - - root <- buildRoot - let dir = buildDir (vanillaContext Stage0 compiler) - need [ root -/- dir -/- "Config.hs" ] - need [ root -/- dir -/- "GHC" -/- "Parser.hs" ] - need [ root -/- dir -/- "GHC" -/- "Parser" -/- "Lexer.hs" ] - need [ root -/- dir -/- "GHC" -/- "Cmm" -/- "Parser.hs" ] - need [ root -/- dir -/- "GHC" -/- "Cmm" -/- "Lexer.hs" ] - - -- Find out the arguments that are needed to load a module into the - -- session - arg_list <- interpret fake_target getArgs - liftIO $ putStrLn (intercalate "\n" arg_list) allStages :: [Stage] allStages = [minBound .. maxBound] |