Commit a642a28b authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Refactor libModules in to explicitLibModules and allLibModules.


Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 6059c6b3
...@@ -35,7 +35,7 @@ module Distribution.PackageDescription ( ...@@ -35,7 +35,7 @@ module Distribution.PackageDescription (
withLib, withLib,
hasPublicLib, hasPublicLib,
hasLibs, hasLibs,
libModules, explicitLibModules,
libModulesAutogen, libModulesAutogen,
-- ** Executables -- ** Executables
......
...@@ -233,7 +233,8 @@ checkLibrary pkg lib = ...@@ -233,7 +233,8 @@ checkLibrary pkg lib =
"Duplicate modules in library: " "Duplicate modules in library: "
++ commaSep (map display moduleDuplicates) ++ commaSep (map display moduleDuplicates)
, check (null (libModules lib) && null (reexportedModules lib)) $ -- TODO: This check is bogus if a required-signature was passed through
, check (null (explicitLibModules lib) && null (reexportedModules lib)) $
PackageDistSuspiciousWarn $ PackageDistSuspiciousWarn $
"Library " ++ (case libName lib of "Library " ++ (case libName lib of
Nothing -> "" Nothing -> ""
...@@ -248,7 +249,7 @@ checkLibrary pkg lib = ...@@ -248,7 +249,7 @@ checkLibrary pkg lib =
-- check that all autogen-modules appear on other-modules or exposed-modules -- check that all autogen-modules appear on other-modules or exposed-modules
, check , check
(not $ and $ map (flip elem (libModules lib)) (libModulesAutogen lib)) $ (not $ and $ map (flip elem (explicitLibModules lib)) (libModulesAutogen lib)) $
PackageBuildImpossible $ PackageBuildImpossible $
"An 'autogen-module' is neither on 'exposed-modules' or " "An 'autogen-module' is neither on 'exposed-modules' or "
++ "'other-modules'." ++ "'other-modules'."
...@@ -261,7 +262,8 @@ checkLibrary pkg lib = ...@@ -261,7 +262,8 @@ checkLibrary pkg lib =
| specVersion pkg >= mkVersion ver = Nothing | specVersion pkg >= mkVersion ver = Nothing
| otherwise = check cond pc | otherwise = check cond pc
moduleDuplicates = dups (libModules lib ++ -- TODO: not sure if this check is always right in Backpack
moduleDuplicates = dups (explicitLibModules lib ++
map moduleReexportName (reexportedModules lib)) map moduleReexportName (reexportedModules lib))
checkExecutable :: PackageDescription -> Executable -> [PackageCheck] checkExecutable :: PackageDescription -> Executable -> [PackageCheck]
...@@ -1342,7 +1344,7 @@ checkCabalVersion pkg = ...@@ -1342,7 +1344,7 @@ checkCabalVersion pkg =
allModuleNames = allModuleNames =
(case library pkg of (case library pkg of
Nothing -> [] Nothing -> []
(Just lib) -> libModules lib (Just lib) -> explicitLibModules lib
) )
++ concatMap otherModules (allBuildInfo pkg) ++ concatMap otherModules (allBuildInfo pkg)
......
...@@ -479,7 +479,14 @@ componentStringName _ (CTestName name) = name ...@@ -479,7 +479,14 @@ componentStringName _ (CTestName name) = name
componentStringName _ (CBenchName name) = name componentStringName _ (CBenchName name) = name
componentModules :: Component -> [ModuleName] componentModules :: Component -> [ModuleName]
componentModules (CLib lib) = libModules lib -- TODO: Use of 'explicitLibModules' here is a bit wrong:
-- a user could very well ask to build a specific signature
-- that was inherited from other packages. To fix this
-- we have to plumb 'LocalBuildInfo' through this code.
-- Fortunately, this is only used by 'pkgComponentInfo'
-- Please don't export this function unless you plan on fixing
-- this.
componentModules (CLib lib) = explicitLibModules lib
componentModules (CExe exe) = exeModules exe componentModules (CExe exe) = exeModules exe
componentModules (CTest test) = testModules test componentModules (CTest test) = testModules test
componentModules (CBench bench) = benchmarkModules bench componentModules (CBench bench) = benchmarkModules bench
......
...@@ -528,7 +528,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do ...@@ -528,7 +528,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
vanillaOpts = baseOpts `mappend` mempty { vanillaOpts = baseOpts `mappend` mempty {
ghcOptMode = toFlag GhcModeMake, ghcOptMode = toFlag GhcModeMake,
ghcOptNumJobs = numJobs, ghcOptNumJobs = numJobs,
ghcOptInputModules = toNubListR $ libModules lib, ghcOptInputModules = toNubListR $ allLibModules lib clbi,
ghcOptHPCDir = hpcdir Hpc.Vanilla ghcOptHPCDir = hpcdir Hpc.Vanilla
} }
...@@ -580,7 +580,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do ...@@ -580,7 +580,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ghcOptHPCDir = hpcdir Hpc.Dyn ghcOptHPCDir = hpcdir Hpc.Dyn
} }
unless (forRepl || null (libModules lib)) $ unless (forRepl || null (allLibModules lib clbi)) $
do let vanilla = whenVanillaLib forceVanillaLib (runGhcProg vanillaOpts) do let vanilla = whenVanillaLib forceVanillaLib (runGhcProg vanillaOpts)
shared = whenSharedLib forceSharedLib (runGhcProg sharedOpts) shared = whenSharedLib forceSharedLib (runGhcProg sharedOpts)
useDynToo = dynamicTooSupported && useDynToo = dynamicTooSupported &&
...@@ -641,7 +641,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do ...@@ -641,7 +641,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
-- exports. -- exports.
ifReplLib $ do ifReplLib $ do
when (null (libModules lib)) $ warn verbosity "No exposed modules" when (null (allLibModules lib clbi)) $ warn verbosity "No exposed modules"
ifReplLib (runGhcProg replOpts) ifReplLib (runGhcProg replOpts)
-- link: -- link:
...@@ -663,17 +663,17 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do ...@@ -663,17 +663,17 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
[ findFileWithExtension [objExtension] [libTargetDir] [ findFileWithExtension [objExtension] [libTargetDir]
(ModuleName.toFilePath x ++"_stub") (ModuleName.toFilePath x ++"_stub")
| ghcVersion < mkVersion [7,2] -- ghc-7.2+ does not make _stub.o files | ghcVersion < mkVersion [7,2] -- ghc-7.2+ does not make _stub.o files
, x <- libModules lib ] , x <- allLibModules lib clbi ]
stubProfObjs <- catMaybes <$> sequenceA stubProfObjs <- catMaybes <$> sequenceA
[ findFileWithExtension ["p_" ++ objExtension] [libTargetDir] [ findFileWithExtension ["p_" ++ objExtension] [libTargetDir]
(ModuleName.toFilePath x ++"_stub") (ModuleName.toFilePath x ++"_stub")
| ghcVersion < mkVersion [7,2] -- ghc-7.2+ does not make _stub.o files | ghcVersion < mkVersion [7,2] -- ghc-7.2+ does not make _stub.o files
, x <- libModules lib ] , x <- allLibModules lib clbi ]
stubSharedObjs <- catMaybes <$> sequenceA stubSharedObjs <- catMaybes <$> sequenceA
[ findFileWithExtension ["dyn_" ++ objExtension] [libTargetDir] [ findFileWithExtension ["dyn_" ++ objExtension] [libTargetDir]
(ModuleName.toFilePath x ++"_stub") (ModuleName.toFilePath x ++"_stub")
| ghcVersion < mkVersion [7,2] -- ghc-7.2+ does not make _stub.o files | ghcVersion < mkVersion [7,2] -- ghc-7.2+ does not make _stub.o files
, x <- libModules lib ] , x <- allLibModules lib clbi ]
hObjs <- Internal.getHaskellObjects implInfo lib lbi hObjs <- Internal.getHaskellObjects implInfo lib lbi
libTargetDir objExtension True libTargetDir objExtension True
...@@ -1169,7 +1169,7 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do ...@@ -1169,7 +1169,7 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do
installShared = install True installShared = install True
copyModuleFiles ext = copyModuleFiles ext =
findModuleFiles [builtDir] [ext] (libModules lib) findModuleFiles [builtDir] [ext] (allLibModules lib clbi)
>>= installOrdinaryFiles verbosity targetDir >>= installOrdinaryFiles verbosity targetDir
compiler_id = compilerId (compiler lbi) compiler_id = compilerId (compiler lbi)
...@@ -1179,7 +1179,7 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do ...@@ -1179,7 +1179,7 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do
ghciLibName = Internal.mkGHCiLibName uid ghciLibName = Internal.mkGHCiLibName uid
sharedLibName = (mkSharedLibName compiler_id) uid sharedLibName = (mkSharedLibName compiler_id) uid
hasLib = not $ null (libModules lib) hasLib = not $ null (allLibModules lib clbi)
&& null (cSources (libBuildInfo lib)) && null (cSources (libBuildInfo lib))
whenVanilla = when (hasLib && withVanillaLib lbi) whenVanilla = when (hasLib && withVanillaLib lbi)
whenProf = when (hasLib && withProfLib lbi) whenProf = when (hasLib && withProfLib lbi)
......
...@@ -361,7 +361,7 @@ getHaskellObjects _implInfo lib lbi pref wanted_obj_ext allow_split_objs ...@@ -361,7 +361,7 @@ getHaskellObjects _implInfo lib lbi pref wanted_obj_ext allow_split_objs
| splitObjs lbi && allow_split_objs = do | splitObjs lbi && allow_split_objs = do
let splitSuffix = "_" ++ wanted_obj_ext ++ "_split" let splitSuffix = "_" ++ wanted_obj_ext ++ "_split"
dirs = [ pref </> (ModuleName.toFilePath x ++ splitSuffix) dirs = [ pref </> (ModuleName.toFilePath x ++ splitSuffix)
| x <- libModules lib ] | x <- allLibModules lib clbi ]
objss <- traverse getDirectoryContents dirs objss <- traverse getDirectoryContents dirs
let objs = [ dir </> obj let objs = [ dir </> obj
| (objs',dir) <- zip objss dirs, obj <- objs', | (objs',dir) <- zip objss dirs, obj <- objs',
...@@ -370,7 +370,9 @@ getHaskellObjects _implInfo lib lbi pref wanted_obj_ext allow_split_objs ...@@ -370,7 +370,9 @@ getHaskellObjects _implInfo lib lbi pref wanted_obj_ext allow_split_objs
return objs return objs
| otherwise = | otherwise =
return [ pref </> ModuleName.toFilePath x <.> wanted_obj_ext return [ pref </> ModuleName.toFilePath x <.> wanted_obj_ext
| x <- libModules lib ] | x <- allLibModules lib clbi ]
where
clbi = getComponentLocalBuildInfo lbi CLibName
mkGhcOptPackages :: ComponentLocalBuildInfo mkGhcOptPackages :: ComponentLocalBuildInfo
-> [(UnitId, ModuleRenaming)] -> [(UnitId, ModuleRenaming)]
......
...@@ -317,7 +317,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do ...@@ -317,7 +317,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
vanillaOptsNoJsLib = baseOpts `mappend` mempty { vanillaOptsNoJsLib = baseOpts `mappend` mempty {
ghcOptMode = toFlag GhcModeMake, ghcOptMode = toFlag GhcModeMake,
ghcOptNumJobs = numJobs, ghcOptNumJobs = numJobs,
ghcOptInputModules = toNubListR $ libModules lib, ghcOptInputModules = toNubListR $ allLibModules lib clbi,
ghcOptHPCDir = hpcdir Hpc.Vanilla ghcOptHPCDir = hpcdir Hpc.Vanilla
} }
vanillaOpts = vanillaOptsNoJsLib `mappend` linkJsLibOpts vanillaOpts = vanillaOptsNoJsLib `mappend` linkJsLibOpts
...@@ -363,7 +363,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do ...@@ -363,7 +363,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ghcOptHPCDir = hpcdir Hpc.Dyn ghcOptHPCDir = hpcdir Hpc.Dyn
} }
unless (forRepl || (null (libModules lib) && null jsSrcs && null cObjs)) $ unless (forRepl || (null (allLibModules lib clbi) && null jsSrcs && null cObjs)) $
do let vanilla = whenVanillaLib forceVanillaLib (runGhcjsProg vanillaOpts) do let vanilla = whenVanillaLib forceVanillaLib (runGhcjsProg vanillaOpts)
shared = whenSharedLib forceSharedLib (runGhcjsProg sharedOpts) shared = whenSharedLib forceSharedLib (runGhcjsProg sharedOpts)
useDynToo = dynamicTooSupported && useDynToo = dynamicTooSupported &&
...@@ -414,7 +414,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do ...@@ -414,7 +414,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
-- TODO: problem here is we need the .c files built first, so we can load them -- TODO: problem here is we need the .c files built first, so we can load them
-- with ghci, but .c files can depend on .h files generated by ghc by ffi -- with ghci, but .c files can depend on .h files generated by ghc by ffi
-- exports. -- exports.
unless (null (libModules lib)) $ unless (null (allLibModules lib clbi)) $
ifReplLib (runGhcjsProg replOpts) ifReplLib (runGhcjsProg replOpts)
-- link: -- link:
...@@ -726,7 +726,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do ...@@ -726,7 +726,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
installSharedNative = install True False installSharedNative = install True False
copyModuleFiles ext = copyModuleFiles ext =
findModuleFiles [builtDir] [ext] (libModules lib) findModuleFiles [builtDir] [ext] (allLibModules lib clbi)
>>= installOrdinaryFiles verbosity targetDir >>= installOrdinaryFiles verbosity targetDir
compiler_id = compilerId (compiler lbi) compiler_id = compilerId (compiler lbi)
...@@ -736,7 +736,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do ...@@ -736,7 +736,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
ghciLibName = Internal.mkGHCiLibName uid ghciLibName = Internal.mkGHCiLibName uid
sharedLibName = (mkSharedLibName compiler_id) uid sharedLibName = (mkSharedLibName compiler_id) uid
hasLib = not $ null (libModules lib) hasLib = not $ null (allLibModules lib clbi)
&& null (cSources (libBuildInfo lib)) && null (cSources (libBuildInfo lib))
whenVanilla = when (hasLib && withVanillaLib lbi) whenVanilla = when (hasLib && withVanillaLib lbi)
whenProf = when (hasLib && withProfLib lbi) whenProf = when (hasLib && withProfLib lbi)
......
...@@ -179,7 +179,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do ...@@ -179,7 +179,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do
["-G", display language] ++ ["-G", display language] ++
concat [ ["-X", display ex] | ex <- usedExtensions bi ] ++ concat [ ["-X", display ex] | ex <- usedExtensions bi ] ++
cppOptions (libBuildInfo lib) ++ cppOptions (libBuildInfo lib) ++
[ display modu | modu <- libModules lib ] [ display modu | modu <- allLibModules lib clbi ]
...@@ -193,7 +193,7 @@ installLib ...@@ -193,7 +193,7 @@ installLib
-> Library -> Library
-> ComponentLocalBuildInfo -> ComponentLocalBuildInfo
-> IO () -> IO ()
installLib verbosity lbi targetDir dynlibTargetDir builtDir pkg lib _clbi = do installLib verbosity lbi targetDir dynlibTargetDir builtDir pkg lib clbi = do
let progdb = withPrograms lbi let progdb = withPrograms lbi
runDbProgram verbosity haskellSuitePkgProgram progdb $ runDbProgram verbosity haskellSuitePkgProgram progdb $
[ "install-library" [ "install-library"
...@@ -201,7 +201,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir pkg lib _clbi = do ...@@ -201,7 +201,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir pkg lib _clbi = do
, "--target-dir", targetDir , "--target-dir", targetDir
, "--dynlib-target-dir", dynlibTargetDir , "--dynlib-target-dir", dynlibTargetDir
, "--package-id", display $ packageId pkg , "--package-id", display $ packageId pkg
] ++ map display (libModules lib) ] ++ map display (allLibModules lib clbi)
registerPackage registerPackage
:: Verbosity :: Verbosity
......
...@@ -125,7 +125,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do ...@@ -125,7 +125,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do
writeFileAtomic pfile . BS.Char8.pack $ jhcPkgConf pkg_descr writeFileAtomic pfile . BS.Char8.pack $ jhcPkgConf pkg_descr
runProgram verbosity jhcProg $ runProgram verbosity jhcProg $
["--build-hl="++pfile, "-o", hlfile] ++ ["--build-hl="++pfile, "-o", hlfile] ++
args ++ map display (libModules lib) args ++ map display (allLibModules lib clbi)
-- | Building an executable for JHC. -- | Building an executable for JHC.
-- Currently C source files are not supported. -- Currently C source files are not supported.
......
...@@ -312,7 +312,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do ...@@ -312,7 +312,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do
let ghcArgs = let ghcArgs =
["-package-name", display pkgid ] ["-package-name", display pkgid ]
++ constructGHCCmdLine lbi libBi clbi libTargetDir verbosity ++ constructGHCCmdLine lbi libBi clbi libTargetDir verbosity
++ map display (libModules lib) ++ map display (allLibModules lib clbi)
lhcWrap x = ["--build-library", "--ghc-opts=" ++ unwords x] lhcWrap x = ["--build-library", "--ghc-opts=" ++ unwords x]
ghcArgsProf = ghcArgs ghcArgsProf = ghcArgs
++ ["-prof", ++ ["-prof",
...@@ -326,7 +326,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do ...@@ -326,7 +326,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do
"-osuf", "dyn_o", "-fPIC" "-osuf", "dyn_o", "-fPIC"
] ]
++ hcSharedOptions GHC libBi ++ hcSharedOptions GHC libBi
unless (null (libModules lib)) $ unless (null (allLibModules lib clbi)) $
do ifVanillaLib forceVanillaLib (runGhcProg $ lhcWrap ghcArgs) do ifVanillaLib forceVanillaLib (runGhcProg $ lhcWrap ghcArgs)
ifProfLib (runGhcProg $ lhcWrap ghcArgsProf) ifProfLib (runGhcProg $ lhcWrap ghcArgsProf)
ifSharedLib (runGhcProg $ lhcWrap ghcArgsShared) ifSharedLib (runGhcProg $ lhcWrap ghcArgsShared)
...@@ -354,15 +354,15 @@ buildLib verbosity pkg_descr lbi lib clbi = do ...@@ -354,15 +354,15 @@ buildLib verbosity pkg_descr lbi lib clbi = do
stubObjs <- fmap catMaybes $ sequenceA stubObjs <- fmap catMaybes $ sequenceA
[ findFileWithExtension [objExtension] [libTargetDir] [ findFileWithExtension [objExtension] [libTargetDir]
(ModuleName.toFilePath x ++"_stub") (ModuleName.toFilePath x ++"_stub")
| x <- libModules lib ] | x <- allLibModules lib clbi ]
stubProfObjs <- fmap catMaybes $ sequenceA stubProfObjs <- fmap catMaybes $ sequenceA
[ findFileWithExtension ["p_" ++ objExtension] [libTargetDir] [ findFileWithExtension ["p_" ++ objExtension] [libTargetDir]
(ModuleName.toFilePath x ++"_stub") (ModuleName.toFilePath x ++"_stub")
| x <- libModules lib ] | x <- allLibModules lib clbi ]
stubSharedObjs <- fmap catMaybes $ sequenceA stubSharedObjs <- fmap catMaybes $ sequenceA
[ findFileWithExtension ["dyn_" ++ objExtension] [libTargetDir] [ findFileWithExtension ["dyn_" ++ objExtension] [libTargetDir]
(ModuleName.toFilePath x ++"_stub") (ModuleName.toFilePath x ++"_stub")
| x <- libModules lib ] | x <- allLibModules lib clbi ]
hObjs <- getHaskellObjects lib lbi hObjs <- getHaskellObjects lib lbi
pref objExtension True pref objExtension True
...@@ -540,7 +540,7 @@ getHaskellObjects :: Library -> LocalBuildInfo ...@@ -540,7 +540,7 @@ getHaskellObjects :: Library -> LocalBuildInfo
getHaskellObjects lib lbi pref wanted_obj_ext allow_split_objs getHaskellObjects lib lbi pref wanted_obj_ext allow_split_objs
| splitObjs lbi && allow_split_objs = do | splitObjs lbi && allow_split_objs = do
let dirs = [ pref </> (ModuleName.toFilePath x ++ "_split") let dirs = [ pref </> (ModuleName.toFilePath x ++ "_split")
| x <- libModules lib ] | x <- allLibModules lib clbi ]
objss <- traverse getDirectoryContents dirs objss <- traverse getDirectoryContents dirs
let objs = [ dir </> obj let objs = [ dir </> obj
| (objs',dir) <- zip objss dirs, obj <- objs', | (objs',dir) <- zip objss dirs, obj <- objs',
...@@ -549,7 +549,9 @@ getHaskellObjects lib lbi pref wanted_obj_ext allow_split_objs ...@@ -549,7 +549,9 @@ getHaskellObjects lib lbi pref wanted_obj_ext allow_split_objs
return objs return objs
| otherwise = | otherwise =
return [ pref </> ModuleName.toFilePath x <.> wanted_obj_ext return [ pref </> ModuleName.toFilePath x <.> wanted_obj_ext
| x <- libModules lib ] | x <- allLibModules lib clbi ]
where
clbi = getComponentLocalBuildInfo lbi CLibName
constructGHCCmdLine constructGHCCmdLine
...@@ -717,11 +719,11 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do ...@@ -717,11 +719,11 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
createDirectoryIfMissingVerbose verbosity True dst createDirectoryIfMissingVerbose verbosity True dst
installOrdinaryFile verbosity (src </> n) (dst </> n) installOrdinaryFile verbosity (src </> n) (dst </> n)
copyModuleFiles ext = copyModuleFiles ext =
findModuleFiles [builtDir] [ext] (libModules lib) findModuleFiles [builtDir] [ext] (allLibModules lib clbi)
>>= installOrdinaryFiles verbosity targetDir >>= installOrdinaryFiles verbosity targetDir
ifVanilla $ copyModuleFiles "hi" ifVanilla $ copyModuleFiles "hi"
ifProf $ copyModuleFiles "p_hi" ifProf $ copyModuleFiles "p_hi"
hcrFiles <- findModuleFiles (builtDir : hsSourceDirs (libBuildInfo lib)) ["hcr"] (libModules lib) hcrFiles <- findModuleFiles (builtDir : hsSourceDirs (libBuildInfo lib)) ["hcr"] (allLibModules lib clbi)
flip traverse_ hcrFiles $ \(srcBase, srcFile) -> runLhc ["--install-library", srcBase </> srcFile] flip traverse_ hcrFiles $ \(srcBase, srcFile) -> runLhc ["--install-library", srcBase </> srcFile]
-- copy the built library files over: -- copy the built library files over:
...@@ -738,7 +740,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do ...@@ -738,7 +740,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
ghciLibName = mkGHCiLibName lib_name ghciLibName = mkGHCiLibName lib_name
sharedLibName = mkSharedLibName cid lib_name sharedLibName = mkSharedLibName cid lib_name
hasLib = not $ null (libModules lib) hasLib = not $ null (allLibModules lib clbi)
&& null (cSources (libBuildInfo lib)) && null (cSources (libBuildInfo lib))
ifVanilla = when (hasLib && withVanillaLib lbi) ifVanilla = when (hasLib && withVanillaLib lbi)
ifProf = when (hasLib && withProfLib lbi) ifProf = when (hasLib && withProfLib lbi)
......
...@@ -47,6 +47,7 @@ module Distribution.Simple.LocalBuildInfo ( ...@@ -47,6 +47,7 @@ module Distribution.Simple.LocalBuildInfo (
allComponentsInBuildOrder, allComponentsInBuildOrder,
componentsInBuildOrder, componentsInBuildOrder,
depLibraryPaths, depLibraryPaths,
allLibModules,
withAllComponentsInBuildOrder, withAllComponentsInBuildOrder,
withComponentsInBuildOrder, withComponentsInBuildOrder,
...@@ -82,6 +83,7 @@ import qualified Distribution.Simple.InstallDirs as InstallDirs ...@@ -82,6 +83,7 @@ import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.PackageDescription import Distribution.PackageDescription
import qualified Distribution.InstalledPackageInfo as Installed import qualified Distribution.InstalledPackageInfo as Installed
import Distribution.Package import Distribution.Package
import Distribution.ModuleName
import Distribution.Simple.Compiler import Distribution.Simple.Compiler
import Distribution.Simple.PackageIndex import Distribution.Simple.PackageIndex
import Distribution.Simple.Utils import Distribution.Simple.Utils
...@@ -287,6 +289,11 @@ depLibraryPaths inplace relative lbi clbi = do ...@@ -287,6 +289,11 @@ depLibraryPaths inplace relative lbi clbi = do
then canonicalizePath p then canonicalizePath p
else return p else return p
-- TODO: doc
allLibModules :: Library -> ComponentLocalBuildInfo -> [ModuleName]
allLibModules lib clbi =
explicitLibModules lib
-- TODO: add more stuff
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- Wrappers for a couple functions from InstallDirs -- Wrappers for a couple functions from InstallDirs
......
...@@ -152,7 +152,7 @@ preprocessComponent pd comp lbi clbi isSrcDist verbosity handlers = case comp of ...@@ -152,7 +152,7 @@ preprocessComponent pd comp lbi clbi isSrcDist verbosity handlers = case comp of
let dirs = hsSourceDirs bi ++ [autogenComponentModulesDir lbi clbi let dirs = hsSourceDirs bi ++ [autogenComponentModulesDir lbi clbi
,autogenPackageModulesDir lbi] ,autogenPackageModulesDir lbi]
setupMessage verbosity "Preprocessing library" (packageId pd) setupMessage verbosity "Preprocessing library" (packageId pd)
for_ (map ModuleName.toFilePath $ libModules lib) $ for_ (map ModuleName.toFilePath $ allLibModules lib clbi) $
pre dirs (componentBuildDir lbi clbi) (localHandlers bi) pre dirs (componentBuildDir lbi clbi) (localHandlers bi)
(CExe exe@Executable { buildInfo = bi, exeName = nm }) -> do (CExe exe@Executable { buildInfo = bi, exeName = nm }) -> do
let exeDir = buildDir lbi </> nm </> nm ++ "-tmp" let exeDir = buildDir lbi </> nm </> nm ++ "-tmp"
......
...@@ -433,7 +433,7 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi ...@@ -433,7 +433,7 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
where where
bi = libBuildInfo lib bi = libBuildInfo lib
(absinc, relinc) = partition isAbsolute (includeDirs bi) (absinc, relinc) = partition isAbsolute (includeDirs bi)
hasModules = not $ null (libModules lib) hasModules = not $ null (allLibModules lib clbi)
hasLibrary = hasModules || not (null (cSources bi)) hasLibrary = hasModules || not (null (cSources bi))
|| (not (null (jsSources bi)) && || (not (null (jsSources bi)) &&
compilerFlavor (compiler lbi) == GHCJS) compilerFlavor (compiler lbi) == GHCJS)
......
...@@ -185,7 +185,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do ...@@ -185,7 +185,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do
-- suboptimal: UHC does not understand module names, so -- suboptimal: UHC does not understand module names, so
-- we replace periods by path separators -- we replace periods by path separators
++ map (map (\ c -> if c == '.' then pathSeparator else c)) ++ map (map (\ c -> if c == '.' then pathSeparator else c))
(map display (libModules lib)) (map display (allLibModules lib clbi))
runUhcProg uhcArgs runUhcProg uhcArgs
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
module Distribution.Types.Library ( module Distribution.Types.Library (
Library(..), Library(..),
emptyLibrary, emptyLibrary,
libModules, explicitLibModules,
libModulesAutogen libModulesAutogen
) where ) where
...@@ -54,9 +54,10 @@ emptyLibrary = mempty ...@@ -54,9 +54,10 @@ emptyLibrary = mempty
-- | Get all the module names from the library (exposed and internal modules) -- | Get all the module names from the library (exposed and internal modules)
-- which need to be compiled. (This does not include reexports, which -- which need to be compiled. (This does not include reexports, which
-- do not need to be compiled.) -- do not need to be compiled.) This may not include all modules for which
libModules :: Library -> [ModuleName] -- GHC generated interface files (i.e., implicit modules.)
libModules lib = exposedModules lib explicitLibModules :: Library -> [ModuleName]
explicitLibModules lib = exposedModules lib
++ otherModules (libBuildInfo lib) ++ otherModules (libBuildInfo lib)
++ requiredSignatures lib ++ requiredSignatures lib
......
...@@ -51,7 +51,7 @@ import Distribution.PackageDescription ...@@ -51,7 +51,7 @@ import Distribution.PackageDescription
, Executable(..) , Executable(..)
, TestSuite(..), TestSuiteInterface(..), testModules , TestSuite(..), TestSuiteInterface(..), testModules
, Benchmark(..), BenchmarkInterface(..), benchmarkModules , Benchmark(..), BenchmarkInterface(..), benchmarkModules
, BuildInfo(..), libModules, exeModules ) , BuildInfo(..), explicitLibModules, exeModules )