Commit 2b3282fc authored by ttuegel's avatar ttuegel
Browse files

Get 'builddir' from cabal.config or CABAL_BUILDDIR

Fixes #2484. The 'builddir' option may now be specified in cabal.config
as well. It will also be read from the CABAL_BUILDDIR environment
variable, if set. The order of precedence (highest to lowest) is:
1. --builddir command line option
2. CABAL_BUILDDIR environment variable
3. cabal.config setting
parent 03530bf9
......@@ -80,7 +80,7 @@ import Distribution.Simple.Register
import Distribution.Simple.Configure
( getPersistBuildConfig, maybeGetPersistBuildConfig
, writePersistBuildConfig, checkPersistBuildConfigOutdated
, configure, checkForeignDeps )
, configure, checkForeignDeps, findDistPrefOrDefault )
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..) )
import Distribution.Simple.Bench (bench)
......@@ -197,150 +197,166 @@ allSuffixHandlers hooks
configureAction :: UserHooks -> ConfigFlags -> Args -> IO LocalBuildInfo
configureAction hooks flags args = do
let distPref = fromFlag $ configDistPref flags
pbi <- preConf hooks args flags
(mb_pd_file, pkg_descr0) <- confPkgDescr
-- get_pkg_descr (configVerbosity flags')
--let pkg_descr = updatePackageDescription pbi pkg_descr0
let epkg_descr = (pkg_descr0, pbi)
--(warns, ers) <- sanityCheckPackage pkg_descr
--errorOut (configVerbosity flags') warns ers
localbuildinfo0 <- confHook hooks epkg_descr flags
-- remember the .cabal filename if we know it
-- and all the extra command line args
let localbuildinfo = localbuildinfo0 {
pkgDescrFile = mb_pd_file,
extraConfigArgs = args
}
writePersistBuildConfig distPref localbuildinfo
let pkg_descr = localPkgDescr localbuildinfo
postConf hooks args flags pkg_descr localbuildinfo
return localbuildinfo
where
verbosity = fromFlag (configVerbosity flags)
confPkgDescr :: IO (Maybe FilePath, GenericPackageDescription)
confPkgDescr = do
mdescr <- readDesc hooks
case mdescr of
Just descr -> return (Nothing, descr)
Nothing -> do
pdfile <- defaultPackageDesc verbosity
descr <- readPackageDescription verbosity pdfile
return (Just pdfile, descr)
distPref <- findDistPrefOrDefault (configDistPref flags)
let flags' = flags { configDistPref = toFlag distPref }
pbi <- preConf hooks args flags'
(mb_pd_file, pkg_descr0) <- confPkgDescr
--get_pkg_descr (configVerbosity flags')
--let pkg_descr = updatePackageDescription pbi pkg_descr0
let epkg_descr = (pkg_descr0, pbi)
--(warns, ers) <- sanityCheckPackage pkg_descr
--errorOut (configVerbosity flags') warns ers
localbuildinfo0 <- confHook hooks epkg_descr flags'
-- remember the .cabal filename if we know it
-- and all the extra command line args
let localbuildinfo = localbuildinfo0 {
pkgDescrFile = mb_pd_file,
extraConfigArgs = args
}
writePersistBuildConfig distPref localbuildinfo
let pkg_descr = localPkgDescr localbuildinfo
postConf hooks args flags' pkg_descr localbuildinfo
return localbuildinfo
where
verbosity = fromFlag (configVerbosity flags)
confPkgDescr :: IO (Maybe FilePath, GenericPackageDescription)
confPkgDescr = do
mdescr <- readDesc hooks
case mdescr of
Just descr -> return (Nothing, descr)
Nothing -> do
pdfile <- defaultPackageDesc verbosity
descr <- readPackageDescription verbosity pdfile
return (Just pdfile, descr)
buildAction :: UserHooks -> BuildFlags -> Args -> IO ()
buildAction hooks flags args = do
let distPref = fromFlag $ buildDistPref flags
verbosity = fromFlag $ buildVerbosity flags
distPref <- findDistPrefOrDefault (buildDistPref flags)
let verbosity = fromFlag $ buildVerbosity flags
flags' = flags { buildDistPref = toFlag distPref }
lbi <- getBuildConfig hooks verbosity distPref
progs <- reconfigurePrograms verbosity
(buildProgramPaths flags)
(buildProgramArgs flags)
(buildProgramPaths flags')
(buildProgramArgs flags')
(withPrograms lbi)
hookedAction preBuild buildHook postBuild
(return lbi { withPrograms = progs })
hooks flags { buildArgs = args } args
hooks flags' { buildArgs = args } args
replAction :: UserHooks -> ReplFlags -> Args -> IO ()
replAction hooks flags args = do
let distPref = fromFlag $ replDistPref flags
verbosity = fromFlag $ replVerbosity flags
distPref <- findDistPrefOrDefault (replDistPref flags)
let verbosity = fromFlag $ replVerbosity flags
flags' = flags { replDistPref = toFlag distPref }
lbi <- getBuildConfig hooks verbosity distPref
progs <- reconfigurePrograms verbosity
(replProgramPaths flags)
(replProgramArgs flags)
(replProgramPaths flags')
(replProgramArgs flags')
(withPrograms lbi)
pbi <- preRepl hooks args flags
pbi <- preRepl hooks args flags'
let lbi' = lbi { withPrograms = progs }
pkg_descr0 = localPkgDescr lbi'
pkg_descr = updatePackageDescription pbi pkg_descr0
replHook hooks pkg_descr lbi' hooks flags args
postRepl hooks args flags pkg_descr lbi'
replHook hooks pkg_descr lbi' hooks flags' args
postRepl hooks args flags' pkg_descr lbi'
hscolourAction :: UserHooks -> HscolourFlags -> Args -> IO ()
hscolourAction hooks flags args
= do let distPref = fromFlag $ hscolourDistPref flags
verbosity = fromFlag $ hscolourVerbosity flags
hookedAction preHscolour hscolourHook postHscolour
(getBuildConfig hooks verbosity distPref)
hooks flags args
hscolourAction hooks flags args = do
distPref <- findDistPrefOrDefault (hscolourDistPref flags)
let verbosity = fromFlag $ hscolourVerbosity flags
flags' = flags { hscolourDistPref = toFlag distPref }
hookedAction preHscolour hscolourHook postHscolour
(getBuildConfig hooks verbosity distPref)
hooks flags' args
haddockAction :: UserHooks -> HaddockFlags -> Args -> IO ()
haddockAction hooks flags args = do
let distPref = fromFlag $ haddockDistPref flags
verbosity = fromFlag $ haddockVerbosity flags
distPref <- findDistPrefOrDefault (haddockDistPref flags)
let verbosity = fromFlag $ haddockVerbosity flags
flags' = flags { haddockDistPref = toFlag distPref }
lbi <- getBuildConfig hooks verbosity distPref
progs <- reconfigurePrograms verbosity
(haddockProgramPaths flags)
(haddockProgramArgs flags)
(haddockProgramPaths flags')
(haddockProgramArgs flags')
(withPrograms lbi)
hookedAction preHaddock haddockHook postHaddock
(return lbi { withPrograms = progs })
hooks flags args
hooks flags' args
cleanAction :: UserHooks -> CleanFlags -> Args -> IO ()
cleanAction hooks flags args = do
pbi <- preClean hooks args flags
distPref <- findDistPrefOrDefault (cleanDistPref flags)
let flags' = flags { cleanDistPref = toFlag distPref }
pbi <- preClean hooks args flags'
pdfile <- defaultPackageDesc verbosity
ppd <- readPackageDescription verbosity pdfile
let pkg_descr0 = flattenPackageDescription ppd
-- We don't sanity check for clean as an error
-- here would prevent cleaning:
--sanityCheckHookedBuildInfo pkg_descr0 pbi
let pkg_descr = updatePackageDescription pbi pkg_descr0
pdfile <- defaultPackageDesc verbosity
ppd <- readPackageDescription verbosity pdfile
let pkg_descr0 = flattenPackageDescription ppd
-- We don't sanity check for clean as an error
-- here would prevent cleaning:
--sanityCheckHookedBuildInfo pkg_descr0 pbi
let pkg_descr = updatePackageDescription pbi pkg_descr0
cleanHook hooks pkg_descr () hooks flags
postClean hooks args flags pkg_descr ()
where verbosity = fromFlag (cleanVerbosity flags)
cleanHook hooks pkg_descr () hooks flags'
postClean hooks args flags' pkg_descr ()
where
verbosity = fromFlag (cleanVerbosity flags)
copyAction :: UserHooks -> CopyFlags -> Args -> IO ()
copyAction hooks flags args
= do let distPref = fromFlag $ copyDistPref flags
verbosity = fromFlag $ copyVerbosity flags
hookedAction preCopy copyHook postCopy
(getBuildConfig hooks verbosity distPref)
hooks flags args
copyAction hooks flags args = do
distPref <- findDistPrefOrDefault (copyDistPref flags)
let verbosity = fromFlag $ copyVerbosity flags
flags' = flags { copyDistPref = toFlag distPref }
hookedAction preCopy copyHook postCopy
(getBuildConfig hooks verbosity distPref)
hooks flags' args
installAction :: UserHooks -> InstallFlags -> Args -> IO ()
installAction hooks flags args
= do let distPref = fromFlag $ installDistPref flags
verbosity = fromFlag $ installVerbosity flags
hookedAction preInst instHook postInst
(getBuildConfig hooks verbosity distPref)
hooks flags args
installAction hooks flags args = do
distPref <- findDistPrefOrDefault (installDistPref flags)
let verbosity = fromFlag $ installVerbosity flags
flags' = flags { installDistPref = toFlag distPref }
hookedAction preInst instHook postInst
(getBuildConfig hooks verbosity distPref)
hooks flags' args
sdistAction :: UserHooks -> SDistFlags -> Args -> IO ()
sdistAction hooks flags args = do
let distPref = fromFlag $ sDistDistPref flags
pbi <- preSDist hooks args flags
mlbi <- maybeGetPersistBuildConfig distPref
pdfile <- defaultPackageDesc verbosity
ppd <- readPackageDescription verbosity pdfile
let pkg_descr0 = flattenPackageDescription ppd
sanityCheckHookedBuildInfo pkg_descr0 pbi
let pkg_descr = updatePackageDescription pbi pkg_descr0
sDistHook hooks pkg_descr mlbi hooks flags
postSDist hooks args flags pkg_descr mlbi
where verbosity = fromFlag (sDistVerbosity flags)
distPref <- findDistPrefOrDefault (sDistDistPref flags)
let flags' = flags { sDistDistPref = toFlag distPref }
pbi <- preSDist hooks args flags'
mlbi <- maybeGetPersistBuildConfig distPref
pdfile <- defaultPackageDesc verbosity
ppd <- readPackageDescription verbosity pdfile
let pkg_descr0 = flattenPackageDescription ppd
sanityCheckHookedBuildInfo pkg_descr0 pbi
let pkg_descr = updatePackageDescription pbi pkg_descr0
sDistHook hooks pkg_descr mlbi hooks flags'
postSDist hooks args flags' pkg_descr mlbi
where
verbosity = fromFlag (sDistVerbosity flags)
testAction :: UserHooks -> TestFlags -> Args -> IO ()
testAction hooks flags args = do
let distPref = fromFlag $ testDistPref flags
verbosity = fromFlag $ testVerbosity flags
distPref <- findDistPrefOrDefault (testDistPref flags)
let verbosity = fromFlag $ testVerbosity flags
flags' = flags { testDistPref = toFlag distPref }
localBuildInfo <- getBuildConfig hooks verbosity distPref
let pkg_descr = localPkgDescr localBuildInfo
-- It is safe to do 'runTests' before the new test handler because the
......@@ -349,31 +365,34 @@ testAction hooks flags args = do
runTests hooks args False pkg_descr localBuildInfo
hookedActionWithArgs preTest testHook postTest
(getBuildConfig hooks verbosity distPref)
hooks flags args
hooks flags' args
benchAction :: UserHooks -> BenchmarkFlags -> Args -> IO ()
benchAction hooks flags args = do
let distPref = fromFlag $ benchmarkDistPref flags
verbosity = fromFlag $ benchmarkVerbosity flags
distPref <- findDistPrefOrDefault (benchmarkDistPref flags)
let verbosity = fromFlag $ benchmarkVerbosity flags
flags' = flags { benchmarkDistPref = toFlag distPref }
hookedActionWithArgs preBench benchHook postBench
(getBuildConfig hooks verbosity distPref)
hooks flags args
hooks flags' args
registerAction :: UserHooks -> RegisterFlags -> Args -> IO ()
registerAction hooks flags args
= do let distPref = fromFlag $ regDistPref flags
verbosity = fromFlag $ regVerbosity flags
hookedAction preReg regHook postReg
(getBuildConfig hooks verbosity distPref)
hooks flags args
registerAction hooks flags args = do
distPref <- findDistPrefOrDefault (regDistPref flags)
let verbosity = fromFlag $ regVerbosity flags
flags' = flags { regDistPref = toFlag distPref }
hookedAction preReg regHook postReg
(getBuildConfig hooks verbosity distPref)
hooks flags' args
unregisterAction :: UserHooks -> RegisterFlags -> Args -> IO ()
unregisterAction hooks flags args
= do let distPref = fromFlag $ regDistPref flags
verbosity = fromFlag $ regVerbosity flags
hookedAction preUnreg unregHook postUnreg
(getBuildConfig hooks verbosity distPref)
hooks flags args
unregisterAction hooks flags args = do
distPref <- findDistPrefOrDefault (regDistPref flags)
let verbosity = fromFlag $ regVerbosity flags
flags' = flags { regDistPref = toFlag distPref }
hookedAction preUnreg unregHook postUnreg
(getBuildConfig hooks verbosity distPref)
hooks flags' args
hookedAction :: (UserHooks -> Args -> flags -> IO HookedBuildInfo)
-> (UserHooks -> PackageDescription -> LocalBuildInfo
......@@ -466,7 +485,7 @@ getBuildConfig hooks verbosity distPref = do
clean :: PackageDescription -> CleanFlags -> IO ()
clean pkg_descr flags = do
let distPref = fromFlag $ cleanDistPref flags
let distPref = fromFlagOrDefault defaultDistPref $ cleanDistPref flags
notice verbosity "cleaning..."
maybeConfig <- if fromFlag (cleanSaveConf flags)
......
......@@ -33,6 +33,7 @@ module Distribution.Simple.Configure (configure,
checkPersistBuildConfigOutdated,
tryGetPersistBuildConfig,
maybeGetPersistBuildConfig,
findDistPref, findDistPrefOrDefault,
localBuildInfoFile,
getInstalledPackages, getPackageDBContents,
configCompiler, configCompilerAux,
......@@ -86,9 +87,9 @@ import Distribution.Simple.Program
, userSpecifyArgss, userSpecifyPaths
, lookupProgram, requireProgram, requireProgramVersion
, pkgConfigProgram, gccProgram, rawSystemProgramStdoutConf )
import Distribution.Simple.Setup
( ConfigFlags(..), CopyDest(..), Flag(..), fromFlag, fromFlagOrDefault
, flagToMaybe )
import Distribution.Simple.Setup as Setup
( ConfigFlags(..), CopyDest(..), Flag(..), defaultDistPref
, fromFlag, fromFlagOrDefault, flagToMaybe, toFlag )
import Distribution.Simple.InstallDirs
( InstallDirs(..), defaultInstallDirs, combineInstallDirs )
import Distribution.Simple.LocalBuildInfo
......@@ -158,6 +159,7 @@ import Distribution.Text
import Text.PrettyPrint
( render, (<>), ($+$), char, text, comma
, quotes, punctuate, nest, sep, hsep )
import Distribution.Compat.Environment ( lookupEnv )
import Distribution.Compat.Exception ( catchExit, catchIO )
-- | The errors that can be thrown when reading the @setup-config@ file.
......@@ -312,6 +314,30 @@ localBuildInfoFile distPref = distPref </> "setup-config"
-- * Configuration
-- -----------------------------------------------------------------------------
-- | Return the \"dist/\" prefix, or the default prefix. The prefix is taken from
-- (in order of highest to lowest preference) the override prefix, the \"CABAL_BUILDDIR\"
-- environment variable, or the default prefix.
findDistPref :: FilePath -- ^ default \"dist\" prefix
-> Setup.Flag FilePath -- ^ override \"dist\" prefix
-> IO FilePath
findDistPref defDistPref overrideDistPref = do
envDistPref <- liftM parseEnvDistPref (lookupEnv "CABAL_BUILDDIR")
return $ fromFlagOrDefault defDistPref (mappend envDistPref overrideDistPref)
where
parseEnvDistPref env =
case env of
Just distPref | not (null distPref) -> toFlag distPref
_ -> NoFlag
-- | Return the \"dist/\" prefix, or the default prefix. The prefix is taken from
-- (in order of highest to lowest preference) the override prefix, the \"CABAL_BUILDDIR\"
-- environment variable, or 'defaultDistPref' is used. Call this function to resolve a
-- @*DistPref@ flag whenever it is not known to be set. (The @*DistPref@ flags are always
-- set to a definite value before invoking 'UserHooks'.)
findDistPrefOrDefault :: Setup.Flag FilePath -- ^ override \"dist\" prefix
-> IO FilePath
findDistPrefOrDefault = findDistPref defaultDistPref
-- |Perform the \"@.\/setup configure@\" action.
-- Returns the @.setup-config@ file.
configure :: (GenericPackageDescription, HookedBuildInfo)
......
......@@ -57,7 +57,7 @@ module Distribution.Simple.Setup (
buildOptions, haddockOptions, installDirsOptions,
programConfigurationOptions, programConfigurationPaths',
defaultDistPref,
defaultDistPref, optionDistPref,
Flag(..),
toFlag,
......@@ -354,7 +354,7 @@ defaultConfigFlags progConf = emptyConfigFlags {
configOptimization = Flag NormalOptimisation,
configProgPrefix = Flag (toPathTemplate ""),
configProgSuffix = Flag (toPathTemplate ""),
configDistPref = Flag defaultDistPref,
configDistPref = NoFlag,
configVerbosity = Flag normal,
configUserInstall = Flag False, --TODO: reverse this
#if defined(mingw32_HOST_OS)
......@@ -832,7 +832,7 @@ data CopyFlags = CopyFlags {
defaultCopyFlags :: CopyFlags
defaultCopyFlags = CopyFlags {
copyDest = Flag NoCopyDest,
copyDistPref = Flag defaultDistPref,
copyDistPref = NoFlag,
copyVerbosity = Flag normal
}
......@@ -895,7 +895,7 @@ data InstallFlags = InstallFlags {
defaultInstallFlags :: InstallFlags
defaultInstallFlags = InstallFlags {
installPackageDB = NoFlag,
installDistPref = Flag defaultDistPref,
installDistPref = NoFlag,
installUseWrapper = Flag False,
installInPlace = Flag False,
installVerbosity = Flag normal
......@@ -977,7 +977,7 @@ defaultSDistFlags :: SDistFlags
defaultSDistFlags = SDistFlags {
sDistSnapshot = Flag False,
sDistDirectory = mempty,
sDistDistPref = Flag defaultDistPref,
sDistDistPref = NoFlag,
sDistListSources = mempty,
sDistVerbosity = Flag normal
}
......@@ -1059,7 +1059,7 @@ defaultRegisterFlags = RegisterFlags {
regGenScript = Flag False,
regGenPkgConf = NoFlag,
regInPlace = Flag False,
regDistPref = Flag defaultDistPref,
regDistPref = NoFlag,
regPrintId = Flag False,
regVerbosity = Flag normal
}
......@@ -1186,7 +1186,7 @@ defaultHscolourFlags = HscolourFlags {
hscolourExecutables = Flag False,
hscolourTestSuites = Flag False,
hscolourBenchmarks = Flag False,
hscolourDistPref = Flag defaultDistPref,
hscolourDistPref = NoFlag,
hscolourVerbosity = Flag normal
}
......@@ -1297,7 +1297,7 @@ defaultHaddockFlags = HaddockFlags {
haddockHscolour = Flag False,
haddockHscolourCss = NoFlag,
haddockContents = NoFlag,
haddockDistPref = Flag defaultDistPref,
haddockDistPref = NoFlag,
haddockKeepTempFiles= Flag False,
haddockVerbosity = Flag normal
}
......@@ -1463,7 +1463,7 @@ data CleanFlags = CleanFlags {
defaultCleanFlags :: CleanFlags
defaultCleanFlags = CleanFlags {
cleanSaveConf = Flag False,
cleanDistPref = Flag defaultDistPref,
cleanDistPref = NoFlag,
cleanVerbosity = Flag normal
}
......@@ -1530,7 +1530,7 @@ defaultBuildFlags :: BuildFlags
defaultBuildFlags = BuildFlags {
buildProgramPaths = mempty,
buildProgramArgs = [],
buildDistPref = Flag defaultDistPref,
buildDistPref = mempty,
buildVerbosity = Flag normal,
buildNumJobs = mempty,
buildArgs = []
......@@ -1630,7 +1630,7 @@ defaultReplFlags :: ReplFlags
defaultReplFlags = ReplFlags {
replProgramPaths = mempty,
replProgramArgs = [],
replDistPref = Flag defaultDistPref,
replDistPref = NoFlag,
replVerbosity = Flag normal,
replReload = Flag False
}
......@@ -1759,7 +1759,7 @@ data TestFlags = TestFlags {
defaultTestFlags :: TestFlags
defaultTestFlags = TestFlags {
testDistPref = Flag defaultDistPref,
testDistPref = NoFlag,
testVerbosity = Flag normal,
testHumanLog = toFlag $ toPathTemplate $ "$pkgid-$test-suite.log",
testMachineLog = toFlag $ toPathTemplate $ "$pkgid.log",
......@@ -1878,7 +1878,7 @@ data BenchmarkFlags = BenchmarkFlags {
defaultBenchmarkFlags :: BenchmarkFlags
defaultBenchmarkFlags = BenchmarkFlags {
benchmarkDistPref = Flag defaultDistPref,
benchmarkDistPref = NoFlag,
benchmarkVerbosity = Flag normal,
benchmarkOptions = []
}
......
......@@ -4,6 +4,7 @@
* Deal with extra C sources from preprocessors (#238).
* Include cabal_macros.h when running c2hs (#2600).
* Don't recompile C sources unless needed (#2601).
* Read 'builddir' option from 'CABAL_BUILDDIR' environment variable
1.22.0.0 Johan Tibell <johan.tibell@gmail.com> January 2015
* Support GHC 7.10.
......
......@@ -58,7 +58,7 @@ import Distribution.Simple.Compiler
import Distribution.Simple.Setup
( ConfigFlags(..), configureOptions, defaultConfigFlags
, HaddockFlags(..), haddockOptions, defaultHaddockFlags
, installDirsOptions
, installDirsOptions, optionDistPref
, programConfigurationPaths', programConfigurationOptions
, Flag(..), toFlag, flagToMaybe, fromFlagOrDefault )
import Distribution.Simple.InstallDirs
......@@ -684,6 +684,18 @@ configFieldDescriptions =
-- share the options or make then distinct. In any case
-- they should probably be per-server.
++ [ viewAsFieldDescr
$ optionDistPref
(configDistPref . savedConfigureFlags)
(\distPref config ->
config
{ savedConfigureFlags = (savedConfigureFlags config) { configDistPref = distPref }
, savedHaddockFlags = (savedHaddockFlags config) { haddockDistPref = distPref }
}
)
ParseArgs
]
where
toSavedConfig lift options exclusions replacements =
[ lift (fromMaybe field replacement)
......
......@@ -21,6 +21,7 @@ module Distribution.Client.Sandbox (
getSandboxConfigFilePath,
loadConfigOrSandboxConfig,
findSavedDistPref,
initPackageDBIfNeeded,
maybeWithSandboxDirOnSearchPath,
......@@ -65,6 +66,8 @@ import Distribution.Client.Sandbox.PackageEnvironment
, sandboxPackageEnvironmentFile, userPackageEnvironmentFile )
import Distribution.Client.Sandbox.Types ( SandboxPackageInfo(..)
, UseSandbox(..) )
import Distribution.Client.SetupWrapper
( SetupScriptOptions(..), defaultSetupScriptOptions )
import Distribution.Client.Types ( PackageLocation(..)
, SourcePackage(..) )
import Distribution.Client.Utils ( inDir, tryCanonicalizePath
......@@ -76,7 +79,8 @@ import Distribution.Simple.Compiler ( Compiler(..), PackageDB(..)
, PackageDBStack )
import Distribution.Simple.Configure ( configCompilerAuxEx
, interpretPackageDbFlags
, getPackageDBContents )
, getPackageDBContents
, findDistPref )
import Distribution.Simple.PreProcess ( knownSuffixHandlers )
import Distribution.Simple.Program ( ProgramConfiguration )
import Distribution.Simple.Setup ( Flag(..), HaddockFlags(..)
......@@ -542,6 +546,14 @@ loadConfigOrSandboxConfig verbosity globalFlags userInstallFlag = do
checkFlag (Flag False) = return ()
checkFlag (NoFlag) = return ()
-- | Return the saved \"dist/\" prefix, or the default prefix.
findSavedDistPref :: Verbosity -> GlobalFlags -> Flag FilePath -> IO FilePath
findSavedDistPref verbosity globalFlags flagDistPref = do
(_, config) <- loadConfigOrSandboxConfig verbosity globalFlags mempty
let defDistPref = useDistPref defaultSetupScriptOptions
flagDistPref' = configDistPref (savedConfigureFlags config) `mappend` flagDistPref
findDistPref defDistPref flagDistPref'
-- | If we're in a sandbox, call @withSandboxBinDirOnSearchPath@, otherwise do
-- nothing.
maybeWithSandboxDirOnSearchPath :: UseSandbox -> IO a -> IO a
......
......@@ -87,6 +87,7 @@ import Distribution.Client.Sandbox (sandboxInit
,getSandboxConfigFilePath
,loadConfigOrSandboxConfig
,findSavedDistPref
,initPackageDBIfNeeded
,maybeWithSandboxDirOnSearchPath
,maybeWithSandboxPackageInfo
......@@ -276,13 +277,10 @@ wrapperAction :: Monoid flags
-> Command (GlobalFlags -> IO ())
wrapperAction command verbosityFlag distPrefFlag =
commandAddAction command
{ commandDefaultFlags = mempty } $ \flags extraArgs _globalFlags -> do
{ commandDefaultFlags = mempty } $ \flags extraArgs globalFlags -> do
let verbosity = fromFlagOrDefault normal (verbosityFlag flags)
setupScriptOptions = defaultSetupScriptOptions {
useDistPref = fromFlagOrDefault
(useDistPref defaultSetupScriptOptions)
(distPrefFlag flags)
}
distPref <- findSavedDistPref verbosity globalFlags (distPrefFlag flags)
let setupScriptOptions = defaultSetupScriptOptions { useDistPref = distPref }
setupWrapper verbosity setupScriptOptions Nothing
command (const flags) extraArgs
......@@ -324,11 +322,10 @@ configureAction (configFlags, configExFlags) extraArgs globalFlags = do
buildAction :: (BuildFlags, BuildExFlags) -> [String] -> GlobalFlags -> IO ()
buildAction (buildFlags, buildExFlags) extraArgs globalFlags = do
let distPref = fromFlagOrDefault (useDistPref defaultSetupScriptOptions)
(buildDistPref buildFlags)