Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Other enhancements:
* Check for duplicate local package names
* Stop nagging people that call `stack test` [#845](https://github.com/commercialhaskell/stack/issues/845)
* `--file-watch` will ignore files that are in your VCS boring/ignore files [#703](https://github.com/commercialhaskell/stack/issues/703)
* Adapt to upcoming Cabal installed package identifier format change [#851](https://github.com/commercialhaskell/stack/issues/851)

Bug fixes:

Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Build/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ flagCacheFile :: (MonadIO m, MonadThrow m, MonadReader env m, HasEnvConfig env)
flagCacheFile installed = do
rel <- parseRelFile $
case installed of
Library gid -> ghcPkgIdString gid
Library _ gid -> ghcPkgIdString gid
Executable ident -> packageIdentifierString ident
dir <- flagCacheLocal
return $ dir </> rel
Expand Down
35 changes: 18 additions & 17 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ constructPlan :: forall env m.
-> BaseConfigOpts
-> [LocalPackage]
-> Set PackageName -- ^ additional packages that must be built
-> Set GhcPkgId -- ^ locally registered
-> Map GhcPkgId PackageIdentifier -- ^ locally registered
-> (PackageName -> Version -> Map FlagName Bool -> IO Package) -- ^ load upstream package
-> SourceMap
-> InstalledMap
Expand Down Expand Up @@ -192,19 +192,20 @@ constructPlan mbp0 baseConfigOpts0 locals extraToBuild0 locallyRegistered loadPa
-- already registered local packages
mkUnregisterLocal :: Map PackageName Task
-> Map PackageName Text
-> Set GhcPkgId
-> Map GhcPkgId Text
-> Map GhcPkgId PackageIdentifier
-> Map GhcPkgId (PackageIdentifier, Text)
mkUnregisterLocal tasks dirtyReason locallyRegistered =
Map.unions $ map toUnregisterMap $ Set.toList locallyRegistered
Map.unions $ map toUnregisterMap $ Map.toList locallyRegistered
where
toUnregisterMap gid =
toUnregisterMap (gid, ident) =
case M.lookup name tasks of
Nothing -> Map.empty
Just _ -> Map.singleton gid
$ fromMaybe "likely unregistering due to a version change"
$ Map.lookup name dirtyReason
( ident
, fromMaybe "likely unregistering due to a version change"
$ Map.lookup name dirtyReason
)
where
ident = ghcPkgIdPackageIdentifier gid
name = packageIdentifierName ident

addFinal :: LocalPackage -> LocalPackageTB -> M ()
Expand All @@ -219,7 +220,7 @@ addFinal lp lptb = do
(packageName package)
(packageVersion package)
, taskConfigOpts = TaskConfigOpts missing $ \missing' ->
let allDeps = Set.union present missing'
let allDeps = Map.union present missing'
in configureOpts
(getEnvConfig ctx)
(baseConfigOpts ctx)
Expand Down Expand Up @@ -335,7 +336,7 @@ installPackage treatAsDep name ps = do
(packageName package)
(packageVersion package)
, taskConfigOpts = TaskConfigOpts missing $ \missing' ->
let allDeps = Set.union present missing'
let allDeps = Map.union present missing'
destLoc = piiLocation ps <> minLoc
in configureOpts
(getEnvConfig ctx)
Expand Down Expand Up @@ -372,7 +373,7 @@ checkNeedInstall treatAsDep name ps installed wanted = assert (piiLocation ps ==
return True

addPackageDeps :: Bool -- ^ is this being used by a dependency?
-> Package -> M (Either ConstructPlanException (Set PackageIdentifier, Set GhcPkgId, InstallLocation))
-> Package -> M (Either ConstructPlanException (Set PackageIdentifier, Map PackageIdentifier GhcPkgId, InstallLocation))
addPackageDeps treatAsDep package = do
ctx <- ask
deps' <- packageDepsWithTools package
Expand All @@ -389,11 +390,11 @@ addPackageDeps treatAsDep package = do
Right adr | not $ adrVersion adr `withinRange` range ->
return $ Left (depname, (range, mlatest, DependencyMismatch $ adrVersion adr))
Right (ADRToInstall task) -> return $ Right
(Set.singleton $ taskProvides task, Set.empty, taskLocation task)
(Set.singleton $ taskProvides task, Map.empty, taskLocation task)
Right (ADRFound loc _ (Executable _)) -> return $ Right
(Set.empty, Set.empty, loc)
Right (ADRFound loc _ (Library gid)) -> return $ Right
(Set.empty, Set.singleton gid, loc)
(Set.empty, Map.empty, loc)
Right (ADRFound loc _ (Library ident gid)) -> return $ Right
(Set.empty, Map.singleton ident gid, loc)
case partitionEithers deps of
([], pairs) -> return $ Right $ mconcat pairs
(errs, _) -> return $ Left $ DependencyPlanFailures
Expand All @@ -408,7 +409,7 @@ addPackageDeps treatAsDep package = do
checkDirtiness :: PackageSource
-> Installed
-> Package
-> Set GhcPkgId
-> Map PackageIdentifier GhcPkgId
-> Set PackageName
-> M Bool
checkDirtiness ps installed package present wanted = do
Expand All @@ -424,7 +425,7 @@ checkDirtiness ps installed package present wanted = do
buildOpts = bcoBuildOpts (baseConfigOpts ctx)
wantConfigCache = ConfigCache
{ configCacheOpts = configOpts
, configCacheDeps = present
, configCacheDeps = Set.fromList $ Map.elems present
, configCacheComponents =
case ps of
PSLocal lp -> Set.map renderComponent $ lpComponents lp
Expand Down
29 changes: 14 additions & 15 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ printPlan :: M env m
=> Plan
-> m ()
printPlan plan = do
case Map.toList $ planUnregisterLocal plan of
case Map.elems $ planUnregisterLocal plan of
[] -> $logInfo "No packages would be unregistered."
xs -> do
$logInfo "Would unregister locally:"
forM_ xs $ \(gid, reason) -> $logInfo $ T.concat
[ T.pack $ ghcPkgIdString gid
forM_ xs $ \(ident, reason) -> $logInfo $ T.concat
[ T.pack $ packageIdentifierString ident
, " ("
, reason
, ")"
Expand Down Expand Up @@ -417,9 +417,9 @@ executePlan' installedMap plan ee@ExecuteEnv {..} = do
[] -> return ()
ids -> do
localDB <- packageDatabaseLocal
forM_ ids $ \(id', reason) -> do
forM_ ids $ \(id', (ident, reason)) -> do
$logInfo $ T.concat
[ T.pack $ ghcPkgIdString id'
[ T.pack $ packageIdentifierString ident
, ": unregistering ("
, reason
, ")"
Expand Down Expand Up @@ -477,8 +477,8 @@ executePlan' installedMap plan ee@ExecuteEnv {..} = do
where
installedMap' = Map.difference installedMap
$ Map.fromList
$ map (\gid -> (packageIdentifierName $ ghcPkgIdPackageIdentifier gid, ()))
$ Map.keys
$ map (\(ident, _) -> (packageIdentifierName ident, ()))
$ Map.elems
$ planUnregisterLocal plan

toActions :: M env m
Expand Down Expand Up @@ -535,12 +535,12 @@ getConfigCache ExecuteEnv {..} Task {..} extra = do
let getMissing ident =
case Map.lookup ident idMap of
Nothing -> error "singleBuild: invariant violated, missing package ID missing"
Just (Library x) -> Just x
Just (Library ident' x) -> assert (ident == ident') $ Just (ident, x)
Just (Executable _) -> Nothing
missing' = Set.fromList $ mapMaybe getMissing $ Set.toList missing
missing' = Map.fromList $ mapMaybe getMissing $ Set.toList missing
TaskConfigOpts missing mkOpts = taskConfigOpts
opts = mkOpts missing'
allDeps = Set.union missing' taskPresent
allDeps = Set.fromList $ Map.elems missing' ++ Map.elems taskPresent
return ConfigCache
{ configCacheOpts = opts
{ coNoDirs = coNoDirs opts ++ map T.unpack extra
Expand Down Expand Up @@ -862,7 +862,7 @@ singleBuild runInBase ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} in
return $ Just $
case mpkgid of
Nothing -> Executable taskProvides
Just pkgid -> Library pkgid
Just pkgid -> Library taskProvides pkgid
where
bindir = toFilePath $ bcoSnapInstallRoot eeBaseConfigOpts </> bindirSuffix

Expand Down Expand Up @@ -921,14 +921,13 @@ singleBuild runInBase ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} in
, bcoLocalDB eeBaseConfigOpts
]
mpkgid <- findGhcPkgId eeEnvOverride wc pkgDbs (packageName package)
let ident = PackageIdentifier (packageName package) (packageVersion package)
mpkgid' <- case (packageHasLibrary package, mpkgid) of
(False, _) -> assert (isNothing mpkgid) $ do
markExeInstalled (taskLocation task) taskProvides -- TODO unify somehow with writeFlagCache?
return $ Executable $ PackageIdentifier
(packageName package)
(packageVersion package)
return $ Executable ident
(True, Nothing) -> throwM $ Couldn'tFindPkgId $ packageName package
(True, Just pkgid) -> return $ Library pkgid
(True, Just pkgid) -> return $ Library ident pkgid

when (doHaddock package && shouldHaddockDeps eeBuildOpts) $
withMVar eeInstallLock $ \() ->
Expand Down
15 changes: 7 additions & 8 deletions src/Stack/Build/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,18 @@ copyDepHaddocks :: (MonadIO m, MonadLogger m, MonadThrow m, MonadCatch m, MonadB
-> Set (Path Abs Dir)
-> m ()
copyDepHaddocks envOverride wc bco pkgDbs pkgId extraDestDirs = do
mpkgHtmlDir <- findGhcPkgHaddockHtml envOverride wc pkgDbs pkgId
mpkgHtmlDir <- findGhcPkgHaddockHtml envOverride wc pkgDbs $ packageIdentifierString pkgId
case mpkgHtmlDir of
Nothing -> return ()
Just pkgHtmlDir -> do
depGhcIds <- findGhcPkgDepends envOverride wc pkgDbs pkgId
forM_ (map ghcPkgIdPackageIdentifier depGhcIds) $
copyDepWhenNeeded pkgHtmlDir
Just (_pkgId, pkgHtmlDir) -> do
depGhcIds <- findGhcPkgDepends envOverride wc pkgDbs $ packageIdentifierString pkgId
forM_ depGhcIds $ copyDepWhenNeeded pkgHtmlDir
where
copyDepWhenNeeded pkgHtmlDir depId = do
mDepOrigDir <- findGhcPkgHaddockHtml envOverride wc pkgDbs depId
copyDepWhenNeeded pkgHtmlDir depGhcId = do
mDepOrigDir <- findGhcPkgHaddockHtml envOverride wc pkgDbs $ ghcPkgIdString depGhcId
case mDepOrigDir of
Nothing -> return ()
Just depOrigDir -> do
Just (depId, depOrigDir) -> do
let extraDestDirs' =
-- Parent test ensures we don't try to copy docs to global locations
if bcoSnapInstallRoot bco `isParentOf` pkgHtmlDir ||
Expand Down
17 changes: 8 additions & 9 deletions src/Stack/Build/Installed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Stack.Build.Installed
) where

import Control.Applicative
import Control.Arrow ((&&&))
import Control.Monad
import Control.Monad.Catch (MonadCatch, MonadMask)
import Control.Monad.IO.Class
Expand All @@ -26,8 +27,6 @@ import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import qualified Data.Map.Strict as Map
import Data.Maybe
import Data.Set (Set)
import qualified Data.Set as Set
import Network.HTTP.Client.Conduit (HasHttpManager)
import Path
import Prelude hiding (FilePath, writeFile)
Expand Down Expand Up @@ -63,7 +62,7 @@ getInstalled :: (M env m, PackageInstallInfo pii)
=> EnvOverride
-> GetInstalledOpts
-> Map PackageName pii -- ^ does not contain any installed information
-> m (InstalledMap, Set GhcPkgId)
-> m (InstalledMap, Map GhcPkgId PackageIdentifier)
getInstalled menv opts sourceMap = do
snapDBPath <- packageDatabaseDeps
localDBPath <- packageDatabaseLocal
Expand Down Expand Up @@ -122,18 +121,18 @@ loadDatabase :: (M env m, PackageInstallInfo pii)
-> Map PackageName pii -- ^ to determine which installed things we should include
-> Maybe (InstallLocation, Path Abs Dir) -- ^ package database, Nothing for global
-> [LoadHelper] -- ^ from parent databases
-> m ([LoadHelper], Set GhcPkgId)
-> m ([LoadHelper], Map GhcPkgId PackageIdentifier)
loadDatabase menv opts mcache sourceMap mdb lhs0 = do
wc <- getWhichCompiler
(lhs1, gids) <- ghcPkgDump menv wc (fmap snd mdb)
$ conduitDumpPackage =$ sink
let lhs = pruneDeps
(packageIdentifierName . ghcPkgIdPackageIdentifier)
id
lhId
lhDeps
const
(lhs0 ++ lhs1)
return (map (\lh -> lh { lhDeps = [] }) $ Map.elems lhs, Set.fromList gids)
return (map (\lh -> lh { lhDeps = [] }) $ Map.elems lhs, Map.fromList gids)
where
conduitProfilingCache =
case mcache of
Expand All @@ -151,7 +150,7 @@ loadDatabase menv opts mcache sourceMap mdb lhs0 = do
=$ conduitHaddockCache
=$ CL.mapMaybe (isAllowed opts mcache sourceMap (fmap fst mdb))
=$ CL.consume
sinkGIDs = CL.map dpGhcPkgId =$ CL.consume
sinkGIDs = CL.map (dpGhcPkgId &&& dpPackageIdent) =$ CL.consume
sink = getZipSink $ (,)
<$> ZipSink sinkDP
<*> ZipSink sinkGIDs
Expand Down Expand Up @@ -183,7 +182,7 @@ isAllowed opts mcache sourceMap mloc dp
if name `HashSet.member` wiredInPackages
then []
else dpDepends dp
, lhPair = (name, (version, fromMaybe Snap mloc, Library gid))
, lhPair = (name, (version, fromMaybe Snap mloc, Library ident gid))
}
| otherwise = Nothing
where
Expand All @@ -209,4 +208,4 @@ isAllowed opts mcache sourceMap mloc dp
checkLocation Local = mloc == Just Local

gid = dpGhcPkgId dp
PackageIdentifier name version = ghcPkgIdPackageIdentifier gid
ident@(PackageIdentifier name version) = dpPackageIdent dp
4 changes: 1 addition & 3 deletions src/Stack/Dot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ createDependencyGraph dotOpts = do

-- Given an 'Installed' try to get the 'Version'
libVersionFromInstalled :: Installed -> Maybe Version
libVersionFromInstalled (Library ghcPkgId) =
case ghcPkgIdPackageIdentifier ghcPkgId of
PackageIdentifier _ v -> Just v
libVersionFromInstalled (Library (PackageIdentifier _ v) _) = Just v
libVersionFromInstalled (Executable _) = Nothing

listDependencies :: (HasEnvConfig env
Expand Down
Loading