Skip to content

Commit

Permalink
Update installedPkgs with internal deps.
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Z. Yang <[email protected]>
  • Loading branch information
ezyang committed Oct 20, 2016
1 parent 8cac8be commit 0d15ede
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
23 changes: 18 additions & 5 deletions Cabal/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import qualified Distribution.Simple.JHC as JHC
import qualified Distribution.Simple.LHC as LHC
import qualified Distribution.Simple.UHC as UHC
import qualified Distribution.Simple.HaskellSuite as HaskellSuite
import qualified Distribution.Simple.PackageIndex as Index

import qualified Distribution.Simple.Build.Macros as Build.Macros
import qualified Distribution.Simple.Build.PathsModule as Build.PathsModule
Expand All @@ -49,6 +50,7 @@ import qualified Distribution.Simple.Program.HcPkg as HcPkg
import Distribution.Simple.Compiler hiding (Flag)
import Distribution.PackageDescription hiding (Flag)
import qualified Distribution.InstalledPackageInfo as IPI
import Distribution.InstalledPackageInfo (InstalledPackageInfo)
import qualified Distribution.ModuleName as ModuleName

import Distribution.Simple.Setup
Expand All @@ -69,6 +71,7 @@ import Distribution.Verbosity

import Distribution.Compat.Graph (IsNode(..))

import Control.Monad
import qualified Data.Set as Set
import Data.List ( intersect )
import System.FilePath ( (</>), (<.>), takeDirectory )
Expand Down Expand Up @@ -96,18 +99,21 @@ build pkg_descr lbi flags suffixes = do

internalPackageDB <- createInternalPackageDB verbosity lbi distPref

for_ componentsToBuild $ \target -> do
(\f -> foldM_ f (installedPkgs lbi) componentsToBuild) $ \index target -> do
let comp = targetComponent target
clbi = targetCLBI target
initialBuildSteps distPref pkg_descr lbi clbi verbosity
let bi = componentBuildInfo comp
progs' = addInternalBuildTools pkg_descr lbi bi (withPrograms lbi)
lbi' = lbi {
withPrograms = progs',
withPackageDB = withPackageDB lbi ++ [internalPackageDB]
withPackageDB = withPackageDB lbi ++ [internalPackageDB],
installedPkgs = index
}
buildComponent verbosity (buildNumJobs flags) pkg_descr
mb_ipi <- buildComponent verbosity (buildNumJobs flags) pkg_descr
lbi' suffixes comp clbi distPref
return (maybe index (Index.insert `flip` index) mb_ipi)
return ()
where
distPref = fromFlag (buildDistPref flags)
verbosity = fromFlag (buildVerbosity flags)
Expand Down Expand Up @@ -178,7 +184,7 @@ buildComponent :: Verbosity
-> Component
-> ComponentLocalBuildInfo
-> FilePath
-> IO ()
-> IO (Maybe InstalledPackageInfo)
buildComponent verbosity numJobs pkg_descr lbi suffixes
comp@(CLib lib) clbi distPref = do
preprocessComponent pkg_descr comp lbi clbi False verbosity suffixes
Expand All @@ -195,7 +201,8 @@ buildComponent verbosity numJobs pkg_descr lbi suffixes
-- Don't register inplace if we're only building a single component;
-- it's not necessary because there won't be any subsequent builds
-- that need to tag us
when (not (oneComponentRequested (componentEnabledSpec lbi))) $ do
if (not (oneComponentRequested (componentEnabledSpec lbi)))
then do
-- Register the library in-place, so exes can depend
-- on internally defined libraries.
pwd <- getCurrentDirectory
Expand All @@ -206,6 +213,8 @@ buildComponent verbosity numJobs pkg_descr lbi suffixes
debug verbosity $ "Registering inplace:\n" ++ (IPI.showInstalledPackageInfo installedPkgInfo)
registerPackage verbosity (compiler lbi) (withPrograms lbi) HcPkg.MultiInstance
(withPackageDB lbi) installedPkgInfo
return (Just installedPkgInfo)
else return Nothing

buildComponent verbosity numJobs pkg_descr lbi suffixes
comp@(CExe exe) clbi _ = do
Expand All @@ -215,6 +224,7 @@ buildComponent verbosity numJobs pkg_descr lbi suffixes
let ebi = buildInfo exe
exe' = exe { buildInfo = addExtraCSources ebi extras }
buildExe verbosity numJobs pkg_descr lbi exe' clbi
return Nothing


buildComponent verbosity numJobs pkg_descr lbi suffixes
Expand All @@ -227,6 +237,7 @@ buildComponent verbosity numJobs pkg_descr lbi suffixes
let ebi = buildInfo exe
exe' = exe { buildInfo = addExtraCSources ebi extras }
buildExe verbosity numJobs pkg_descr lbi exe' clbi
return Nothing


buildComponent verbosity numJobs pkg_descr lbi0 suffixes
Expand All @@ -253,6 +264,7 @@ buildComponent verbosity numJobs pkg_descr lbi0 suffixes
let ebi = buildInfo exe
exe' = exe { buildInfo = addExtraCSources ebi extras }
buildExe verbosity numJobs pkg_descr lbi exe' exeClbi
return Nothing -- Can't depend on test suite


buildComponent _ _ _ _ _
Expand All @@ -271,6 +283,7 @@ buildComponent verbosity numJobs pkg_descr lbi suffixes
let ebi = buildInfo exe
exe' = exe { buildInfo = addExtraCSources ebi extras }
buildExe verbosity numJobs pkg_descr lbi exe' exeClbi
return Nothing


buildComponent _ _ _ _ _
Expand Down
8 changes: 7 additions & 1 deletion Cabal/Distribution/Types/LocalBuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ data LocalBuildInfo = LocalBuildInfo {
installedPkgs :: InstalledPackageIndex,
-- ^ All the info about the installed packages that the
-- current package depends on (directly or indirectly).
-- Does NOT include internal dependencies.
-- The copy saved on disk does NOT include internal
-- dependencies (because we just don't have enough
-- information at this point to have an
-- 'InstalledPackageInfo' for an internal dep), but we
-- will often update it with the internal dependencies;
-- see for example 'Distribution.Simple.Build.build'.
-- (This admonition doesn't apply for per-component builds.)
pkgDescrFile :: Maybe FilePath,
-- ^ the filename containing the .cabal file, if available
localPkgDescr :: PackageDescription,
Expand Down

0 comments on commit 0d15ede

Please sign in to comment.