Skip to content
Snippets Groups Projects
Unverified Commit 800d2817 authored by Peter Becich's avatar Peter Becich
Browse files

more type annotations

parent 08c2d5be
No related branches found
No related tags found
No related merge requests found
......@@ -432,7 +432,7 @@ checkFileMonitorChanged
-- or we cannot decode it. Sadly ErrorCall can still happen, despite
-- using decodeFileOrFail, e.g. Data.Char.chr errors
handleDoesNotExist (MonitorChanged MonitorFirstRun) .
handleDoesNotExist (MonitorChanged MonitorFirstRun) $
handleErrorCall (MonitorChanged MonitorCorruptCache) $
readCacheFile monitor
>>= either (\_ -> return (MonitorChanged MonitorCorruptCache))
......
......@@ -101,7 +101,7 @@ import qualified Data.ByteString.Lazy as LBS
import Control.Exception (Handler (..), SomeAsyncException, assert, catches, handle)
import System.Directory (canonicalizePath, createDirectoryIfMissing, doesDirectoryExist, doesFileExist, removeFile, renameDirectory)
import System.FilePath (dropDrive, makeRelative, normalise, takeDirectory, (<.>), (</>))
import System.IO (IOMode (AppendMode), withFile)
import System.IO (IOMode (AppendMode), Handle, withFile)
import Distribution.Compat.Directory (listDirectory)
......@@ -689,6 +689,7 @@ rebuildTarget verbosity
--TODO: [nice to have] git/darcs repos etc
unpackTarballPhase :: FilePath -> IO BuildResult
unpackTarballPhase tarball =
withTarballLocalDirectory
verbosity distDirLayout tarball
......@@ -706,6 +707,7 @@ rebuildTarget verbosity
-- 'BuildInplaceOnly' style packages. 'BuildAndInstall' style packages
-- would only start from download or unpack phases.
--
rebuildPhase :: BuildStatusRebuild -> FilePath -> IO BuildResult
rebuildPhase buildStatus srcdir =
assert (elabBuildStyle pkg == BuildInplaceOnly) $
......@@ -714,6 +716,7 @@ rebuildTarget verbosity
builddir = distBuildDirectory
(elabDistDirParams sharedPackageConfig pkg)
buildAndInstall :: FilePath -> FilePath -> IO BuildResult
buildAndInstall srcdir builddir =
buildAndInstallUnpackedPackage
verbosity distDirLayout storeDirLayout
......@@ -725,6 +728,7 @@ rebuildTarget verbosity
builddir' = makeRelative srcdir builddir
--TODO: [nice to have] ^^ do this relative stuff better
buildInplace :: BuildStatusRebuild -> FilePath -> FilePath -> IO BuildResult
buildInplace buildStatus srcdir builddir =
--TODO: [nice to have] use a relative build dir rather than absolute
buildInplaceUnpackedPackage
......@@ -760,6 +764,7 @@ asyncDownloadPackages verbosity withRepoCtx installPlan pkgsBuildStatus body
asyncFetchPackages verbosity repoctx
pkgsToDownload body
where
pkgsToDownload :: [PackageLocation (Maybe FilePath)]
pkgsToDownload =
ordNub $
[ elabPkgSourceLocation elab
......@@ -1143,6 +1148,7 @@ buildAndInstallUnpackedPackage verbosity
Nothing -> Nothing
Just mkLogFile -> Just (mkLogFile compiler platform pkgid uid)
initLogFile :: IO ()
initLogFile =
case mlogFile of
Nothing -> return ()
......@@ -1151,6 +1157,7 @@ buildAndInstallUnpackedPackage verbosity
exists <- doesFileExist logFile
when exists $ removeFile logFile
withLogging :: (Maybe Handle -> IO r) -> IO r
withLogging action =
case mlogFile of
Nothing -> action Nothing
......@@ -1162,6 +1169,7 @@ hasValidHaddockTargets ElaboratedConfiguredPackage{..}
| not elabBuildHaddocks = False
| otherwise = any componentHasHaddocks components
where
components :: [ComponentTarget]
components = elabBuildTargets ++ elabTestTargets ++ elabBenchTargets
++ maybeToList elabReplTarget ++ elabHaddockTargets
......
......@@ -136,6 +136,8 @@ import Distribution.Compiler
( CompilerFlavor(GHC) )
import Distribution.Types.ComponentName
( componentNameString )
import Distribution.Types.InstalledPackageInfo
( InstalledPackageInfo )
import Distribution.Types.UnqualComponentName
( UnqualComponentName, packageNameToUnqualComponentName )
......@@ -1102,6 +1104,9 @@ dieOnBuildFailures verbosity currentCommand plan buildOutcomes
| InstallPlan.Configured pkg <- InstallPlan.toList plan
, hasNoDependents pkg ]
ultimateDeps
:: UnitId
-> [InstallPlan.GenericPlanPackage InstalledPackageInfo ElaboratedConfiguredPackage]
ultimateDeps pkgid =
filter (\pkg -> hasNoDependents pkg && installedUnitId pkg /= pkgid)
(InstallPlan.reverseDependencyClosure plan [pkgid])
......@@ -1261,6 +1266,7 @@ establishDummyProjectBaseContext verbosity cliConfig distDirLayout localPackages
mstoreDir = flagToMaybe projectConfigStoreDir
cabalDirLayout = mkCabalDirLayout cabalDir mstoreDir mlogsDir
buildSettings :: BuildTimeSettings
buildSettings = resolveBuildTimeSettings
verbosity cabalDirLayout
projectConfig
......
......@@ -225,9 +225,11 @@ encodePlanAsJson distDirLayout elaboratedInstallPlan elaboratedSharedConfig =
, "subdir" J..= fmap J.String srpSubdir
]
dist_dir :: FilePath
dist_dir = distBuildDirectory distDirLayout
(elabDistDirParams elaboratedSharedConfig elab)
bin_file :: ComponentDeps.Component -> [J.Pair]
bin_file c = case c of
ComponentDeps.ComponentExe s -> bin_file' s
ComponentDeps.ComponentTest s -> bin_file' s
......@@ -241,6 +243,7 @@ encodePlanAsJson distDirLayout elaboratedInstallPlan elaboratedSharedConfig =
then dist_dir </> "build" </> prettyShow s </> prettyShow s <.> exeExtension plat
else InstallDirs.bindir (elabInstallDirs elab) </> prettyShow s <.> exeExtension plat
flib_file' :: (Pretty a, Show a) => a -> [J.Pair]
flib_file' s =
["bin-file" J..= J.String bin]
where
......@@ -580,6 +583,8 @@ postBuildProjectStatus plan previousPackagesUpToDate
InstallPlan.Configured srcpkg -> elabLibDeps srcpkg
InstallPlan.Installed srcpkg -> elabLibDeps srcpkg
]
elabLibDeps :: ElaboratedConfiguredPackage -> [UnitId]
elabLibDeps = map (newSimpleUnitId . confInstId) . elabLibDependencies
-- Was a build was attempted for this package?
......@@ -599,11 +604,13 @@ postBuildProjectStatus plan previousPackagesUpToDate
buildAttempted _ (Left BuildFailure {}) = True
buildAttempted _ (Right _) = True
lookupBuildStatusRequiresBuild :: Bool -> UnitId -> Bool
lookupBuildStatusRequiresBuild def ipkgid =
case Map.lookup ipkgid pkgBuildStatus of
Nothing -> def -- Not in the plan subset we did the dry-run on
Just buildStatus -> buildStatusRequiresBuild buildStatus
packagesBuildLocal :: Set UnitId
packagesBuildLocal =
selectPlanPackageIdSet $ \pkg ->
case pkg of
......@@ -611,6 +618,7 @@ postBuildProjectStatus plan previousPackagesUpToDate
InstallPlan.Installed _ -> False
InstallPlan.Configured srcpkg -> elabLocalToProject srcpkg
packagesBuildInplace :: Set UnitId
packagesBuildInplace =
selectPlanPackageIdSet $ \pkg ->
case pkg of
......@@ -618,7 +626,7 @@ postBuildProjectStatus plan previousPackagesUpToDate
InstallPlan.Installed _ -> False
InstallPlan.Configured srcpkg -> elabBuildStyle srcpkg
== BuildInplaceOnly
packagesAlreadyInStore :: Set UnitId
packagesAlreadyInStore =
selectPlanPackageIdSet $ \pkg ->
case pkg of
......@@ -626,6 +634,10 @@ postBuildProjectStatus plan previousPackagesUpToDate
InstallPlan.Installed _ -> True
InstallPlan.Configured _ -> False
selectPlanPackageIdSet
:: (InstallPlan.GenericPlanPackage InstalledPackageInfo ElaboratedConfiguredPackage
-> Bool)
-> Set UnitId
selectPlanPackageIdSet p = Map.keysSet
. Map.filter p
$ InstallPlan.toMap plan
......@@ -902,6 +914,7 @@ selectGhcEnvironmentFilePackageDbs elaboratedInstallPlan =
([], pkgs) -> checkSamePackageDBs pkgs
(pkgs, _) -> checkSamePackageDBs pkgs
where
checkSamePackageDBs :: [ElaboratedConfiguredPackage] -> PackageDBStack
checkSamePackageDBs pkgs =
case ordNub (map elabBuildPackageDBStack pkgs) of
[packageDbs] -> packageDbs
......@@ -914,10 +927,13 @@ selectGhcEnvironmentFilePackageDbs elaboratedInstallPlan =
-- this feature, e.g. write out multiple env files, one for each
-- compiler / project profile.
inplacePackages :: [ElaboratedConfiguredPackage]
inplacePackages =
[ srcpkg
| srcpkg <- sourcePackages
, elabBuildStyle srcpkg == BuildInplaceOnly ]
sourcePackages :: [ElaboratedConfiguredPackage]
sourcePackages =
[ srcpkg
| pkg <- InstallPlan.toList elaboratedInstallPlan
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment