@@ -340,23 +340,67 @@ rebuildTargets
340340 -> BuildTimeSettings
341341 -> IO BuildOutcomes
342342rebuildTargets
343+ verbosity
344+ projectConfig
345+ distDirLayout
346+ storeDirLayout
347+ installPlan
348+ sharedPackageConfig
349+ pkgsBuildStatus
350+ buildSettings
351+ | buildSettingOnlyDownload buildSettings = do
352+ rebuildTargets' verbosity projectConfig distDirLayout installPlan sharedPackageConfig pkgsBuildStatus buildSettings $
353+ \ downloadMap _jobControl pkg pkgBuildStatus ->
354+ rebuildTargetOnlyDownload
355+ verbosity
356+ downloadMap
357+ pkg
358+ pkgBuildStatus
359+ | otherwise = do
360+ registerLock <- newLock -- serialise registration
361+ cacheLock <- newLock -- serialise access to setup exe cache
362+ rebuildTargets' verbosity projectConfig distDirLayout installPlan sharedPackageConfig pkgsBuildStatus buildSettings $
363+ \ downloadMap jobControl pkg pkgBuildStatus ->
364+ rebuildTarget
365+ verbosity
366+ distDirLayout
367+ storeDirLayout
368+ (jobControlSemaphore jobControl)
369+ buildSettings
370+ downloadMap
371+ registerLock
372+ cacheLock
373+ sharedPackageConfig
374+ installPlan
375+ pkg
376+ pkgBuildStatus
377+
378+ rebuildTargets'
379+ :: Verbosity
380+ -> ProjectConfig
381+ -> DistDirLayout
382+ -> ElaboratedInstallPlan
383+ -> ElaboratedSharedConfig
384+ -> BuildStatusMap
385+ -> BuildTimeSettings
386+ -> (AsyncFetchMap -> JobControl IO (Graph. Key (GenericReadyPackage ElaboratedConfiguredPackage ), Either BuildFailure BuildResult ) -> GenericReadyPackage ElaboratedConfiguredPackage -> BuildStatus -> IO BuildResult )
387+ -> IO BuildOutcomes
388+ rebuildTargets'
343389 verbosity
344390 ProjectConfig
345391 { projectConfigBuildOnly = config
346392 }
347- distDirLayout@ DistDirLayout {.. }
348- storeDirLayout
393+ DistDirLayout {.. }
349394 installPlan
350395 sharedPackageConfig
351396 pkgsBuildStatus
352397 buildSettings@ BuildTimeSettings
353398 { buildSettingNumJobs
354399 , buildSettingKeepGoing
355400 }
401+ act
356402 | fromFlagOrDefault False (projectConfigOfflineMode config) && not (null packagesToDownload) = return offlineError
357403 | otherwise = do
358- registerLock <- newLock -- serialise registration
359- cacheLock <- newLock -- serialise access to setup exe cache
360404 -- TODO: [code cleanup] eliminate setup exe cache
361405 info verbosity $
362406 " Executing install plan "
@@ -384,26 +428,13 @@ rebuildTargets
384428 InstallPlan. execute
385429 jobControl
386430 keepGoing
387- (BuildFailure Nothing . DependentFailed . packageId )
431+ (BuildFailure Nothing . DependentFailed . Graph. nodeKey )
388432 installPlan
389433 $ \ pkg ->
390434 -- TODO: review exception handling
391435 handle (\ (e :: BuildFailure ) -> return (Left e)) $ fmap Right $ do
392436 let pkgBuildStatus = Map. findWithDefault (error " rebuildTargets" ) (nodeKey pkg) pkgsBuildStatus
393-
394- rebuildTarget
395- verbosity
396- distDirLayout
397- storeDirLayout
398- (jobControlSemaphore jobControl)
399- buildSettings
400- downloadMap
401- registerLock
402- cacheLock
403- sharedPackageConfig
404- installPlan
405- pkg
406- pkgBuildStatus
437+ act downloadMap jobControl pkg pkgBuildStatus
407438 where
408439 keepGoing = buildSettingKeepGoing
409440 withRepoCtx =
@@ -433,29 +464,6 @@ rebuildTargets
433464 _ -> pure ()
434465 _ -> pure ()
435466
436- -- createPackageDBIfMissing _ _ _ _ = return ()
437-
438- -- -- all the package dbs we may need to create
439- -- (Set.toList . Set.fromList)
440- -- [ pkgdb
441- -- | InstallPlan.Configured elab <- InstallPlan.toList installPlan
442- -- , pkgdb <-
443- -- concat
444- -- [ elabBuildPackageDBStack elab
445- -- , elabRegisterPackageDBStack elab
446- -- , elabSetupPackageDBStack elab
447- -- ]
448- -- ]
449- -- createPackageDBIfMissing
450- -- verbosity
451- -- compiler
452- -- progdb
453- -- (SpecificPackageDB dbPath) = do
454- -- exists <- Cabal.doesPackageDBExist dbPath
455- -- unless exists $ do
456- -- createDirectoryIfMissingVerbose verbosity True (takeDirectory dbPath)
457- -- Cabal.createPackageDB verbosity compiler progdb False dbPath
458- -- createPackageDBIfMissing _ _ _ _ = return ()
459467 offlineError :: BuildOutcomes
460468 offlineError = Map. fromList . map makeBuildOutcome $ packagesToDownload
461469 where
@@ -624,6 +632,23 @@ rebuildTarget
624632 srcdir
625633 builddir
626634
635+ rebuildTargetOnlyDownload
636+ :: Verbosity
637+ -> AsyncFetchMap
638+ -> GenericReadyPackage ElaboratedConfiguredPackage
639+ -> BuildStatus
640+ -> IO BuildResult
641+ rebuildTargetOnlyDownload
642+ verbosity
643+ downloadMap
644+ (ReadyPackage pkg)
645+ pkgBuildStatus = do
646+ case pkgBuildStatus of
647+ BuildStatusDownload ->
648+ void $ waitAsyncPackageDownload verbosity downloadMap pkg
649+ _ -> return ()
650+ return $ BuildResult DocsNotTried TestsNotTried Nothing
651+
627652-- TODO: [nice to have] do we need to use a with-style for the temp
628653-- files for downloading http packages, or are we going to cache them
629654-- persistently?
0 commit comments