Commit b083151f authored by Edward Z. Yang's avatar Edward Z. Yang

Implement ComponentId, replacing PackageKey and InstalledPackageId.

Today in Cabal, when you build and install a package, it is
uniquely identified using an InstalledPackageId which is computed
using the ABI hash of the library that was installed.  There
are few problems with doing it this way:

    - In a Nix-like world, we should instead uniquely identify
      build products by some sort of hash on the inputs to the
      compilation (source files, dependencies, flags).  The ABI
      hash doesn't capture any of this!

    - An InstalledPackageId suggests that we can uniquely identify
      build products by hashing the source and dependencies of
      a package as a whole.  But Cabal packages contain many components:
      a library, test suite, executables, etc.  Currently, when
      we say InstalledPackageId, we are really just talking about
      the dependencies of the library; however, this is unacceptable
      if a Cabal package can install multiple libraries; we need
      different identifiers for each.

    - We've also needed to compute another ID, which we've called
      the "package key", which is to be used for linker symbols
      and type equality GHC-side.  It is confusing what the distinction
      between this ID and InstalledPackageIds are; the main reason
      we needed another ID was because the package key was needed
      prior to compilation, whereas the ABI hash was only available
      afterwards.

This patch replaces InstalledPackageId and PackageKey with a
new identifier called ComponentId, which has the following
properties:

    - It is computed per-component, and consists of a package
      name, package version, hash of the ComponentIds
      of the dependencies it is built against, and the name
      of the component.  For example, "foo-0.1-abcdef" continues
      to identify the library of package foo-0.1, but
      "foo-0.1-123455-foo.exe" would identify the executable,
      and "foo-0.1-abcdef-bar" would identify a private sub-library
      named bar.

    - It is passed to GHC to be used for linker symbols and
      type equality.  So as far as GHC is concerned, this is
      the end-all be-all identifier.

    - Cabal the library has a simple, default routine for computing
      a ComponentId which DOES NOT hash source code;
      in a later patch Duncan is working on, cabal-install can
      specify a more detailed ComponentId for a package
      to be built with.

Here are some knock-on effects:

    - 'id' is a ComponentId

    - 'depends' is now a list of ComponentIds

    - New 'abi' field to record what the ABI of a unit is (as it is no longer
      computed by looking at the output of ghc --abi-hash).

    - The 'HasInstalledPackageId' typeclass is renamed to
      'HasComponentId'.

    - GHC 7.10 has explicit compatibility handling with
      a 'compatPackageKey' (an 'ComponentId') which is
      in a compatible format.  The value of this is read out
      from the 'key' field.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 40b28559
......@@ -120,6 +120,10 @@ extra-source-files:
tests/PackageTests/TestSuiteTests/LibV09/LibV09.cabal
tests/PackageTests/TestSuiteTests/LibV09/Lib.hs
tests/PackageTests/TestSuiteTests/LibV09/tests/Deadlock.hs
tests/PackageTests/UniqueIPID/P1/M.hs
tests/PackageTests/UniqueIPID/P1/my.cabal
tests/PackageTests/UniqueIPID/P2/M.hs
tests/PackageTests/UniqueIPID/P2/my.cabal
tests/Setup.hs
tests/Test/Distribution/Version.hs
tests/Test/Laws.hs
......@@ -316,6 +320,7 @@ test-suite package-tests
PackageTests.TestStanza.Check
PackageTests.TestSuiteTests.ExeV10.Check
PackageTests.TestSuiteTests.LibV09.Check
PackageTests.UniqueIPID.Check
Test.Distribution.Version
Test.Laws
Test.QuickCheck.Utils
......
......@@ -27,8 +27,8 @@
-- This module is meant to be local-only to Distribution...
module Distribution.InstalledPackageInfo (
AbiHash(..),
InstalledPackageInfo(..),
libraryName,
OriginalModule(..), ExposedModule(..),
ParseResult(..), PError(..), PWarning,
emptyInstalledPackageInfo,
......@@ -50,9 +50,8 @@ import Distribution.ParseUtils
import Distribution.License ( License(..) )
import Distribution.Package
( PackageName(..), PackageIdentifier(..)
, PackageId, InstalledPackageId(..)
, packageName, packageVersion, PackageKey(..)
, LibraryName(..) )
, PackageId, ComponentId(..)
, packageName, packageVersion, ComponentId(..) )
import qualified Distribution.Package as Package
import Distribution.ModuleName
( ModuleName )
......@@ -66,17 +65,19 @@ import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.Binary (Binary)
import Data.Maybe (fromMaybe)
import GHC.Generics (Generic)
import qualified Data.Char as Char
-- -----------------------------------------------------------------------------
-- The InstalledPackageInfo type
-- For BC reasons, we continue to name this record an InstalledPackageInfo;
-- but it would more accurately be called an InstalledUnitInfo with Backpack
data InstalledPackageInfo
= InstalledPackageInfo {
-- these parts are exactly the same as PackageDescription
installedPackageId :: InstalledPackageId,
sourcePackageId :: PackageId,
packageKey :: PackageKey,
installedComponentId:: ComponentId,
compatPackageKey :: ComponentId,
license :: License,
copyright :: String,
maintainer :: String,
......@@ -88,6 +89,7 @@ data InstalledPackageInfo
description :: String,
category :: String,
-- these parts are required by an installed package only:
abiHash :: AbiHash,
exposed :: Bool,
exposedModules :: [ExposedModule],
instantiatedWith :: [(ModuleName, OriginalModule)],
......@@ -101,7 +103,7 @@ data InstalledPackageInfo
extraGHCiLibraries:: [String], -- overrides extraLibraries for GHCi
includeDirs :: [FilePath],
includes :: [String],
depends :: [InstalledPackageId],
depends :: [ComponentId],
ccOptions :: [String],
ldOptions :: [String],
frameworkDirs :: [FilePath],
......@@ -112,16 +114,13 @@ data InstalledPackageInfo
}
deriving (Generic, Read, Show)
libraryName :: InstalledPackageInfo -> LibraryName
libraryName ipi = Package.packageKeyLibraryName (sourcePackageId ipi) (packageKey ipi)
instance Binary InstalledPackageInfo
instance Package.Package InstalledPackageInfo where
packageId = sourcePackageId
instance Package.HasInstalledPackageId InstalledPackageInfo where
installedPackageId = installedPackageId
instance Package.HasComponentId InstalledPackageInfo where
installedComponentId = installedComponentId
instance Package.PackageInstalled InstalledPackageInfo where
installedDepends = depends
......@@ -129,10 +128,9 @@ instance Package.PackageInstalled InstalledPackageInfo where
emptyInstalledPackageInfo :: InstalledPackageInfo
emptyInstalledPackageInfo
= InstalledPackageInfo {
installedPackageId = InstalledPackageId "",
sourcePackageId = PackageIdentifier (PackageName "") noVersion,
packageKey = OldPackageKey (PackageIdentifier
(PackageName "") noVersion),
installedComponentId = ComponentId "",
compatPackageKey = ComponentId "",
license = UnspecifiedLicense,
copyright = "",
maintainer = "",
......@@ -143,6 +141,7 @@ emptyInstalledPackageInfo
synopsis = "",
description = "",
category = "",
abiHash = AbiHash "",
exposed = False,
exposedModules = [],
hiddenModules = [],
......@@ -172,9 +171,20 @@ noVersion = Version [] []
-- -----------------------------------------------------------------------------
-- Exposed modules
newtype AbiHash = AbiHash String
deriving (Show, Read, Generic)
instance Binary AbiHash
instance Text AbiHash where
disp (AbiHash abi) = Disp.text abi
parse = fmap AbiHash (Parse.munch Char.isAlphaNum)
-- -----------------------------------------------------------------------------
-- Exposed modules
data OriginalModule
= OriginalModule {
originalPackageId :: InstalledPackageId,
originalPackageId :: ComponentId,
originalModuleName :: ModuleName
}
deriving (Generic, Eq, Read, Show)
......@@ -287,10 +297,10 @@ basicFieldDescrs =
packageVersion (\ver pkg -> pkg{sourcePackageId=(sourcePackageId pkg){pkgVersion=ver}})
, simpleField "id"
disp parse
installedPackageId (\ipid pkg -> pkg{installedPackageId=ipid})
installedComponentId (\pk pkg -> pkg{installedComponentId=pk})
, simpleField "key"
disp parse
packageKey (\pk pkg -> pkg{packageKey=pk})
compatPackageKey (\pk pkg -> pkg{compatPackageKey=pk})
, simpleField "license"
disp parseLicenseQ
license (\l pkg -> pkg{license=l})
......@@ -333,6 +343,9 @@ installedFieldDescrs = [
, listField "hidden-modules"
disp parseModuleNameQ
hiddenModules (\xs pkg -> pkg{hiddenModules=xs})
, simpleField "abi"
disp parse
abiHash (\abi pkg -> pkg{abiHash=abi})
, listField "instantiated-with"
showInstantiatedWith parseInstantiatedWith
instantiatedWith (\xs pkg -> pkg{instantiatedWith=xs})
......
This diff is collapsed.
......@@ -24,7 +24,6 @@ import Distribution.Simple.InstallDirs
( fromPathTemplate, initialPathTemplateEnv, PathTemplateVariable(..)
, substPathTemplate , toPathTemplate, PathTemplate )
import qualified Distribution.Simple.LocalBuildInfo as LBI
( LocalBuildInfo(..), localLibraryName )
import Distribution.Simple.Setup ( BenchmarkFlags(..), fromFlag )
import Distribution.Simple.UserHooks ( Args )
import Distribution.Simple.Utils ( die, notice, rawSystemExitCode )
......@@ -123,6 +122,6 @@ benchOption pkg_descr lbi bm template =
fromPathTemplate $ substPathTemplate env template
where
env = initialPathTemplateEnv
(PD.package pkg_descr) (LBI.localLibraryName lbi)
(PD.package pkg_descr) (LBI.localComponentId lbi)
(compilerInfo $ LBI.compiler lbi) (LBI.hostPlatform lbi) ++
[(BenchmarkNameVar, toPathTemplate $ PD.benchmarkName bm)]
......@@ -35,8 +35,8 @@ import qualified Distribution.Simple.Build.PathsModule as Build.PathsModule
import Distribution.Package
( Package(..), PackageName(..), PackageIdentifier(..)
, Dependency(..), thisPackageVersion, PackageKey(..), packageName
, LibraryName(..) )
, Dependency(..), thisPackageVersion, packageName
, ComponentId(..), ComponentId(..) )
import Distribution.Simple.Compiler
( Compiler, CompilerFlavor(..), compilerFlavor
, PackageDB(..), PackageDBStack )
......@@ -60,8 +60,7 @@ import Distribution.Simple.LocalBuildInfo
, ComponentLocalBuildInfo(..), pkgEnabledComponents
, withComponentsInBuildOrder, componentsInBuildOrder
, ComponentName(..), showComponentName
, ComponentDisabledReason(..), componentDisabledReason
, inplacePackageId )
, ComponentDisabledReason(..), componentDisabledReason )
import Distribution.Simple.Program.Types
import Distribution.Simple.Program.Db
import qualified Distribution.Simple.Program.HcPkg as HcPkg
......@@ -207,9 +206,8 @@ buildComponent verbosity numJobs pkg_descr lbi suffixes
-- on internally defined libraries.
pwd <- getCurrentDirectory
let -- The in place registration uses the "-inplace" suffix, not an ABI hash
ipkgid = inplacePackageId (packageId installedPkgInfo)
installedPkgInfo = inplaceInstalledPackageInfo pwd distPref pkg_descr
ipkgid lib' lbi clbi
(IPI.AbiHash "") lib' lbi clbi
registerPackage verbosity
installedPkgInfo pkg_descr lbi True -- True meaning in place
......@@ -407,9 +405,9 @@ testSuiteLibV09AsLibAndExe pkg_descr
libClbi = LibComponentLocalBuildInfo
{ componentPackageDeps = componentPackageDeps clbi
, componentPackageRenaming = componentPackageRenaming clbi
, componentLibraryName = LibraryName (testName test)
, componentId = ComponentId $ display (packageId pkg)
, componentCompatPackageKey = ComponentId $ display (packageId pkg)
, componentExposedModules = [IPI.ExposedModule m Nothing Nothing]
, componentPackageKey = OldPackageKey (PackageIdentifier (PackageName (testName test)) (pkgVersion (package pkg_descr)))
}
pkg = pkg_descr {
package = (package pkg_descr) {
......@@ -420,8 +418,7 @@ testSuiteLibV09AsLibAndExe pkg_descr
, testSuites = []
, library = Just lib
}
ipkgid = inplacePackageId (packageId pkg)
ipi = inplaceInstalledPackageInfo pwd distPref pkg ipkgid lib lbi libClbi
ipi = inplaceInstalledPackageInfo pwd distPref pkg (IPI.AbiHash "") lib lbi libClbi
testDir = buildDir lbi </> stubName test
</> stubName test ++ "-tmp"
testLibDep = thisPackageVersion $ package pkg
......@@ -441,7 +438,7 @@ testSuiteLibV09AsLibAndExe pkg_descr
-- that exposes the relevant test suite library.
exeClbi = ExeComponentLocalBuildInfo {
componentPackageDeps =
(IPI.installedPackageId ipi, packageId ipi)
(IPI.installedComponentId ipi, packageId ipi)
: (filter (\(_, x) -> let PackageName name = pkgName x
in name == "Cabal" || name == "base")
(componentPackageDeps clbi)),
......
......@@ -33,7 +33,7 @@ import Distribution.PackageDescription
import Distribution.Simple.Compiler
( packageKeySupported )
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(compiler, withPrograms), externalPackageDeps, localPackageKey )
( LocalBuildInfo(compiler, withPrograms), externalPackageDeps, localComponentId )
import Distribution.Simple.Program.Db
( configuredPrograms )
import Distribution.Simple.Program.Types
......@@ -52,7 +52,7 @@ generate _pkg_descr lbi =
"/* DO NOT EDIT: This file is automatically generated by Cabal */\n\n" ++
generatePackageVersionMacros (map snd (externalPackageDeps lbi)) ++
generateToolVersionMacros (configuredPrograms . withPrograms $ lbi) ++
generatePackageKeyMacro lbi
generateComponentIdMacro lbi
-- | Helper function that generates just the @VERSION_pkg@ and @MIN_VERSION_pkg@
-- macros for a list of package ids (usually used with the specific deps of
......@@ -99,10 +99,10 @@ generateMacros prefix name version =
-- | Generate the @CURRENT_PACKAGE_KEY@ definition for the package key
-- of the current package, if supported by the compiler.
-- NB: this only makes sense for definite packages.
generatePackageKeyMacro :: LocalBuildInfo -> String
generatePackageKeyMacro lbi
generateComponentIdMacro :: LocalBuildInfo -> String
generateComponentIdMacro lbi
| packageKeySupported (compiler lbi) =
"#define CURRENT_PACKAGE_KEY \"" ++ display (localPackageKey lbi) ++ "\"\n\n"
"#define CURRENT_PACKAGE_KEY \"" ++ display (localComponentId lbi) ++ "\"\n\n"
| otherwise = ""
fixchar :: Char -> Char
......
......@@ -27,9 +27,6 @@ import Distribution.Package
import Distribution.PackageDescription
( PackageDescription(..), hasLibs )
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(..), InstallDirs(..)
, absoluteInstallDirs, prefixRelativeInstallDirs )
import Distribution.Simple.Setup ( CopyDest(NoCopyDest) )
import Distribution.Simple.BuildPaths
( autogenModuleName )
import Distribution.Simple.Utils
......
......@@ -34,7 +34,7 @@ module Distribution.Simple.BuildPaths (
import System.FilePath ((</>), (<.>))
import Distribution.Package
( packageName, LibraryName, getHSLibraryName )
( packageName, getHSLibraryName, ComponentId )
import Distribution.ModuleName (ModuleName)
import qualified Distribution.ModuleName as ModuleName
import Distribution.Compiler
......@@ -81,16 +81,16 @@ haddockName pkg_descr = display (packageName pkg_descr) <.> "haddock"
-- ---------------------------------------------------------------------------
-- Library file names
mkLibName :: LibraryName -> String
mkLibName :: ComponentId -> String
mkLibName lib = "lib" ++ getHSLibraryName lib <.> "a"
mkProfLibName :: LibraryName -> String
mkProfLibName :: ComponentId -> String
mkProfLibName lib = "lib" ++ getHSLibraryName lib ++ "_p" <.> "a"
-- Implement proper name mangling for dynamical shared objects
-- libHS<packagename>-<compilerFlavour><compilerVersion>
-- e.g. libHSbase-2.1-ghc6.6.1.so
mkSharedLibName :: CompilerId -> LibraryName -> String
mkSharedLibName :: CompilerId -> ComponentId -> String
mkSharedLibName (CompilerId compilerFlavor compilerVersion) lib
= "lib" ++ getHSLibraryName lib ++ "-" ++ comp <.> dllExtension
where comp = display compilerFlavor ++ display compilerVersion
......
......@@ -53,6 +53,7 @@ module Distribution.Simple.Compiler (
parmakeSupported,
reexportedModulesSupported,
renamingPackageFlagsSupported,
unifiedIPIDRequired,
packageKeySupported,
-- * Support for profiling detail levels
......@@ -276,6 +277,10 @@ reexportedModulesSupported = ghcSupported "Support reexported-modules"
renamingPackageFlagsSupported :: Compiler -> Bool
renamingPackageFlagsSupported = ghcSupported "Support thinning and renaming package flags"
-- | Does this compiler have unified IPIDs (so no package keys)
unifiedIPIDRequired :: Compiler -> Bool
unifiedIPIDRequired = ghcSupported "Requires unified installed package IDs"
-- | Does this compiler support package keys?
packageKeySupported :: Compiler -> Bool
packageKeySupported = ghcSupported "Uses package keys"
......
This diff is collapsed.
......@@ -428,7 +428,7 @@ buildOrReplLib :: Bool -> Verbosity -> Cabal.Flag (Maybe Int)
-> PackageDescription -> LocalBuildInfo
-> Library -> ComponentLocalBuildInfo -> IO ()
buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
let libName = componentLibraryName clbi
let libName = componentId clbi
libTargetDir = buildDir lbi
whenVanillaLib forceVanilla =
when (forceVanilla || withVanillaLib lbi)
......@@ -1090,7 +1090,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
>>= installOrdinaryFiles verbosity targetDir
cid = compilerId (compiler lbi)
libName = componentLibraryName clbi
libName = componentId clbi
vanillaLibName = mkLibName libName
profileLibName = mkProfLibName libName
ghciLibName = Internal.mkGHCiLibName libName
......
......@@ -14,7 +14,7 @@ module Distribution.Simple.GHC.IPI641 (
) where
import qualified Distribution.InstalledPackageInfo as Current
import qualified Distribution.Package as Current hiding (installedPackageId)
import qualified Distribution.Package as Current hiding (installedComponentId)
import Distribution.Text (display)
import Distribution.Simple.GHC.IPI642
......@@ -61,17 +61,17 @@ data InstalledPackageInfo = InstalledPackageInfo {
}
deriving Read
mkInstalledPackageId :: Current.PackageIdentifier -> Current.InstalledPackageId
mkInstalledPackageId = Current.InstalledPackageId . display
mkComponentId :: Current.PackageIdentifier -> Current.ComponentId
mkComponentId = Current.ComponentId . display
toCurrent :: InstalledPackageInfo -> Current.InstalledPackageInfo
toCurrent ipi@InstalledPackageInfo{} =
let pid = convertPackageId (package ipi)
mkExposedModule m = Current.ExposedModule m Nothing Nothing
in Current.InstalledPackageInfo {
Current.installedPackageId = mkInstalledPackageId (convertPackageId (package ipi)),
Current.sourcePackageId = pid,
Current.packageKey = Current.OldPackageKey pid,
Current.installedComponentId = mkComponentId pid,
Current.compatPackageKey = mkComponentId pid,
Current.license = convertLicense (license ipi),
Current.copyright = copyright ipi,
Current.maintainer = maintainer ipi,
......@@ -82,6 +82,7 @@ toCurrent ipi@InstalledPackageInfo{} =
Current.synopsis = "",
Current.description = description ipi,
Current.category = category ipi,
Current.abiHash = Current.AbiHash "",
Current.exposed = exposed ipi,
Current.exposedModules = map (mkExposedModule . convertModuleName) (exposedModules ipi),
Current.instantiatedWith = [],
......@@ -95,7 +96,7 @@ toCurrent ipi@InstalledPackageInfo{} =
Current.extraGHCiLibraries = [],
Current.includeDirs = includeDirs ipi,
Current.includes = includes ipi,
Current.depends = map (mkInstalledPackageId.convertPackageId) (depends ipi),
Current.depends = map (mkComponentId.convertPackageId) (depends ipi),
Current.ccOptions = ccOptions ipi,
Current.ldOptions = ldOptions ipi,
Current.frameworkDirs = frameworkDirs ipi,
......
......@@ -19,7 +19,7 @@ module Distribution.Simple.GHC.IPI642 (
) where
import qualified Distribution.InstalledPackageInfo as Current
import qualified Distribution.Package as Current hiding (installedPackageId)
import qualified Distribution.Package as Current hiding (installedComponentId)
import qualified Distribution.License as Current
import Distribution.Version (Version)
......@@ -84,8 +84,8 @@ convertPackageId :: PackageIdentifier -> Current.PackageIdentifier
convertPackageId PackageIdentifier { pkgName = n, pkgVersion = v } =
Current.PackageIdentifier (Current.PackageName n) v
mkInstalledPackageId :: Current.PackageIdentifier -> Current.InstalledPackageId
mkInstalledPackageId = Current.InstalledPackageId . display
mkComponentId :: Current.PackageIdentifier -> Current.ComponentId
mkComponentId = Current.ComponentId . display
convertModuleName :: String -> ModuleName
convertModuleName s = fromJust $ simpleParse s
......@@ -104,9 +104,10 @@ toCurrent ipi@InstalledPackageInfo{} =
let pid = convertPackageId (package ipi)
mkExposedModule m = Current.ExposedModule m Nothing Nothing
in Current.InstalledPackageInfo {
Current.installedPackageId = mkInstalledPackageId (convertPackageId (package ipi)),
Current.sourcePackageId = pid,
Current.packageKey = Current.OldPackageKey pid,
Current.installedComponentId = mkComponentId pid,
Current.compatPackageKey = mkComponentId pid,
Current.abiHash = Current.AbiHash "", -- bogus but old GHCs don't care.
Current.license = convertLicense (license ipi),
Current.copyright = copyright ipi,
Current.maintainer = maintainer ipi,
......@@ -130,7 +131,7 @@ toCurrent ipi@InstalledPackageInfo{} =
Current.extraGHCiLibraries = extraGHCiLibraries ipi,
Current.includeDirs = includeDirs ipi,
Current.includes = includes ipi,
Current.depends = map (mkInstalledPackageId.convertPackageId) (depends ipi),
Current.depends = map (mkComponentId.convertPackageId) (depends ipi),
Current.ccOptions = ccOptions ipi,
Current.ldOptions = ldOptions ipi,
Current.frameworkDirs = frameworkDirs ipi,
......
......@@ -31,8 +31,7 @@ module Distribution.Simple.GHC.Internal (
import Distribution.Simple.GHC.ImplInfo ( GhcImplInfo (..) )
import Distribution.Package
( InstalledPackageId, PackageId, LibraryName
, getHSLibraryName )
( PackageId, ComponentId, getHSLibraryName )
import Distribution.InstalledPackageInfo
( InstalledPackageInfo )
import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo
......@@ -374,8 +373,8 @@ componentGhcOptions verbosity lbi bi clbi odir =
ghcOptVerbosity = toFlag verbosity,
ghcOptHideAllPackages = toFlag True,
ghcOptCabal = toFlag True,
ghcOptPackageKey = case clbi of
LibComponentLocalBuildInfo { componentPackageKey = pk } -> toFlag pk
ghcOptComponentId = case clbi of
LibComponentLocalBuildInfo { componentCompatPackageKey = pk } -> toFlag pk
_ -> mempty,
ghcOptSigOf = hole_insts,
ghcOptPackageDBs = withPackageDB lbi,
......@@ -413,7 +412,7 @@ componentGhcOptions verbosity lbi bi clbi odir =
toGhcDebugInfo NormalDebugInfo = toFlag True
toGhcDebugInfo MaximalDebugInfo = toFlag True
hole_insts = map (\(k,(p,n)) -> (k, (InstalledPackageInfo.packageKey p,n)))
hole_insts = map (\(k,(p,n)) -> (k, (InstalledPackageInfo.installedComponentId p,n)))
(instantiatedWith lbi)
-- | Strip out flags that are not supported in ghci
......@@ -429,7 +428,7 @@ filterGhciFlags = filter supported
supported "-unreg" = False
supported _ = True
mkGHCiLibName :: LibraryName -> String
mkGHCiLibName :: ComponentId -> String
mkGHCiLibName lib = getHSLibraryName lib <.> "o"
ghcLookupProperty :: String -> Compiler -> Bool
......@@ -460,7 +459,7 @@ getHaskellObjects implInfo lib lbi pref wanted_obj_ext allow_split_objs
| x <- libModules lib ]
mkGhcOptPackages :: ComponentLocalBuildInfo
-> [(InstalledPackageId, PackageId, ModuleRenaming)]
-> [(ComponentId, PackageId, ModuleRenaming)]
mkGhcOptPackages clbi =
map (\(i,p) -> (i,p,lookupRenaming p (componentPackageRenaming clbi)))
(componentPackageDeps clbi)
......
......@@ -26,7 +26,7 @@ import Distribution.InstalledPackageInfo
( InstalledPackageInfo )
import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo
( InstalledPackageInfo(..) )
import Distribution.Package ( LibraryName(..), getHSLibraryName )
import Distribution.Package ( ComponentId(..), getHSLibraryName )
import Distribution.Simple.PackageIndex ( InstalledPackageIndex )
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.LocalBuildInfo
......@@ -301,7 +301,7 @@ buildOrReplLib :: Bool -> Verbosity -> Cabal.Flag (Maybe Int)
-> PackageDescription -> LocalBuildInfo
-> Library -> ComponentLocalBuildInfo -> IO ()
buildOrReplLib forRepl verbosity numJobs _pkg_descr lbi lib clbi = do
let libName@(LibraryName cname) = componentLibraryName clbi
let libName@(ComponentId cname) = componentId clbi
libTargetDir = buildDir lbi
whenVanillaLib forceVanilla =
when (not forRepl && (forceVanilla || withVanillaLib lbi))
......@@ -312,7 +312,7 @@ buildOrReplLib forRepl verbosity numJobs _pkg_descr lbi lib clbi = do
ifReplLib = when forRepl
comp = compiler lbi
implInfo = getImplInfo comp
hole_insts = map (\(k,(p,n)) -> (k,(InstalledPackageInfo.packageKey p,n)))
hole_insts = map (\(k,(p,n)) -> (k,(InstalledPackageInfo.installedComponentId p,n)))
(instantiatedWith lbi)
nativeToo = ghcjsNativeToo comp
......@@ -756,7 +756,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
>>= installOrdinaryFiles verbosity targetDir
cid = compilerId (compiler lbi)
libName = componentLibraryName clbi
libName = componentId clbi
vanillaLibName = mkLibName libName
profileLibName = mkProfLibName libName
ghciLibName = Internal.mkGHCiLibName libName
......
......@@ -27,7 +27,7 @@ import qualified Distribution.Simple.GHCJS as GHCJS
import Distribution.Package
( PackageIdentifier(..)
, Package(..)
, PackageName(..), packageName, LibraryName(..) )
, PackageName(..), packageName, ComponentId(..) )
import qualified Distribution.ModuleName as ModuleName
import Distribution.PackageDescription as PD
( PackageDescription(..), BuildInfo(..), usedExtensions
......@@ -631,7 +631,7 @@ haddockPackageFlags lbi clbi htmlTemplate = do
haddockTemplateEnv :: LocalBuildInfo -> PackageIdentifier -> PathTemplateEnv
haddockTemplateEnv lbi pkg_id =
(PrefixVar, prefix (installDirTemplates lbi))
: initialPathTemplateEnv pkg_id (LibraryName (display pkg_id)) (compilerInfo (compiler lbi))
: initialPathTemplateEnv pkg_id (ComponentId (display pkg_id)) (compilerInfo (compiler lbi))
(hostPlatform lbi)
-- ------------------------------------------------------------------------------
......
......@@ -190,8 +190,9 @@ installLib
-> FilePath -- ^Build location
-> PackageDescription
-> Library
-> ComponentLocalBuildInfo
-> IO ()
installLib verbosity lbi targetDir dynlibTargetDir builtDir pkg lib = do
installLib verbosity lbi targetDir dynlibTargetDir builtDir pkg lib _clbi = do
let conf = withPrograms lbi
runDbProgram verbosity haskellSuitePkgProgram conf $
[ "install-library"
......
......@@ -16,13 +16,9 @@ module Distribution.Simple.Install (
install,
) where
import Distribution.PackageDescription (
PackageDescription(..), BuildInfo(..), Library(..),
hasLibs, withLib, hasExes, withExe )
import Distribution.PackageDescription
import Distribution.Package (Package(..))
import Distribution.Simple.LocalBuildInfo (
LocalBuildInfo(..), InstallDirs(..), absoluteInstallDirs,
substPathTemplate, withLibLBI)
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.BuildPaths (haddockName, haddockPref)
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose
......@@ -69,6 +65,8 @@ install pkg_descr lbi flags = do
htmldir = htmlPref,
haddockdir = interfacePref,
includedir = incPref})
-- Using the library clbi for binPref is a hack;
-- binPref should be computed per executable
= absoluteInstallDirs pkg_descr lbi copydest
--TODO: decide if we need the user to be able to control the libdir
......@@ -126,32 +124,33 @@ install pkg_descr lbi flags = do
-- install include files for all compilers - they may be needed to compile
-- haskell files (using the CPP extension)
--
when (hasLibs pkg_descr) $ installIncludeFiles verbosity pkg_descr incPref
case compilerFlavor (compiler lbi) of
GHC -> do withLibLBI pkg_descr lbi $
GHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
withExe pkg_descr $
GHC.installExe verbosity lbi installDirs buildPref (progPrefixPref, progSuffixPref) pkg_descr
GHCJS-> do withLibLBI pkg_descr lbi $
GHCJS.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
withExe pkg_descr $
GHCJS.installExe verbosity lbi installDirs buildPref (progPrefixPref, progSuffixPref) pkg_descr
LHC -> do withLibLBI pkg_descr lbi $
LHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
withExe pkg_descr $
LHC.installExe verbosity lbi installDirs buildPref (progPrefixPref, progSuffixPref) pkg_descr
JHC -> do withLib pkg_descr $
JHC.installLib verbosity libPref buildPref pkg_descr
withExe pkg_descr $
JHC.installExe verbosity binPref buildPref (progPrefixPref, progSuffixPref) pkg_descr
UHC -> do withLib pkg_descr $ UHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr