summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2016-07-10 21:38:01 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2016-07-10 21:38:01 +0200
commit9a3df1f892499f9e8bfaa2096da63f2058c20027 (patch)
tree02e2b6b82c3d918f68132d040d69a960b0b58860 /utils
parentf53d761df9762232b54ec57a950d301011cd21f8 (diff)
downloadhaskell-9a3df1f892499f9e8bfaa2096da63f2058c20027.tar.gz
check-api-annotations utility loads by filename
Previously it loaded by modulename, which prevented loading files with a Main module.
Diffstat (limited to 'utils')
-rw-r--r--utils/check-api-annotations/Main.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/utils/check-api-annotations/Main.hs b/utils/check-api-annotations/Main.hs
index 20e6aa0ca2..1d577421fb 100644
--- a/utils/check-api-annotations/Main.hs
+++ b/utils/check-api-annotations/Main.hs
@@ -20,15 +20,23 @@ main = do
testOneFile :: FilePath -> String -> IO ()
testOneFile libdir fileName = do
+ let modByFile m =
+ case ml_hs_file $ ms_location m of
+ Nothing -> False
+ Just fn -> fn == fileName
((anns,_cs),p) <- runGhc (Just libdir) $ do
dflags <- getSessionDynFlags
_ <- setSessionDynFlags dflags
- let mn =mkModuleName fileName
- addTarget Target { targetId = TargetModule mn
+ addTarget Target { targetId = TargetFile fileName Nothing
, targetAllowObjCode = True
, targetContents = Nothing }
_ <- load LoadAllTargets
- modSum <- getModSummary mn
+ graph <- getModuleGraph
+ let
+ modSum = case filter modByFile graph of
+ [x] -> x
+ xs -> error $ "Can't find module, got:"
+ ++ show (map (ml_hs_file . ms_location) xs)
p <- parseModule modSum
return (pm_annotations p,p)