@@ -337,24 +337,68 @@ rebuildTargets
337337 -> BuildStatusMap
338338 -> BuildTimeSettings
339339 -> IO BuildOutcomes
340- rebuildTargets
340+ rebuildTargets
341+ verbosity
342+ projectConfig
343+ distDirLayout
344+ storeDirLayout
345+ installPlan
346+ sharedPackageConfig
347+ pkgsBuildStatus
348+ buildSettings
349+ | buildSettingOnlyDownload buildSettings = do
350+ rebuildTargets' verbosity projectConfig distDirLayout installPlan sharedPackageConfig pkgsBuildStatus buildSettings $
351+ \ downloadMap _jobControl pkg pkgBuildStatus ->
352+ rebuildTargetOnlyDownload
353+ verbosity
354+ downloadMap
355+ pkg
356+ pkgBuildStatus
357+ | otherwise = do
358+ registerLock <- newLock -- serialise registration
359+ cacheLock <- newLock -- serialise access to setup exe cache
360+ rebuildTargets' verbosity projectConfig distDirLayout installPlan sharedPackageConfig pkgsBuildStatus buildSettings $
361+ \ downloadMap jobControl pkg pkgBuildStatus ->
362+ rebuildTarget
363+ verbosity
364+ distDirLayout
365+ storeDirLayout
366+ (jobControlSemaphore jobControl)
367+ buildSettings
368+ downloadMap
369+ registerLock
370+ cacheLock
371+ sharedPackageConfig
372+ installPlan
373+ pkg
374+ pkgBuildStatus
375+
376+ rebuildTargets'
377+ :: Verbosity
378+ -> ProjectConfig
379+ -> DistDirLayout
380+ -> ElaboratedInstallPlan
381+ -> ElaboratedSharedConfig
382+ -> BuildStatusMap
383+ -> BuildTimeSettings
384+ -> (AsyncFetchMap -> JobControl IO (Graph. Key (GenericReadyPackage ElaboratedConfiguredPackage ), Either BuildFailure BuildResult ) -> GenericReadyPackage ElaboratedConfiguredPackage -> BuildStatus -> IO BuildResult )
385+ -> IO BuildOutcomes
386+ rebuildTargets'
341387 verbosity
342388 ProjectConfig
343389 { projectConfigBuildOnly = config
344390 }
345- distDirLayout@ DistDirLayout {.. }
346- storeDirLayout
391+ DistDirLayout {.. }
347392 installPlan
348393 sharedPackageConfig
349394 pkgsBuildStatus
350395 buildSettings@ BuildTimeSettings
351396 { buildSettingNumJobs
352397 , buildSettingKeepGoing
353398 }
399+ act
354400 | fromFlagOrDefault False (projectConfigOfflineMode config) && not (null packagesToDownload) = return offlineError
355401 | otherwise = do
356- registerLock <- newLock -- serialise registration
357- cacheLock <- newLock -- serialise access to setup exe cache
358402 -- TODO: [code cleanup] eliminate setup exe cache
359403 info verbosity $
360404 " Executing install plan "
@@ -382,26 +426,13 @@ rebuildTargets
382426 InstallPlan. execute
383427 jobControl
384428 keepGoing
385- (BuildFailure Nothing . DependentFailed . packageId )
429+ (BuildFailure Nothing . DependentFailed . Graph. nodeKey )
386430 installPlan
387431 $ \ pkg ->
388432 -- TODO: review exception handling
389433 handle (\ (e :: BuildFailure ) -> return (Left e)) $ fmap Right $ do
390434 let pkgBuildStatus = Map. findWithDefault (error " rebuildTargets" ) (nodeKey pkg) pkgsBuildStatus
391-
392- rebuildTarget
393- verbosity
394- distDirLayout
395- storeDirLayout
396- (jobControlSemaphore jobControl)
397- buildSettings
398- downloadMap
399- registerLock
400- cacheLock
401- sharedPackageConfig
402- installPlan
403- pkg
404- pkgBuildStatus
435+ act downloadMap jobControl pkg pkgBuildStatus
405436 where
406437 keepGoing = buildSettingKeepGoing
407438 withRepoCtx =
@@ -431,29 +462,6 @@ rebuildTargets
431462 _ -> pure ()
432463 _ -> pure ()
433464
434- -- createPackageDBIfMissing _ _ _ _ = return ()
435-
436- -- -- all the package dbs we may need to create
437- -- (Set.toList . Set.fromList)
438- -- [ pkgdb
439- -- | InstallPlan.Configured elab <- InstallPlan.toList installPlan
440- -- , pkgdb <-
441- -- concat
442- -- [ elabBuildPackageDBStack elab
443- -- , elabRegisterPackageDBStack elab
444- -- , elabSetupPackageDBStack elab
445- -- ]
446- -- ]
447- -- createPackageDBIfMissing
448- -- verbosity
449- -- compiler
450- -- progdb
451- -- (SpecificPackageDB dbPath) = do
452- -- exists <- Cabal.doesPackageDBExist dbPath
453- -- unless exists $ do
454- -- createDirectoryIfMissingVerbose verbosity True (takeDirectory dbPath)
455- -- Cabal.createPackageDB verbosity compiler progdb False dbPath
456- -- createPackageDBIfMissing _ _ _ _ = return ()
457465 offlineError :: BuildOutcomes
458466 offlineError = Map. fromList . map makeBuildOutcome $ packagesToDownload
459467 where
@@ -622,6 +630,23 @@ rebuildTarget
622630 srcdir
623631 builddir
624632
633+ rebuildTargetOnlyDownload
634+ :: Verbosity
635+ -> AsyncFetchMap
636+ -> GenericReadyPackage ElaboratedConfiguredPackage
637+ -> BuildStatus
638+ -> IO BuildResult
639+ rebuildTargetOnlyDownload
640+ verbosity
641+ downloadMap
642+ (ReadyPackage pkg)
643+ pkgBuildStatus = do
644+ case pkgBuildStatus of
645+ BuildStatusDownload ->
646+ void $ waitAsyncPackageDownload verbosity downloadMap pkg
647+ _ -> return ()
648+ return $ BuildResult DocsNotTried TestsNotTried Nothing
649+
625650-- TODO: [nice to have] do we need to use a with-style for the temp
626651-- files for downloading http packages, or are we going to cache them
627652-- persistently?
0 commit comments