Commit aa26864e authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Add an "exposed" field to the .cabal file library section

It's a bool flag that says if by default the library should
be registered with the compiler as exposed/unhidden (for
compilers which have such a concept, ie ghc). You might want
to do this for packages which would otherwise pollute the
module namespace or clash with other common packages.
It should be very rarely used. The only current examples we
know of are the ghc api package and the dph packages.
parent b0cb3d46
......@@ -214,6 +214,7 @@ instance Text BuildType where
data Library = Library {
exposedModules :: [ModuleName],
libExposed :: Bool, -- ^ Is the lib to be exposed by default?
libBuildInfo :: BuildInfo
}
deriving (Show, Eq, Read)
......@@ -221,10 +222,12 @@ data Library = Library {
instance Monoid Library where
mempty = Library {
exposedModules = mempty,
libExposed = True,
libBuildInfo = mempty
}
mappend a b = Library {
exposedModules = combine exposedModules,
libExposed = libExposed a && libExposed b, -- so False propagates
libBuildInfo = combine libBuildInfo
}
where combine field = field a `mappend` field b
......
......@@ -167,11 +167,13 @@ storeXFieldsPD _ _ = Nothing
-- The Library type
libFieldDescrs :: [FieldDescr Library]
libFieldDescrs = map biToLib binfoFieldDescrs
++ [
listField "exposed-modules" disp parseModuleNameQ
exposedModules (\mods lib -> lib{exposedModules=mods})
]
libFieldDescrs =
[ listField "exposed-modules" disp parseModuleNameQ
exposedModules (\mods lib -> lib{exposedModules=mods})
, boolField "exposed"
libExposed (\val lib -> lib{libExposed=val})
] ++ map biToLib binfoFieldDescrs
where biToLib = liftField libBuildInfo (\bi lib -> lib{libBuildInfo=bi})
storeXFieldsLib :: UnrecFieldParser Library
......
......@@ -267,7 +267,7 @@ mkInstalledPackageInfo distPref pkg_descr lbi inplace = do
IPI.pkgUrl = pkgUrl pkg_descr,
IPI.description = description pkg_descr,
IPI.category = category pkg_descr,
IPI.exposed = True,
IPI.exposed = libExposed lib,
IPI.exposedModules = exposedModules lib,
IPI.hiddenModules = otherModules bi,
IPI.importDirs = [libraryDir],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment