From 859a576bd0325d66f5ea02ced6be9217bffa3ffd Mon Sep 17 00:00:00 2001 From: Christiaan Baaij <christiaan.baaij@gmail.com> Date: Mon, 24 Nov 2014 15:38:08 +0100 Subject: [PATCH] Enable registration of relocatable packages --- Cabal/Distribution/Simple/Register.hs | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Cabal/Distribution/Simple/Register.hs b/Cabal/Distribution/Simple/Register.hs index 819afbeb3a..d7a121e52d 100644 --- a/Cabal/Distribution/Simple/Register.hs +++ b/Cabal/Distribution/Simple/Register.hs @@ -98,8 +98,9 @@ register :: PackageDescription -> LocalBuildInfo register pkg@PackageDescription { library = Just lib } lbi regFlags = do let clbi = getComponentLocalBuildInfo lbi CLibName + installedPkgInfo <- generateRegistrationInfo - verbosity pkg lib lbi clbi inplace distPref + verbosity pkg lib lbi clbi inplace reloc distPref when (fromFlag (regPrintId regFlags)) $ do putStrLn (display (IPI.installedPackageId installedPkgInfo)) @@ -119,6 +120,7 @@ register pkg@PackageDescription { library = Just lib } lbi regFlags modeGenerateRegScript = fromFlag (regGenScript regFlags) inplace = fromFlag (regInPlace regFlags) + reloc = relocatable lbi -- FIXME: there's really no guarantee this will work. -- registering into a totally different db stack can -- fail if dependencies cannot be satisfied. @@ -152,9 +154,10 @@ generateRegistrationInfo :: Verbosity -> LocalBuildInfo -> ComponentLocalBuildInfo -> Bool + -> Bool -> FilePath -> IO InstalledPackageInfo -generateRegistrationInfo verbosity pkg lib lbi clbi inplace distPref = do +generateRegistrationInfo verbosity pkg lib lbi clbi inplace reloc distPref = do --TODO: eliminate pwd! pwd <- getCurrentDirectory @@ -172,6 +175,8 @@ generateRegistrationInfo verbosity pkg lib lbi clbi inplace distPref = do let installedPkgInfo | inplace = inplaceInstalledPackageInfo pwd distPref pkg ipid lib lbi clbi + | reloc = relocatableInstalledPackageInfo + pkg ipid lib lbi clbi | otherwise = absoluteInstalledPackageInfo pkg ipid lib lbi clbi @@ -372,6 +377,32 @@ absoluteInstalledPackageInfo pkg ipid lib lbi clbi = bi = libBuildInfo lib installDirs = absoluteInstallDirs pkg lbi NoCopyDest + +relocatableInstalledPackageInfo :: PackageDescription + -> InstalledPackageId + -> Library + -> LocalBuildInfo + -> ComponentLocalBuildInfo + -> InstalledPackageInfo +relocatableInstalledPackageInfo pkg ipid lib lbi clbi = + generalInstalledPackageInfo adjustReativeIncludeDirs + pkg ipid lib lbi clbi installDirs + where + -- For installed packages we install all include files into one dir, + -- whereas in the build tree they may live in multiple local dirs. + adjustReativeIncludeDirs _ + | null (installIncludes bi) = [] + | otherwise = [includedir installDirs] + bi = libBuildInfo lib + installDirs = + (absoluteInstallDirs pkg lbi NoCopyDest) { + libdir = "${pkgroot}" </> display (pkgKey lbi), + haddockdir = "${pkgroot}" </> "share" </> "doc" </> "ghc" </> "html" </> + "libraries" </> display (package pkg), + htmldir = "${pkgrooturl}/../share/doc/ghc/html/libraries/" ++ + display (package pkg) + } + -- ----------------------------------------------------------------------------- -- Unregistration -- GitLab