Commit 8ca987a9 authored by Francesco Gazzetta's avatar Francesco Gazzetta

Add --download-only flag

parent 4aad1823
......@@ -294,6 +294,7 @@ instance Semigroup SavedConfig where
installDocumentation = combine installDocumentation,
installHaddockIndex = combine installHaddockIndex,
installDryRun = combine installDryRun,
installOnlyDownload = combine installOnlyDownload,
installDest = combine installDest,
installMaxBackjumps = combine installMaxBackjumps,
installReorderGoals = combine installReorderGoals,
......
......@@ -652,8 +652,14 @@ rebuildTarget verbosity
registerLock cacheLock
sharedPackageConfig
plan rpkg@(ReadyPackage pkg)
pkgBuildStatus =
pkgBuildStatus
| buildSettingOnlyDownload buildSettings = do
case pkgBuildStatus of
BuildStatusDownload ->
void $ waitAsyncPackageDownload verbosity downloadMap pkg
_ -> return ()
return $ BuildResult DocsNotTried TestsNotTried Nothing
| otherwise =
-- We rely on the 'BuildStatus' to decide which phase to start from:
case pkgBuildStatus of
BuildStatusDownload -> downloadPhase
......
......@@ -303,6 +303,7 @@ resolveBuildTimeSettings verbosity
where
buildSettingDryRun = fromFlag projectConfigDryRun
buildSettingOnlyDeps = fromFlag projectConfigOnlyDeps
buildSettingOnlyDownload = fromFlag projectConfigOnlyDownload
buildSettingSummaryFile = fromNubList projectConfigSummaryFile
--buildSettingLogFile -- defined below, more complicated
--buildSettingLogVerbosity -- defined below, more complicated
......@@ -328,6 +329,7 @@ resolveBuildTimeSettings verbosity
defaults = mempty {
projectConfigDryRun = toFlag False,
projectConfigOnlyDeps = toFlag False,
projectConfigOnlyDownload = toFlag False,
projectConfigBuildReports = toFlag NoReports,
projectConfigReportPlanningFailure = toFlag False,
projectConfigKeepGoing = toFlag False,
......
......@@ -509,6 +509,7 @@ convertLegacyBuildOnlyFlags globalFlags configFlags
InstallFlags {
installDryRun = projectConfigDryRun,
installOnlyDownload = projectConfigOnlyDownload,
installOnly = _,
installOnlyDeps = projectConfigOnlyDeps,
installRootCmd = _,
......@@ -612,6 +613,7 @@ convertToLegacySharedConfig
installHaddockIndex = projectConfigHaddockIndex,
installDest = Flag NoCopyDest,
installDryRun = projectConfigDryRun,
installOnlyDownload = projectConfigOnlyDownload,
installReinstall = mempty, --projectConfigReinstall,
installAvoidReinstalls = mempty, --projectConfigAvoidReinstalls,
installOverrideReinstall = mempty, --projectConfigOverrideReinstall,
......
......@@ -136,6 +136,7 @@ data ProjectConfigBuildOnly
projectConfigVerbosity :: Flag Verbosity,
projectConfigDryRun :: Flag Bool,
projectConfigOnlyDeps :: Flag Bool,
projectConfigOnlyDownload :: Flag Bool,
projectConfigSummaryFile :: NubList PathTemplate,
projectConfigLogFile :: Flag PathTemplate,
projectConfigBuildReports :: Flag ReportLevel,
......@@ -436,6 +437,7 @@ data BuildTimeSettings
= BuildTimeSettings {
buildSettingDryRun :: Bool,
buildSettingOnlyDeps :: Bool,
buildSettingOnlyDownload :: Bool,
buildSettingSummaryFile :: [PathTemplate],
buildSettingLogFile :: Maybe (Compiler -> Platform
-> PackageId -> UnitId
......
......@@ -1623,6 +1623,7 @@ data InstallFlags = InstallFlags {
installHaddockIndex :: Flag PathTemplate,
installDest :: Flag Cabal.CopyDest,
installDryRun :: Flag Bool,
installOnlyDownload :: Flag Bool,
installMaxBackjumps :: Flag Int,
installReorderGoals :: Flag ReorderGoals,
installCountConflicts :: Flag CountConflicts,
......@@ -1665,6 +1666,7 @@ defaultInstallFlags = InstallFlags {
installHaddockIndex = Flag docIndexFile,
installDest = Flag Cabal.NoCopyDest,
installDryRun = Flag False,
installOnlyDownload = Flag False,
installMaxBackjumps = Flag defaultMaxBackjumps,
installReorderGoals = Flag (ReorderGoals False),
installCountConflicts = Flag (CountConflicts True),
......@@ -1878,6 +1880,11 @@ installOptions showOrParseArgs =
installDryRun (\v flags -> flags { installDryRun = v })
trueArg
, option [] ["only-download"]
"Do not build anything, only fetch the packages."
installOnlyDownload (\v flags -> flags { installOnlyDownload = v })
trueArg
, option "" ["target-package-db"]
"package database to install into. Required when using ${pkgroot} prefix."
installDest (\v flags -> flags { installDest = v })
......
......@@ -201,10 +201,11 @@ prop_roundtrip_printparse_buildonly config =
hackProjectConfigBuildOnly :: ProjectConfigBuildOnly -> ProjectConfigBuildOnly
hackProjectConfigBuildOnly config =
config {
-- These two fields are only command line transitory things, not
-- These fields are only command line transitory things, not
-- something to be recorded persistently in a config file
projectConfigOnlyDeps = mempty,
projectConfigDryRun = mempty
projectConfigOnlyDeps = mempty,
projectConfigOnlyDownload = mempty,
projectConfigDryRun = mempty
}
prop_roundtrip_printparse_shared :: ProjectConfigShared -> Property
......@@ -377,6 +378,7 @@ instance Arbitrary ProjectConfigBuildOnly where
<$> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> (toNubList <$> shortListOf 2 arbitrary)
<*> arbitrary
<*> arbitrary
......@@ -398,6 +400,7 @@ instance Arbitrary ProjectConfigBuildOnly where
shrink ProjectConfigBuildOnly { projectConfigVerbosity = x00
, projectConfigDryRun = x01
, projectConfigOnlyDeps = x02
, projectConfigOnlyDownload = x18
, projectConfigSummaryFile = x03
, projectConfigLogFile = x04
, projectConfigBuildReports = x05
......@@ -416,6 +419,7 @@ instance Arbitrary ProjectConfigBuildOnly where
[ ProjectConfigBuildOnly { projectConfigVerbosity = x00'
, projectConfigDryRun = x01'
, projectConfigOnlyDeps = x02'
, projectConfigOnlyDownload = x18'
, projectConfigSummaryFile = x03'
, projectConfigLogFile = x04'
, projectConfigBuildReports = x05'
......@@ -434,12 +438,12 @@ instance Arbitrary ProjectConfigBuildOnly where
| ((x00', x01', x02', x03', x04'),
(x05', x06', x07', x08', x09'),
(x10', x11', x12', x14'),
( x17' ))
( x17', x18' ))
<- shrink
((x00, x01, x02, x03, x04),
(x05, x06, x07, x08, preShrink_NumJobs x09),
(x10, x11, x12, x14),
( x17 ))
( x17, x18 ))
]
where
preShrink_NumJobs = fmap (fmap Positive)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment