@@ -3,6 +3,7 @@
33
44{-# LANGUAGE OverloadedStrings #-}
55{-# LANGUAGE RankNTypes #-}
6+{-# LANGUAGE CPP #-}
67
78-- | Based on https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/API.
89-- Given a list of paths to find libraries, and a file to compile, produce a list of 'CoreModule' values.
@@ -414,7 +415,9 @@ getModSummaryFromBuffer fp (contents, fileDate) dflags parsed = do
414415 { ml_hs_file = Just fp
415416 , ml_hi_file = replaceExtension fp "hi"
416417 , ml_obj_file = replaceExtension fp "o"
418+#ifndef USE_GHC
417419 , ml_hie_file = replaceExtension fp "hie"
420+#endif
418421 -- This does not consider the dflags configuration
419422 -- (-osuf and -hisuf, object and hi dir.s).
420423 -- However, we anyway don't want to generate them.
@@ -433,7 +436,9 @@ getModSummaryFromBuffer fp (contents, fileDate) dflags parsed = do
433436 , ms_hsc_src = HsSrcFile
434437 , ms_obj_date = Nothing
435438 , ms_iface_date = Nothing
439+#ifndef USE_GHC
436440 , ms_hie_date = Nothing
441+#endif
437442 , ms_srcimps = [] -- source imports are not allowed
438443 , ms_parsed_mod = Nothing
439444 }
@@ -450,8 +455,13 @@ parseFileContents preprocessor filename (time, contents) = do
450455 let loc = mkRealSrcLoc (mkFastString filename) 1 1
451456 dflags <- parsePragmasIntoDynFlags filename contents
452457 case unP Parser.parseModule (mkPState dflags contents loc) of
458+#ifdef USE_GHC
459+ PFailed getMessages _ _ ->
460+ Ex.throwE $ toDiagnostics dflags $ snd $ getMessages dflags
461+#else
453462 PFailed s ->
454463 Ex.throwE $ toDiagnostics dflags $ snd $ getMessages s dflags
464+#endif
455465 POk pst rdr_module ->
456466 let hpm_annotations =
457467 (Map.fromListWith (++) $ annotations pst,