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

Don't pass LocalBuildInfo to per-compiler registerPackage functions

Rather, pass the individual bits we need, which is the program db
and in some cases the compiler. This is a step towards having the main
registerPackage not take the LocalBuildInfo. That is useful in contexts
like cabal-install where we do not have a full LocalBuildInfo, but we
still want to be able to register packages in a compiler-agnostic way.
parent 27dd76a0
......@@ -1128,12 +1128,12 @@ hcPkgInfo conf = HcPkg.HcPkgInfo { HcPkg.hcPkgProgram = ghcPkgProg
registerPackage
:: Verbosity
-> InstalledPackageInfo
-> LocalBuildInfo
-> ProgramConfiguration
-> PackageDBStack
-> InstalledPackageInfo
-> IO ()
registerPackage verbosity installedPkgInfo lbi packageDbs =
HcPkg.reregister (hcPkgInfo $ withPrograms lbi) verbosity
registerPackage verbosity progdb packageDbs installedPkgInfo =
HcPkg.reregister (hcPkgInfo progdb) verbosity
packageDbs (Right installedPkgInfo)
pkgRoot :: Verbosity -> LocalBuildInfo -> PackageDB -> IO FilePath
......
......@@ -822,12 +822,12 @@ adjustExts hiSuf objSuf opts =
}
registerPackage :: Verbosity
-> InstalledPackageInfo
-> LocalBuildInfo
-> ProgramConfiguration
-> PackageDBStack
-> InstalledPackageInfo
-> IO ()
registerPackage verbosity installedPkgInfo lbi packageDbs =
HcPkg.reregister (hcPkgInfo $ withPrograms lbi) verbosity packageDbs
registerPackage verbosity progdb packageDbs installedPkgInfo =
HcPkg.reregister (hcPkgInfo progdb) verbosity packageDbs
(Right installedPkgInfo)
componentGhcOptions :: Verbosity -> LocalBuildInfo
......
......@@ -200,12 +200,12 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir pkg lib _clbi = do
registerPackage
:: Verbosity
-> InstalledPackageInfo
-> LocalBuildInfo
-> ProgramConfiguration
-> PackageDBStack
-> InstalledPackageInfo
-> IO ()
registerPackage verbosity installedPkgInfo lbi packageDbs = do
(hspkg, _) <- requireProgram verbosity haskellSuitePkgProgram (withPrograms lbi)
registerPackage verbosity progdb packageDbs installedPkgInfo = do
(hspkg, _) <- requireProgram verbosity haskellSuitePkgProgram progdb
runProgramInvocation verbosity $
(programInvocation hspkg
......
......@@ -774,12 +774,12 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
registerPackage
:: Verbosity
-> InstalledPackageInfo
-> LocalBuildInfo
-> ProgramConfiguration
-> PackageDBStack
-> InstalledPackageInfo
-> IO ()
registerPackage verbosity installedPkgInfo lbi packageDbs =
HcPkg.reregister (hcPkgInfo $ withPrograms lbi) verbosity packageDbs
registerPackage verbosity progdb packageDbs installedPkgInfo =
HcPkg.reregister (hcPkgInfo progdb) verbosity packageDbs
(Right installedPkgInfo)
hcPkgInfo :: ProgramConfiguration -> HcPkg.HcPkgInfo
......
......@@ -243,15 +243,18 @@ registerPackage :: Verbosity
-> PackageDBStack
-> IO ()
registerPackage verbosity installedPkgInfo _pkg lbi _inplace packageDbs = do
case compilerFlavor (compiler lbi) of
GHC -> GHC.registerPackage verbosity installedPkgInfo lbi packageDbs
GHCJS -> GHCJS.registerPackage verbosity installedPkgInfo lbi packageDbs
LHC -> LHC.registerPackage verbosity installedPkgInfo lbi packageDbs
UHC -> UHC.registerPackage verbosity installedPkgInfo lbi packageDbs
case compilerFlavor comp of
GHC -> GHC.registerPackage verbosity progdb packageDbs installedPkgInfo
GHCJS -> GHCJS.registerPackage verbosity progdb packageDbs installedPkgInfo
LHC -> LHC.registerPackage verbosity progdb packageDbs installedPkgInfo
UHC -> UHC.registerPackage verbosity comp progdb packageDbs installedPkgInfo
JHC -> notice verbosity "Registering for jhc (nothing to do)"
HaskellSuite {} ->
HaskellSuite.registerPackage verbosity installedPkgInfo lbi packageDbs
HaskellSuite.registerPackage verbosity progdb packageDbs installedPkgInfo
_ -> die "Registering is not implemented for this compiler"
where
comp = compiler lbi
progdb = withPrograms lbi
writeHcPkgRegisterScript :: Verbosity
-> InstalledPackageInfo
......
......@@ -264,13 +264,14 @@ uhcPackageSubDir compilerid = compilerid </> uhcTarget </> uhcTargetVarian
registerPackage
:: Verbosity
-> InstalledPackageInfo
-> LocalBuildInfo
-> Compiler
-> ProgramConfiguration
-> PackageDBStack
-> InstalledPackageInfo
-> IO ()
registerPackage verbosity installedPkgInfo lbi packageDbs = do
registerPackage verbosity comp progdb packageDbs installedPkgInfo = do
dbdir <- case last packageDbs of
GlobalPackageDB -> getGlobalPackageDir verbosity (withPrograms lbi)
GlobalPackageDB -> getGlobalPackageDir verbosity progdb
UserPackageDB -> getUserPackageDir
SpecificPackageDB dir -> return dir
let pkgdir = dbdir </> uhcPackageDir (display pkgid) (display compilerid)
......@@ -279,4 +280,4 @@ registerPackage verbosity installedPkgInfo lbi packageDbs = do
(showInstalledPackageInfo installedPkgInfo)
where
pkgid = sourcePackageId installedPkgInfo
compilerid = compilerId (compiler lbi)
compilerid = compilerId comp
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