@@ -101,7 +101,7 @@ import Stack.Types.BuildOpts
101
101
import Stack.Types.BuildOptsCLI ( BuildOptsCLI (.. ) )
102
102
import Stack.Types.CompCollection
103
103
( collectionKeyValueList , collectionLookup
104
- , getBuildableListText , foldComponentToAnotherCollection
104
+ , foldComponentToAnotherCollection , getBuildableListText
105
105
)
106
106
import Stack.Types.Compiler
107
107
( ActualCompiler (.. ), WhichCompiler (.. ), getGhcVersion
@@ -637,11 +637,22 @@ singleBuild
637
637
when (hasLibrary || hasSubLibraries) $ cabal KeepTHLoading [" register" ]
638
638
639
639
copyDdumpFilesIfNeeded buildingFinals ee. buildOpts. ddumpDir
640
- installedPkg <- fetchAndMarkInstalledPackage ee (taskLocation task) package pkgId
641
- postProcessRemotePackage task. taskType ac cache ee installedPkg package pkgId pkgDir
640
+ installedPkg <-
641
+ fetchAndMarkInstalledPackage ee (taskLocation task) package pkgId
642
+ postProcessRemotePackage
643
+ task. taskType
644
+ ac
645
+ cache
646
+ ee
647
+ installedPkg
648
+ package
649
+ pkgId
650
+ pkgDir
642
651
pure installedPkg
643
652
644
- postProcessRemotePackage :: (HasEnvConfig env )
653
+ -- | Action in the case that the task relates to a remote package.
654
+ postProcessRemotePackage ::
655
+ (HasEnvConfig env )
645
656
=> TaskType
646
657
-> ActionContext
647
658
-> ConfigCache
@@ -651,64 +662,77 @@ postProcessRemotePackage :: (HasEnvConfig env)
651
662
-> PackageIdentifier
652
663
-> Path b Dir
653
664
-> RIO env ()
654
- postProcessRemotePackage taskType ac cache ee installedPackage package pkgId pkgDir = do
655
- case taskType of
656
- TTRemotePackage isMutable _ loc -> do
657
- when (isMutable == Immutable ) $ writePrecompiledCache
658
- ee. baseConfigOpts
659
- loc
660
- cache. configureOpts
661
- cache. buildHaddocks
662
- installedPackage
663
- (buildableExes package)
664
- -- For packages from a package index, pkgDir is in the tmp directory. We
665
- -- eagerly delete it if no other tasks require it, to reduce space usage
666
- -- in tmp (#3018).
667
- let remaining =
668
- Set. filter
669
- (\ (ActionId x _) -> x == pkgId)
670
- ac. remaining
671
- when (null remaining) $ removeDirRecur pkgDir
672
- _ -> pure ()
673
-
674
- -- | Once all the cabal related tasks have run for a package, we should be able to gather
675
- -- the information needed to create an @Installed@ package value.
676
- -- For now, either there's a main library in which case we consider the package's libraries
677
- -- ghcPkgIds or we just consider it's an executable
665
+ postProcessRemotePackage
666
+ taskType
667
+ ac
668
+ cache
669
+ ee
670
+ installedPackage
671
+ package
672
+ pkgId
673
+ pkgDir
674
+ = case taskType of
675
+ TTRemotePackage isMutable _ loc -> do
676
+ when (isMutable == Immutable ) $ writePrecompiledCache
677
+ ee. baseConfigOpts
678
+ loc
679
+ cache. configureOpts
680
+ cache. buildHaddocks
681
+ installedPackage
682
+ (buildableExes package)
683
+ -- For packages from a package index, pkgDir is in the tmp directory. We
684
+ -- eagerly delete it if no other tasks require it, to reduce space usage
685
+ -- in tmp (#3018).
686
+ let remaining =
687
+ Set. filter
688
+ (\ (ActionId x _) -> x == pkgId)
689
+ ac. remaining
690
+ when (null remaining) $ removeDirRecur pkgDir
691
+ _ -> pure ()
692
+
693
+ -- | Once all the Cabal-related tasks have run for a package, we should be able
694
+ -- to gather the information needed to create an 'Installed' package value. For
695
+ -- now, either there's a main library (in which case we consider the 'GhcPkgId'
696
+ -- values of the package's libraries) or we just consider it's an executable
678
697
-- (and mark all the executables as installed, if any).
679
698
--
680
- -- Note that this also modifies the installedDumpPkgsTVar which is used for generating Haddocks.
699
+ -- Note that this also modifies the installedDumpPkgsTVar which is used for
700
+ -- generating Haddocks.
681
701
--
682
702
fetchAndMarkInstalledPackage ::
683
- (HasTerm env , HasEnvConfig env )
703
+ (HasTerm env , HasEnvConfig env )
684
704
=> ExecuteEnv
685
705
-> InstallLocation
686
706
-> Package
687
707
-> PackageIdentifier
688
708
-> RIO env Installed
689
709
fetchAndMarkInstalledPackage ee taskInstallLocation package pkgId = do
690
710
let baseConfigOpts = ee. baseConfigOpts
691
- let (installedPkgDb, installedDumpPkgsTVar) =
711
+ (installedPkgDb, installedDumpPkgsTVar) =
692
712
case taskInstallLocation of
693
713
Snap ->
694
714
( baseConfigOpts. snapDB
695
715
, ee. snapshotDumpPkgs )
696
716
Local ->
697
717
( baseConfigOpts. localDB
698
718
, ee. localDumpPkgs )
699
- -- let ident = PackageIdentifier package.name package.version
700
- -- only pure the sub-libraries to cache them if we also cache the main
719
+ -- Only pure the sub-libraries to cache them if we also cache the main
701
720
-- library (that is, if it exists)
702
721
if hasBuildableMainLibrary package
703
722
then do
704
- let getAndStoreGhcPkgId = loadInstalledPkg [installedPkgDb] installedDumpPkgsTVar
705
- let foldSubLibToMap subLib mapInMonad = do
723
+ let getAndStoreGhcPkgId =
724
+ loadInstalledPkg [installedPkgDb] installedDumpPkgsTVar
725
+ foldSubLibToMap subLib mapInMonad = do
706
726
let mungedName = toCabalMungedPackageName package. name subLib. name
707
- maybeGhcpkgId <- getAndStoreGhcPkgId (encodeCompatPackageName mungedName)
727
+ maybeGhcpkgId <-
728
+ getAndStoreGhcPkgId (encodeCompatPackageName mungedName)
708
729
mapInMonad <&> case maybeGhcpkgId of
709
730
Just v -> Map. insert subLib. name v
710
731
_ -> id
711
- subLibsPkgIds <- foldComponentToAnotherCollection package. subLibraries foldSubLibToMap mempty
732
+ subLibsPkgIds <- foldComponentToAnotherCollection
733
+ package. subLibraries
734
+ foldSubLibToMap
735
+ mempty
712
736
mGhcPkgId <- getAndStoreGhcPkgId package. name
713
737
case mGhcPkgId of
714
738
Nothing -> throwM $ Couldn'tFindPkgId package. name
0 commit comments