Skip to content

Commit 811e510

Browse files
committed
Have ConfigCache distinguish between local and upstream src #2147
1 parent 964fb8a commit 811e510

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

src/Stack/Build/ConstructPlan.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ addFinal lp package isAllInOne = do
352352
, taskPresent = present
353353
, taskType = TTLocal lp
354354
, taskAllInOne = isAllInOne
355+
, taskCachePkgSrc = CacheSrcLocal
355356
}
356357
tell mempty { wFinals = Map.singleton (packageName package) res }
357358

@@ -552,6 +553,7 @@ installPackageGivenDeps isAllInOne ps package minstalled (missing, present, minL
552553
PSLocal lp -> TTLocal lp
553554
PSUpstream _ loc _ _ sha -> TTUpstream package (loc <> minLoc) sha
554555
, taskAllInOne = isAllInOne
556+
, taskCachePkgSrc = toCachePkgSrc ps
555557
}
556558

557559
-- Update response in the lib map. If it is an error, and there's
@@ -684,6 +686,7 @@ checkDirtiness ps installed package present wanted = do
684686
shouldHaddockPackage buildOpts wanted (packageName package) ||
685687
-- Disabling haddocks when old config had haddocks doesn't make dirty.
686688
maybe False configCacheHaddock moldOpts
689+
, configCachePkgSrc = toCachePkgSrc ps
687690
}
688691
let mreason =
689692
case moldOpts of
@@ -703,6 +706,10 @@ checkDirtiness ps installed package present wanted = do
703706

704707
describeConfigDiff :: Config -> ConfigCache -> ConfigCache -> Maybe Text
705708
describeConfigDiff config old new
709+
| configCachePkgSrc old /= configCachePkgSrc new = Just $
710+
"switching from " <>
711+
pkgSrcName (configCachePkgSrc old) <> " to " <>
712+
pkgSrcName (configCachePkgSrc new)
706713
| not (configCacheDeps new `Set.isSubsetOf` configCacheDeps old) = Just "dependencies changed"
707714
| not $ Set.null newComponents =
708715
Just $ "components added: " `T.append` T.intercalate ", "
@@ -760,6 +767,9 @@ describeConfigDiff config old new
760767

761768
newComponents = configCacheComponents new `Set.difference` configCacheComponents old
762769

770+
pkgSrcName CacheSrcLocal = "local source"
771+
pkgSrcName CacheSrcUpstream = "upstream source"
772+
763773
psForceDirty :: PackageSource -> Bool
764774
psForceDirty (PSLocal lp) = lpForceDirty lp
765775
psForceDirty PSUpstream{} = False

src/Stack/Build/Execute.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ getConfigCache ExecuteEnv {..} Task {..} installedMap enableTest enableBench = d
790790
TTUpstream{} -> Set.empty
791791
, configCacheHaddock =
792792
shouldHaddockPackage eeBuildOpts eeWanted (packageIdentifierName taskProvides)
793+
, configCachePkgSrc = taskCachePkgSrc
793794
}
794795
allDepsMap = Map.union missing' taskPresent
795796
return (allDepsMap, cache)

src/Stack/SDist.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ getSDistFileList lp =
239239
}
240240
, taskPresent = Map.empty
241241
, taskAllInOne = True
242+
, taskCachePkgSrc = CacheSrcLocal
242243
}
243244

244245
normalizeTarballPaths :: (StackM env m) => [FilePath] -> m [FilePath]

src/Stack/Types/Build.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ module Stack.Types.Build
3535
,ConfigCache(..)
3636
,configCacheVC
3737
,configureOpts
38+
,CachePkgSrc (..)
39+
,toCachePkgSrc
3840
,isStackOpt
3941
,wantedLocalPackages
4042
,FileCacheInfo (..)
@@ -393,13 +395,23 @@ data ConfigCache = ConfigCache
393395
-- is a convenient way to force compilation when the components change.
394396
, configCacheHaddock :: !Bool
395397
-- ^ Are haddocks to be built?
398+
, configCachePkgSrc :: !CachePkgSrc
396399
}
397400
deriving (Generic, Eq, Show, Data, Typeable)
398401
instance Store ConfigCache
399402
instance NFData ConfigCache
400403

404+
data CachePkgSrc = CacheSrcUpstream | CacheSrcLocal
405+
deriving (Generic, Eq, Show, Data, Typeable)
406+
instance Store CachePkgSrc
407+
instance NFData CachePkgSrc
408+
409+
toCachePkgSrc :: PackageSource -> CachePkgSrc
410+
toCachePkgSrc PSLocal{} = CacheSrcLocal
411+
toCachePkgSrc PSUpstream{} = CacheSrcUpstream
412+
401413
configCacheVC :: VersionConfig ConfigCache
402-
configCacheVC = storeVersionConfig "config-v1" "NMEzMXpksE1h7STRzlQ2f6Glkjo="
414+
configCacheVC = storeVersionConfig "config-v2" "IU16Mr9HCSnOm0APqrPUvCW0adw="
403415

404416
-- | A task to perform when building
405417
data Task = Task
@@ -412,6 +424,7 @@ data Task = Task
412424
-- ^ GhcPkgIds of already-installed dependencies
413425
, taskAllInOne :: !Bool
414426
-- ^ indicates that the package can be built in one step
427+
, taskCachePkgSrc :: !CachePkgSrc
415428
}
416429
deriving Show
417430

0 commit comments

Comments
 (0)