Commit 15e0e717 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Remove instantiated-with and related support work.



Backpack is going to have to rewrite this functionality.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 94e59da8
......@@ -77,7 +77,6 @@ data InstalledPackageInfo
abiHash :: AbiHash,
exposed :: Bool,
exposedModules :: [ExposedModule],
installedInstantiatedWith :: [(ModuleName, OriginalModule)],
hiddenModules :: [ModuleName],
trusted :: Bool,
importDirs :: [FilePath],
......@@ -130,7 +129,6 @@ emptyInstalledPackageInfo
exposed = False,
exposedModules = [],
hiddenModules = [],
installedInstantiatedWith = [],
trusted = False,
importDirs = [],
libraryDirs = [],
......@@ -229,14 +227,6 @@ parseInstalledPackageInfo =
parseFieldsFlat (fieldsInstalledPackageInfo ++ deprecatedFieldDescrs)
emptyInstalledPackageInfo
parseInstantiatedWith :: Parse.ReadP r (ModuleName, OriginalModule)
parseInstantiatedWith = do k <- parse
_ <- Parse.char '='
n <- parse
_ <- Parse.char '@'
p <- parse
return (k, OriginalModule p n)
-- -----------------------------------------------------------------------------
-- Pretty-printing
......@@ -249,9 +239,6 @@ showInstalledPackageInfoField = showSingleNamedField fieldsInstalledPackageInfo
showSimpleInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String)
showSimpleInstalledPackageInfoField = showSimpleSingleNamedField fieldsInstalledPackageInfo
showInstantiatedWith :: (ModuleName, OriginalModule) -> Doc
showInstantiatedWith (k, OriginalModule p m) = disp k <> text "=" <> disp m <> text "@" <> disp p
-- -----------------------------------------------------------------------------
-- Description of the fields, for parsing/printing
......@@ -317,9 +304,6 @@ installedFieldDescrs = [
, simpleField "abi"
disp parse
abiHash (\abi pkg -> pkg{abiHash=abi})
, listField "instantiated-with"
showInstantiatedWith parseInstantiatedWith
installedInstantiatedWith (\xs pkg -> pkg{installedInstantiatedWith=xs})
, boolField "trusted"
trusted (\val pkg -> pkg{trusted=val})
, listField "import-dirs"
......
......@@ -391,11 +391,6 @@ configure (pkg_descr0, pbi) cfg = do
checkPackageProblems verbosity pkg_descr0
(updatePackageDescription pbi pkg_descr)
-- Handle hole instantiation
-- TODO: Totally unclear if this belongs here
(holeDeps, hole_insts)
<- configureInstantiateWith pkg_descr cfg installedPackageSet
-- The list of 'InstalledPackageInfo' recording the selected
-- dependencies...
-- internalPkgDeps: ...on internal packages (these are fake!)
......@@ -421,7 +416,7 @@ configure (pkg_descr0, pbi) cfg = do
let installDeps = Map.elems -- deduplicate
. Map.fromList
. map (\v -> (Installed.installedComponentId v, v))
$ externalPkgDeps ++ holeDeps
$ externalPkgDeps
packageDependsIndex <-
case PackageIndex.dependencyClosure installedPackageSet
......@@ -507,8 +502,7 @@ configure (pkg_descr0, pbi) cfg = do
Left componentCycle -> reportComponentCycle componentCycle
Right comps ->
mkComponentsLocalBuildInfo cfg comp packageDependsIndex pkg_descr
internalPkgDeps externalPkgDeps holeDeps
(Map.fromList hole_insts)
internalPkgDeps externalPkgDeps
comps (configConfigurationsFlags cfg)
split_objs <-
......@@ -611,7 +605,6 @@ configure (pkg_descr0, pbi) cfg = do
installedPkgs = packageDependsIndex,
pkgDescrFile = Nothing,
localPkgDescr = pkg_descr',
instantiatedWith = hole_insts,
withPrograms = programsConfig'',
withVanillaLib = fromFlag $ configVanillaLib cfg,
withProfLib = profEnabledLib,
......@@ -1153,58 +1146,6 @@ combinedConstraints constraints dependencies installedPackages = do
<> quotes (disp pkgname <> char '=' <> disp ipkgid)
| (pkgname, ipkgid) <- deps ]
-- -----------------------------------------------------------------------------
-- Configuring hole instantiation
configureInstantiateWith :: PackageDescription
-> ConfigFlags
-> InstalledPackageIndex -- ^ installed packages
-> IO ([InstalledPackageInfo],
[(ModuleName, (InstalledPackageInfo, ModuleName))])
configureInstantiateWith pkg_descr cfg installedPackageSet = do
-- Holes: First, check and make sure the provided instantiation covers
-- all the holes we know about. Indefinite package installation is
-- not handled at all at this point.
-- NB: We union together /all/ of the requirements when calculating
-- the package key.
-- NB: For now, we assume that dependencies don't contribute signatures.
-- This will be handled by cabal-install; as far as ./Setup is
-- concerned, the most important thing is to be provided correctly
-- built dependencies.
let signatures =
maybe [] (\lib -> requiredSignatures lib ++ exposedSignatures lib)
(PD.library pkg_descr)
signatureSet = Set.fromList signatures
instantiateMap = Map.fromList (configInstantiateWith cfg)
missing_impls = filter (not . flip Map.member instantiateMap) signatures
hole_insts0 = filter (\(k,_) -> Set.member k signatureSet) (configInstantiateWith cfg)
when (not (null missing_impls)) $
die $ "Missing signature implementations for these modules: "
++ intercalate ", " (map display missing_impls)
-- Holes: Next, we need to make sure we have packages to actually
-- provide the implementations we're talking about. This is on top
-- of the normal dependency resolution process.
-- TODO: internal dependencies (e.g. the test package depending on the
-- main library) is not currently supported
let selectHoleDependency (k,(i,m)) =
case PackageIndex.lookupComponentId installedPackageSet i of
Just pkginst -> Right (k,(pkginst, m))
Nothing -> Left i
(failed_hmap, hole_insts) = partitionEithers (map selectHoleDependency hole_insts0)
holeDeps = map (fst.snd) hole_insts -- could have dups
-- Holes: Finally, any dependencies selected this way have to be
-- included in the allPkgs index, as well as the buildComponents.
-- But don't report these as potential inconsistencies!
when (not (null failed_hmap)) $
die $ "Could not resolve these package IDs (from signature implementations): "
++ intercalate ", " (map display failed_hmap)
return (holeDeps, hole_insts)
-- -----------------------------------------------------------------------------
-- Configuring program dependencies
......@@ -1563,14 +1504,12 @@ mkComponentsLocalBuildInfo :: ConfigFlags
-> PackageDescription
-> [PackageId] -- internal package deps
-> [InstalledPackageInfo] -- external package deps
-> [InstalledPackageInfo] -- hole package deps
-> Map ModuleName (InstalledPackageInfo, ModuleName)
-> [(Component, [ComponentName])]
-> FlagAssignment
-> IO [(ComponentName, ComponentLocalBuildInfo,
[ComponentName])]
mkComponentsLocalBuildInfo cfg comp installedPackages pkg_descr
internalPkgDeps externalPkgDeps holePkgDeps hole_insts
internalPkgDeps externalPkgDeps
graph flagAssignment = do
-- Pre-compute library hash so we can setup internal deps
-- TODO configIPID should have name changed
......@@ -1607,11 +1546,6 @@ mkComponentsLocalBuildInfo cfg comp installedPackages pkg_descr
CLib lib -> do
let exports = map (\n -> Installed.ExposedModule n Nothing Nothing)
(PD.exposedModules lib)
esigs = map (\n -> Installed.ExposedModule n Nothing
(fmap (\(pkg,m) -> Installed.OriginalModule
(Installed.installedComponentId pkg) m)
(Map.lookup n hole_insts)))
(PD.exposedSignatures lib)
let mb_reexports = resolveModuleReexports installedPackages
(packageId pkg_descr)
cid
......@@ -1625,7 +1559,7 @@ mkComponentsLocalBuildInfo cfg comp installedPackages pkg_descr
componentId = cid,
componentCompatPackageKey = compat_key,
componentPackageRenaming = cprns,
componentExposedModules = exports ++ reexports ++ esigs
componentExposedModules = exports ++ reexports
}
CExe _ ->
return ExeComponentLocalBuildInfo {
......@@ -1654,13 +1588,7 @@ mkComponentsLocalBuildInfo cfg comp installedPackages pkg_descr
else [ (Installed.installedComponentId pkg, packageId pkg)
| pkg <- externalPkgDeps ]
cprns = if newPackageDepsBehaviour pkg_descr
then Map.unionWith mappend
-- We need hole dependencies passed to GHC, so add them here
-- (but note that they're fully thinned out. If they
-- appeared legitimately the monoid instance will
-- fill them out.
(Map.fromList [(packageName pkg, mempty) | pkg <- holePkgDeps])
(targetBuildRenaming bi)
then targetBuildRenaming bi
-- Hack: if we have old package-deps behavior, it's impossible
-- for non-default renamings to be used, because the Cabal
-- version is too early. This is a good, because while all the
......
......@@ -86,7 +86,6 @@ toCurrent ipi@InstalledPackageInfo{} =
Current.exposed = exposed ipi,
Current.exposedModules = map (mkExposedModule . convertModuleName) (exposedModules ipi),
Current.hiddenModules = map convertModuleName (hiddenModules ipi),
Current.installedInstantiatedWith = [],
Current.trusted = Current.trusted Current.emptyInstalledPackageInfo,
Current.importDirs = importDirs ipi,
Current.libraryDirs = libraryDirs ipi,
......
......@@ -361,7 +361,6 @@ componentGhcOptions verbosity lbi bi clbi odir =
LibComponentLocalBuildInfo { componentCompatPackageKey = pk }
-> toFlag pk
_ -> Mon.mempty,
ghcOptSigOf = hole_insts,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptPackages = toNubListR $ mkGhcOptPackages clbi,
ghcOptSplitObjs = toFlag (splitObjs lbi),
......@@ -397,10 +396,6 @@ componentGhcOptions verbosity lbi bi clbi odir =
toGhcDebugInfo NormalDebugInfo = toFlag True
toGhcDebugInfo MaximalDebugInfo = toFlag True
hole_insts = map (\(k,(p,n))
-> (k, (InstalledPackageInfo.installedComponentId p,n)))
(instantiatedWith lbi)
-- | Strip out flags that are not supported in ghci
filterGhciFlags :: [String] -> [String]
filterGhciFlags = filter supported
......
......@@ -286,8 +286,6 @@ 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.installedComponentId p,n)))
(instantiatedWith lbi)
nativeToo = ghcjsNativeToo comp
(ghcjsProg, _) <- requireProgram verbosity ghcjsProgram (withPrograms lbi)
......@@ -323,7 +321,6 @@ buildOrReplLib forRepl verbosity numJobs _pkg_descr lbi lib clbi = do
vanillaOptsNoJsLib = baseOpts `mappend` mempty {
ghcOptMode = toFlag GhcModeMake,
ghcOptNumJobs = numJobs,
ghcOptSigOf = hole_insts,
ghcOptInputModules = toNubListR $ libModules lib,
ghcOptHPCDir = hpcdir Hpc.Vanilla
}
......
......@@ -118,7 +118,6 @@ data LocalBuildInfo = LocalBuildInfo {
localPkgDescr :: PackageDescription,
-- ^ The resolved package description, that does not contain
-- any conditionals.
instantiatedWith :: [(ModuleName, (InstalledPackageInfo, ModuleName))],
withPrograms :: ProgramConfiguration, -- ^Location and args for all programs
withPackageDB :: PackageDBStack, -- ^What package database to use, global\/user
withVanillaLib:: Bool, -- ^Whether to build normal libs.
......
......@@ -90,9 +90,6 @@ data GhcOptions = GhcOptions {
-- -no-auto-link-packages@ flag.
ghcOptNoAutoLinkPackages :: Flag Bool,
-- | What packages are implementing the signatures
ghcOptSigOf :: [(ModuleName, (ComponentId, ModuleName))],
-----------------
-- Linker stuff
......@@ -382,15 +379,6 @@ renderGhcOptions comp opts
, packageDbArgs implInfo (ghcOptPackageDBs opts)
, if null (ghcOptSigOf opts)
then []
else "-sig-of"
: intercalate "," (map (\(n,(p,m)) -> display n ++ " is "
++ display p ++ ":"
++ display m)
(ghcOptSigOf opts))
: []
, concat $ if flagPackageId implInfo
then let space "" = ""
space xs = ' ' : xs
......@@ -504,7 +492,6 @@ instance Monoid GhcOptions where
ghcOptPackages = mempty,
ghcOptHideAllPackages = mempty,
ghcOptNoAutoLinkPackages = mempty,
ghcOptSigOf = mempty,
ghcOptLinkLibs = mempty,
ghcOptLinkLibPath = mempty,
ghcOptLinkOptions = mempty,
......@@ -561,7 +548,6 @@ instance Semigroup GhcOptions where
ghcOptPackages = combine ghcOptPackages,
ghcOptHideAllPackages = combine ghcOptHideAllPackages,
ghcOptNoAutoLinkPackages = combine ghcOptNoAutoLinkPackages,
ghcOptSigOf = combine ghcOptSigOf,
ghcOptLinkLibs = combine ghcOptLinkLibs,
ghcOptLinkLibPath = combine ghcOptLinkLibPath,
ghcOptLinkOptions = combine ghcOptLinkOptions,
......
......@@ -319,9 +319,6 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
IPI.exposed = libExposed lib,
IPI.exposedModules = componentExposedModules clbi,
IPI.hiddenModules = otherModules bi,
IPI.installedInstantiatedWith = map (\(k,(p,n)) ->
(k,IPI.OriginalModule (IPI.installedComponentId p) n))
(instantiatedWith lbi),
IPI.trusted = IPI.trusted IPI.emptyInstalledPackageInfo,
IPI.importDirs = [ libdir installDirs | hasModules ],
-- Note. the libsubdir and datasubdir templates have already been expanded
......
......@@ -308,7 +308,6 @@ data ConfigFlags = ConfigFlags {
configConstraints :: [Dependency], -- ^Additional constraints for
-- dependencies.
configDependencies :: [(PackageName, ComponentId)],
configInstantiateWith :: [(ModuleName, (ComponentId, ModuleName))],
-- ^The packages depended on.
configConfigurationsFlags :: FlagAssignment,
configTests :: Flag Bool, -- ^Enable test suite compilation
......@@ -589,13 +588,6 @@ configureOptions showOrParseArgs =
(readP_to_E (const "dependency expected") ((\x -> [x]) `fmap` parseDependency))
(map (\x -> display (fst x) ++ "=" ++ display (snd x))))
,option "" ["instantiate-with"]
"A mapping of signature names to concrete module instantiations. E.g., --instantiate-with=\"Map=Data.Map.Strict@containers-0.5.5.1-inplace\""
configInstantiateWith (\v flags -> flags { configInstantiateWith = v })
(reqArg "NAME=PKG:MOD"
(readP_to_E (const "signature mapping expected") ((\x -> [x]) `fmap` parseHoleMapEntry))
(map (\(n,(p,m)) -> display n ++ "=" ++ display m ++ "@" ++ display p)))
,option "" ["tests"]
"dependency checking and compilation for test suites listed in the package description file."
configTests (\v flags -> flags { configTests = v })
......@@ -669,15 +661,6 @@ parseDependency = do
y <- parse
return (x, y)
parseHoleMapEntry :: Parse.ReadP r (ModuleName, (ComponentId, ModuleName))
parseHoleMapEntry = do
x <- parse
_ <- Parse.char '='
y <- parse
_ <- Parse.char '@'
z <- parse
return (x, (z, y))
installDirsOptions :: [OptionField (InstallDirs (Flag PathTemplate))]
installDirsOptions =
[ option "" ["prefix"]
......@@ -777,7 +760,6 @@ instance Monoid ConfigFlags where
configExtraLibDirs = mempty,
configConstraints = mempty,
configDependencies = mempty,
configInstantiateWith = mempty,
configExtraIncludeDirs = mempty,
configIPID = mempty,
configConfigurationsFlags = mempty,
......@@ -826,7 +808,6 @@ instance Semigroup ConfigFlags where
configExtraLibDirs = combine configExtraLibDirs,
configConstraints = combine configConstraints,
configDependencies = combine configDependencies,
configInstantiateWith = combine configInstantiateWith,
configExtraIncludeDirs = combine configExtraIncludeDirs,
configIPID = combine configIPID,
configConfigurationsFlags = combine configConfigurationsFlags,
......
......@@ -309,7 +309,6 @@ instance Monoid SavedConfig where
configConstraints = lastNonEmpty configConstraints,
-- TODO: NubListify
configDependencies = lastNonEmpty configDependencies,
configInstantiateWith = lastNonEmpty configInstantiateWith,
-- TODO: NubListify
configConfigurationsFlags = lastNonEmpty configConfigurationsFlags,
configTests = combine configTests,
......
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