Skip to content

Commit

Permalink
Change the inplace package database to not use file-style database.
Browse files Browse the repository at this point in the history
Instead we use HcPkg.init (e.g. ghc-pkg init). For ghc-pkg this will
create a new directory style db.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Duncan Coutts <duncan@well-typed.com>
  • Loading branch information
ezyang committed Jan 4, 2015
1 parent f89ddfd commit b14a493
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Cabal/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import qualified Distribution.InstalledPackageInfo as IPI
import qualified Distribution.ModuleName as ModuleName
import Distribution.ModuleName (ModuleName)

import Distribution.Simple.Program (ghcPkgProgram)
import Distribution.Simple.Setup
( BuildFlags(..), ReplFlags(..), fromFlag )
import Distribution.Simple.BuildTarget
Expand All @@ -91,6 +92,7 @@ import Distribution.Simple.LocalBuildInfo
, inplacePackageId, LibraryName(..) )
import Distribution.Simple.Program.Types
import Distribution.Simple.Program.Db
import qualified Distribution.Simple.Program.HcPkg as HcPkg
import Distribution.Simple.BuildPaths
( autogenModulesDir, autogenModuleName, cppHeaderName, exeExtension )
import Distribution.Simple.Register
Expand All @@ -116,7 +118,7 @@ import Control.Monad
import System.FilePath
( (</>), (<.>) )
import System.Directory
( getCurrentDirectory )
( getCurrentDirectory, removeDirectoryRecursive, doesDirectoryExist )

-- -----------------------------------------------------------------------------
-- |Build the libraries and executables in this package.
Expand All @@ -141,7 +143,8 @@ build pkg_descr lbi flags suffixes = do
-- Only bother with this message if we're building the whole package
setupMessage verbosity "Building" (packageId pkg_descr)

internalPackageDB <- createInternalPackageDB distPref
let Just ghcPkgProg = lookupProgram ghcPkgProgram (withPrograms lbi)
internalPackageDB <- createInternalPackageDB verbosity ghcPkgProg distPref

withComponentsInBuildOrder pkg_descr lbi componentsToBuild $ \comp clbi ->
let bi = componentBuildInfo comp
Expand Down Expand Up @@ -177,7 +180,8 @@ repl pkg_descr lbi flags suffixes args = do

initialBuildSteps distPref pkg_descr lbi verbosity

internalPackageDB <- createInternalPackageDB distPref
let Just ghcPkgProg = lookupProgram ghcPkgProgram (withPrograms lbi)
internalPackageDB <- createInternalPackageDB verbosity ghcPkgProg distPref
let lbiForComponent comp lbi' =
lbi' {
withPackageDB = withPackageDB lbi ++ [internalPackageDB],
Expand Down Expand Up @@ -435,11 +439,13 @@ benchmarkExeV10asExe Benchmark{} _ = error "benchmarkExeV10asExe: wrong kind"

-- | Initialize a new package db file for libraries defined
-- internally to the package.
createInternalPackageDB :: FilePath -> IO PackageDB
createInternalPackageDB distPref = do
let dbFile = distPref </> "package.conf.inplace"
packageDB = SpecificPackageDB dbFile
writeFile dbFile "[]"
createInternalPackageDB :: Verbosity -> ConfiguredProgram -> FilePath -> IO PackageDB
createInternalPackageDB verbosity ghcPkgProg distPref = do
let dbDir = distPref </> "package.conf.inplace"
packageDB = SpecificPackageDB dbDir
exists <- doesDirectoryExist dbDir
when exists $ removeDirectoryRecursive dbDir
HcPkg.init verbosity ghcPkgProg dbDir
return packageDB

addInternalBuildTools :: PackageDescription -> LocalBuildInfo -> BuildInfo
Expand Down

0 comments on commit b14a493

Please sign in to comment.