Forked from mpickering/gist:e13f343f2b35b51693d15582180b1c02
Last active
August 25, 2019 07:03
-
-
Save steshaw/138b33730d62ae8deb814ccffb4cf616 to your computer and use it in GitHub Desktop.
Simple GHC API executable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Lib | |
import GHC as G | |
import GhcMake as G | |
import DynFlags | |
import SrcLoc as G | |
import GHC.Paths | |
import Control.Monad | |
import Control.Monad.IO.Class | |
import System.Environment | |
initGhcM :: [String] -> Ghc () | |
initGhcM xs = do | |
df1 <- getSessionDynFlags | |
let cmdOpts = ["-package", "ghc", "-fforce-recomp"] ++ xs | |
(df2, leftovers, warns) <- G.parseDynamicFlags df1 (map G.noLoc cmdOpts) | |
-- pprTraceM "leftovers" $ ppr leftovers | |
setSessionDynFlags df2 | |
ts <- mapM (flip G.guessTarget Nothing) $ map unLoc leftovers | |
-- (df2, ts) | |
setTargets ts | |
-- mod_graph <- G.depanal [] True | |
void $ G.load LoadAllTargets -- Nothing mod_graph | |
-- df <- getSessionDynFlags | |
return () | |
main :: IO () | |
main = do | |
xs <- getArgs | |
runGhc (Just libdir) $ initGhcM xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment