diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ghc-cabal/Main.hs | 33 | ||||
-rw-r--r-- | utils/ghc-cabal/ghc.mk | 2 | ||||
-rw-r--r-- | utils/ghctags/Main.hs | 9 |
3 files changed, 27 insertions, 17 deletions
diff --git a/utils/ghc-cabal/Main.hs b/utils/ghc-cabal/Main.hs index 6878afe3bb..3ecae9bbc4 100644 --- a/utils/ghc-cabal/Main.hs +++ b/utils/ghc-cabal/Main.hs @@ -218,18 +218,15 @@ doRegister ghc ghcpkg topdir directory distDir let Just ghcPkgProg = lookupProgram ghcPkgProgram' progs' instInfos <- dump verbosity ghcPkgProg GlobalPackageDB let installedPkgs' = PackageIndex.fromList instInfos - let mlc = libraryConfig lbi - mlc' = case mlc of - Just lc -> - let cipds = componentPackageDeps lc - cipds' = [ (fixupPackageId instInfos ipid, pid) - | (ipid,pid) <- cipds ] - in Just $ lc { - componentPackageDeps = cipds' - } - Nothing -> Nothing + let updateComponentConfig (cn, clbi, deps) + = (cn, updateComponentLocalBuildInfo clbi, deps) + updateComponentLocalBuildInfo (ComponentLocalBuildInfo cpds) + = ComponentLocalBuildInfo + [ (fixupPackageId instInfos ipid, pid) + | (ipid,pid) <- cpds ] + ccs' = map updateComponentConfig (componentsConfigs lbi) lbi' = lbi { - libraryConfig = mlc', + componentsConfigs = ccs', installedPkgs = installedPkgs', installDirTemplates = idts, withPrograms = progs' @@ -309,8 +306,13 @@ generate config_args distdir directory -- generate Paths_<pkg>.hs and cabal-macros.h writeAutogenFiles verbosity pd lbi + let findLibraryConfig [] = Nothing + findLibraryConfig ((CLibName, clbi, _) : _) = Just clbi + findLibraryConfig (_ : xs) = findLibraryConfig xs + mLibraryConfig = findLibraryConfig (componentsConfigs lbi) + -- generate inplace-pkg-config - case (library pd, libraryConfig lbi) of + case (library pd, mLibraryConfig) of (Nothing, Nothing) -> return () (Just lib, Just clbi) -> do cwd <- getCurrentDirectory @@ -323,7 +325,12 @@ generate config_args distdir directory } content = Installed.showInstalledPackageInfo final_ipi ++ "\n" writeFileAtomic (distdir </> "inplace-pkg-config") (BS.pack $ toUTF8 content) - _ -> error "Inconsistent lib components; can't happen?" + (Just _, Nothing) -> + -- There is a library, but we aren't building it + -- Happens e.g. with haddock, which has both a library + -- and executable in its .cabal file. + return () + (Nothing, Just _) -> die ["Library local build info, but no library in package description"] let libBiModules lib = (libBuildInfo lib, libModules lib) diff --git a/utils/ghc-cabal/ghc.mk b/utils/ghc-cabal/ghc.mk index c80c4ef7ef..bb0a35ecd6 100644 --- a/utils/ghc-cabal/ghc.mk +++ b/utils/ghc-cabal/ghc.mk @@ -14,7 +14,7 @@ # Euch, hideous hack: # XXX This should be in a different Makefile -CABAL_DOTTED_VERSION := $(shell grep "^Version:" libraries/Cabal/Cabal/Cabal.cabal | sed "s/^Version: //") +CABAL_DOTTED_VERSION := $(shell grep "^version:" libraries/Cabal/Cabal/Cabal.cabal | sed "s/^version: //") CABAL_VERSION := $(subst .,$(comma),$(CABAL_DOTTED_VERSION)) CABAL_CONSTRAINT := --constraint="Cabal == $(CABAL_DOTTED_VERSION)" diff --git a/utils/ghctags/Main.hs b/utils/ghctags/Main.hs index 514f2998c0..a4cb302c92 100644 --- a/utils/ghctags/Main.hs +++ b/utils/ghctags/Main.hs @@ -18,13 +18,12 @@ import FastString import MonadUtils ( liftIO ) import SrcLoc --- Every GHC comes with Cabal anyways, so this is not a bad new dependency import Distribution.Simple.GHC ( componentGhcOptions ) import Distribution.Simple.Configure ( getPersistBuildConfig ) import Distribution.Simple.Compiler ( compilerVersion ) import Distribution.Simple.Program.GHC ( renderGhcOptions ) import Distribution.PackageDescription ( library, libBuildInfo ) -import Distribution.Simple.LocalBuildInfo ( localPkgDescr, buildDir, libraryConfig, compiler ) +import Distribution.Simple.LocalBuildInfo import qualified Distribution.Verbosity as V import Control.Monad hiding (mapM) @@ -183,7 +182,11 @@ flagsFromCabal :: FilePath -> IO [String] flagsFromCabal distPref = do lbi <- getPersistBuildConfig distPref let pd = localPkgDescr lbi - case (library pd, libraryConfig lbi) of + findLibraryConfig [] = Nothing + findLibraryConfig ((CLibName, clbi, _) : _) = Just clbi + findLibraryConfig (_ : xs) = findLibraryConfig xs + mLibraryConfig = findLibraryConfig (componentsConfigs lbi) + case (library pd, mLibraryConfig) of (Just lib, Just clbi) -> let bi = libBuildInfo lib odir = buildDir lbi |