Permalink
Browse files

Add an 'initPackageDB' function to D.S.Register.

Creates an empty package DB at the specified location.
  • Loading branch information...
1 parent 1cc6878 commit 3de1049b34e38375d4c6785e0bacc74980118589 @23Skidoo 23Skidoo committed Aug 15, 2012
Showing with 20 additions and 4 deletions.
  1. +7 −1 Cabal/Distribution/Simple/GHC.hs
  2. +13 −3 Cabal/Distribution/Simple/Register.hs
View
8 Cabal/Distribution/Simple/GHC.hs
@@ -65,6 +65,7 @@ module Distribution.Simple.GHC (
buildLib, buildExe,
installLib, installExe,
libAbiHash,
+ initPackageDB,
registerPackage,
componentGhcOptions,
ghcLibDir,
@@ -1105,10 +1106,15 @@ updateLibArchive verbosity lbi path
rawSystemProgram verbosity ranlib [path]
| otherwise = return ()
-
-- -----------------------------------------------------------------------------
-- Registering
+-- | Create an empty package DB at the specified location.
+initPackageDB :: Verbosity -> ProgramConfiguration -> FilePath -> IO ()
+initPackageDB verbosity conf dbPath = HcPkg.init verbosity ghcPkgProg dbPath
+ where
+ Just ghcPkgProg = lookupProgram ghcPkgProgram conf
+
registerPackage
:: Verbosity
-> InstalledPackageInfo
View
16 Cabal/Distribution/Simple/Register.hs
@@ -57,6 +57,7 @@ module Distribution.Simple.Register (
register,
unregister,
+ initPackageDB,
registerPackage,
generateRegistrationInfo,
inplaceInstalledPackageInfo,
@@ -73,11 +74,12 @@ import qualified Distribution.Simple.LHC as LHC
import qualified Distribution.Simple.Hugs as Hugs
import qualified Distribution.Simple.UHC as UHC
import Distribution.Simple.Compiler
- ( compilerVersion, CompilerFlavor(..), compilerFlavor
+ ( compilerVersion, Compiler, CompilerFlavor(..), compilerFlavor
, PackageDBStack, registrationPackageDB )
import Distribution.Simple.Program
- ( ConfiguredProgram, runProgramInvocation
- , requireProgram, lookupProgram, ghcPkgProgram, lhcPkgProgram )
+ ( ProgramConfiguration, ConfiguredProgram
+ , runProgramInvocation, requireProgram, lookupProgram
+ , ghcPkgProgram, lhcPkgProgram )
import Distribution.Simple.Program.Script
( invocationAsSystemScript )
import qualified Distribution.Simple.Program.HcPkg as HcPkg
@@ -204,6 +206,14 @@ generateRegistrationInfo verbosity pkg lib lbi clbi inplace distPref = do
return installedPkgInfo{ IPI.installedPackageId = ipid }
+-- | Create an empty package DB at the specified location.
+initPackageDB :: Verbosity -> Compiler -> ProgramConfiguration -> FilePath
+ -> IO ()
+initPackageDB verbosity comp conf dbPath =
+ case (compilerFlavor comp) of
+ GHC -> GHC.initPackageDB verbosity conf dbPath
+ _ -> die "initPackageDB is not implemented for this compiler"
+
registerPackage :: Verbosity
-> InstalledPackageInfo
-> PackageDescription

0 comments on commit 3de1049

Please sign in to comment.