Skip to content
Snippets Groups Projects
Commit 3fff0977 authored by Matthew Pickering's avatar Matthew Pickering Committed by Marge Bot
Browse files

Don't depend on registerPackage function in Cabal

More recent versions of Cabal modify the behaviour of libAbiHash which
breaks our usage of registerPackage.

It is simpler to inline the part of registerPackage that we need and
avoid any additional dependency and complication using the higher-level
function introduces.
parent 209d09f5
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,7 @@ import qualified Distribution.PackageDescription.Parsec as C ...@@ -31,6 +31,7 @@ import qualified Distribution.PackageDescription.Parsec as C
import qualified Distribution.Simple.Compiler as C import qualified Distribution.Simple.Compiler as C
import qualified Distribution.Simple.Program.Db as C import qualified Distribution.Simple.Program.Db as C
import qualified Distribution.Simple as C import qualified Distribution.Simple as C
import qualified Distribution.Simple.GHC as GHC
import qualified Distribution.Simple.Program.Builtin as C import qualified Distribution.Simple.Program.Builtin as C
import qualified Distribution.Simple.Utils as C import qualified Distribution.Simple.Utils as C
import qualified Distribution.Simple.Program.Types as C import qualified Distribution.Simple.Program.Types as C
...@@ -363,12 +364,11 @@ registerPackage rs context = do ...@@ -363,12 +364,11 @@ registerPackage rs context = do
need [setupConfig] -- This triggers 'configurePackage' need [setupConfig] -- This triggers 'configurePackage'
pd <- packageDescription <$> readContextData context pd <- packageDescription <$> readContextData context
db_path <- packageDbPath (PackageDbLoc (stage context) (iplace context)) db_path <- packageDbPath (PackageDbLoc (stage context) (iplace context))
dist_dir <- Context.buildPath context
pid <- pkgUnitId (stage context) (package context) pid <- pkgUnitId (stage context) (package context)
-- Note: the @cPath@ is ignored. The path that's used is the 'buildDir' path -- Note: the @cPath@ is ignored. The path that's used is the 'buildDir' path
-- from the local build info @lbi@. -- from the local build info @lbi@.
lbi <- liftIO $ C.getPersistBuildConfig cPath lbi <- liftIO $ C.getPersistBuildConfig cPath
liftIO $ register db_path pid dist_dir pd lbi liftIO $ register db_path pid pd lbi
-- Then after the register, which just writes the .conf file, do the recache step. -- Then after the register, which just writes the .conf file, do the recache step.
buildWithResources rs $ buildWithResources rs $
target context (GhcPkg Recache (stage context)) [] [] target context (GhcPkg Recache (stage context)) [] []
...@@ -377,25 +377,23 @@ registerPackage rs context = do ...@@ -377,25 +377,23 @@ registerPackage rs context = do
-- into a different package database to the one it was configured against. -- into a different package database to the one it was configured against.
register :: FilePath register :: FilePath
-> String -- ^ Package Identifier -> String -- ^ Package Identifier
-> FilePath
-> C.PackageDescription -> C.PackageDescription
-> LocalBuildInfo -> LocalBuildInfo
-> IO () -> IO ()
register pkg_db pid build_dir pd lbi register pkg_db pid pd lbi
= withLibLBI pd lbi $ \lib clbi -> do = withLibLBI pd lbi $ \lib clbi -> do
absPackageDBs <- C.absolutePackageDBPaths packageDbs when reloc $ error "register does not support reloc"
installedPkgInfo <- C.generateRegistrationInfo installedPkgInfo <- generateRegistrationInfo pd lbi lib clbi
C.silent pd lib lbi clbi False reloc build_dir
(C.registrationPackageDB absPackageDBs)
writeRegistrationFile installedPkgInfo writeRegistrationFile installedPkgInfo
where where
regFile = pkg_db </> pid <.> "conf" regFile = pkg_db </> pid <.> "conf"
reloc = relocatable lbi reloc = relocatable lbi
-- Using a specific package db here is why we have to copy the function from Cabal.
packageDbs = [C.SpecificPackageDB pkg_db] generateRegistrationInfo pkg lbi lib clbi = do
abi_hash <- C.mkAbiHash <$> GHC.libAbiHash C.silent pkg lbi lib clbi
return (C.absoluteInstalledPackageInfo pkg abi_hash lib lbi clbi)
writeRegistrationFile installedPkgInfo = do writeRegistrationFile installedPkgInfo = do
writeUTF8File regFile (CP.showInstalledPackageInfo installedPkgInfo) writeUTF8File regFile (CP.showInstalledPackageInfo installedPkgInfo)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment