Commit 1492a94a authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Update for distPref changes

parent 8ea46d28
......@@ -39,7 +39,7 @@ import Hackage.Types as Available
, AvailablePackageSource(..), Repo, ConfiguredPackage(..) )
import Hackage.Utils (showDependencies)
import Hackage.SetupWrapper
( setupWrapper, SetupScriptOptions(..) )
( setupWrapper, SetupScriptOptions(..), defaultSetupScriptOptions )
import Paths_cabal_install (getBinDir)
import Distribution.Simple.Compiler
......@@ -153,7 +153,10 @@ installWithPlanner planner verbosity packageDB repos comp conf configFlags insta
useCabalVersion = maybe AnyVersion ThisVersion (libVersion miscOptions),
useCompiler = Just comp,
usePackageIndex = if packageDB == UserPackageDB then index else Nothing,
useProgramConfig = conf
useProgramConfig = conf,
useDistPref = Cabal.fromFlagOrDefault
(useDistPref defaultSetupScriptOptions)
(Cabal.configDistPref configFlags)
}
dryRun = Cabal.fromFlag (installDryRun installFlags)
miscOptions = InstallMisc {
......
......@@ -41,7 +41,7 @@ import Distribution.Simple.Program
( ProgramConfiguration, emptyProgramConfiguration
, rawSystemProgramConf, ghcProgram )
import Distribution.Simple.BuildPaths
( distPref, exeExtension )
( defaultDistPref, exeExtension )
import Distribution.Simple.Command
( CommandUI(..), commandShowOptions )
import Distribution.Simple.GHC
......@@ -69,7 +69,8 @@ data SetupScriptOptions = SetupScriptOptions {
useCabalVersion :: VersionRange,
useCompiler :: Maybe Compiler,
usePackageIndex :: Maybe (PackageIndex InstalledPackageInfo),
useProgramConfig :: ProgramConfiguration
useProgramConfig :: ProgramConfiguration,
useDistPref :: FilePath
}
defaultSetupScriptOptions :: SetupScriptOptions
......@@ -77,7 +78,8 @@ defaultSetupScriptOptions = SetupScriptOptions {
useCabalVersion = AnyVersion,
useCompiler = Nothing,
usePackageIndex = Nothing,
useProgramConfig = emptyProgramConfiguration
useProgramConfig = emptyProgramConfiguration,
useDistPref = defaultDistPref
}
setupWrapper :: Verbosity
......@@ -144,27 +146,27 @@ externalSetupMethod :: SetupScriptOptions -> SetupMethod
externalSetupMethod options verbosity bt args = do
debug verbosity $ "Using external setup method with build-type " ++ show bt
++ " and args:\n " ++ show args
setupHs <- updateSetupScript verbosity bt
setupHs <- updateSetupScript verbosity options bt
debug verbosity $ "Using " ++ setupHs ++ " as setup script."
compileSetupExecutable verbosity options setupHs
invokeSetupScript verbosity args
invokeSetupScript verbosity options args
-- | Decide which Setup.hs script to use, creating it if necessary.
--
updateSetupScript :: Verbosity -> BuildType -> IO FilePath
updateSetupScript _ Custom = do
updateSetupScript :: Verbosity -> SetupScriptOptions -> BuildType -> IO FilePath
updateSetupScript _ _ Custom = do
useHs <- doesFileExist "Setup.hs"
useLhs <- doesFileExist "Setup.lhs"
unless (useHs || useLhs) $ die
"Using 'build-type: Custom' but there is no Setup.hs or Setup.lhs script."
return (if useHs then "Setup.hs" else "Setup.lhs")
updateSetupScript verbosity bt = do
updateSetupScript verbosity options bt = do
createDirectoryIfMissingVerbose verbosity True setupDir
rewriteFile setupHs (buildTypeScript bt)
return setupHs
where
setupDir = distPref </> "setup"
setupDir = useDistPref options </> "setup"
setupHs = setupDir </> "setup" <.> "hs"
buildTypeScript :: BuildType -> String
......@@ -196,7 +198,7 @@ compileSetupExecutable verbosity options setupHs = do
,"-odir", setupDir, "-hidir", setupDir]
where
setupDir = distPref </> "setup"
setupDir = useDistPref options </> "setup"
setupProg = setupDir </> "setup" <.> exeExtension
installedCabalLibVer :: Verbosity -> SetupScriptOptions
......@@ -216,10 +218,11 @@ installedCabalLibVer verbosity options comp conf = do
++ " but no suitable version is installed."
pkgs -> return $ maximumBy (comparing packageVersion) (map packageId pkgs)
invokeSetupScript :: Verbosity -> [String] -> IO ()
invokeSetupScript verbosity args = rawSystemExit verbosity setupProg args
invokeSetupScript :: Verbosity -> SetupScriptOptions -> [String] -> IO ()
invokeSetupScript verbosity options args =
rawSystemExit verbosity setupProg args
where
setupProg = distPref </> "setup" </> "setup" <.> exeExtension
setupProg = useDistPref options </> "setup" </> "setup" <.> exeExtension
-- ------------------------------------------------------------
-- * Utils
......
......@@ -18,7 +18,7 @@ import Distribution.Simple.Setup (SDistFlags(..), fromFlag)
import Distribution.Verbosity (Verbosity)
import Distribution.Simple.PreProcess (knownSuffixHandlers)
import Distribution.PackageDescription.Parse (readPackageDescription)
import Distribution.Simple.BuildPaths ( distPref, srcPref)
import Distribution.Simple.BuildPaths ( srcPref)
import Distribution.Simple.Configure(maybeGetPersistBuildConfig)
import Distribution.PackageDescription.Configuration ( flattenPackageDescription )
import Distribution.Text
......@@ -36,8 +36,8 @@ sdist flags = do
pkg <- return . flattenPackageDescription
=<< readPackageDescription verbosity
=<< defaultPackageDesc verbosity
mb_lbi <- maybeGetPersistBuildConfig
let tmpDir = srcPref
mb_lbi <- maybeGetPersistBuildConfig distPref
let tmpDir = srcPref distPref
-- do some QA
printPackageProblems verbosity pkg
......@@ -63,6 +63,7 @@ sdist flags = do
where
verbosity = fromFlag (sDistVerbosity flags)
snapshot = fromFlag (sDistSnapshot flags)
distPref = fromFlag (sDistDistPref flags)
-- |Create an archive from a tree of source files, and clean up the tree.
createArchive :: Verbosity
......
......@@ -92,24 +92,36 @@ mainWorker args =
,uploadCommand `commandAddAction` uploadAction
,checkCommand `commandAddAction` checkAction
,sdistCommand `commandAddAction` sdistAction
,wrapperAction (Cabal.buildCommand defaultProgramConfiguration) Cabal.buildVerbosity
,wrapperAction Cabal.copyCommand Cabal.copyVerbosity
,wrapperAction Cabal.haddockCommand Cabal.haddockVerbosity
,wrapperAction Cabal.cleanCommand Cabal.cleanVerbosity
,wrapperAction Cabal.hscolourCommand Cabal.hscolourVerbosity
,wrapperAction Cabal.registerCommand Cabal.regVerbosity
,wrapperAction Cabal.testCommand (const mempty)
,wrapperAction (Cabal.buildCommand defaultProgramConfiguration)
Cabal.buildVerbosity Cabal.buildDistPref
,wrapperAction Cabal.copyCommand
Cabal.copyVerbosity Cabal.copyDistPref
,wrapperAction Cabal.haddockCommand
Cabal.haddockVerbosity Cabal.haddockDistPref
,wrapperAction Cabal.cleanCommand
Cabal.cleanVerbosity Cabal.cleanDistPref
,wrapperAction Cabal.hscolourCommand
Cabal.hscolourVerbosity Cabal.hscolourDistPref
,wrapperAction Cabal.registerCommand
Cabal.regVerbosity Cabal.regDistPref
,wrapperAction Cabal.testCommand
Cabal.testVerbosity Cabal.testDistPref
]
wrapperAction :: Monoid flags
=> CommandUI flags
-> (flags -> Flag Verbosity)
-> (flags -> Flag String)
-> Command (IO ())
wrapperAction command verbosityFlag =
wrapperAction command verbosityFlag distPrefFlag =
commandAddAction command $ \flags extraArgs -> do
let verbosity = fromFlagOrDefault normal (verbosityFlag flags)
setupWrapper verbosity defaultSetupScriptOptions Nothing
command flags extraArgs
setupScriptOptions = defaultSetupScriptOptions {
useDistPref = fromFlagOrDefault
(useDistPref defaultSetupScriptOptions)
(distPrefFlag flags)
}
setupWrapper verbosity setupScriptOptions Nothing command flags extraArgs
configureAction :: Cabal.ConfigFlags -> [String] -> IO ()
configureAction flags extraArgs = do
......@@ -120,9 +132,12 @@ configureAction flags extraArgs = do
`mappend` flags
(comp, conf) <- configCompilerAux flags'
let setupScriptOptions = defaultSetupScriptOptions {
useCompiler = Just comp,
useProgramConfig = conf
}
useCompiler = Just comp,
useProgramConfig = conf,
useDistPref = fromFlagOrDefault
(useDistPref defaultSetupScriptOptions)
(Cabal.configDistPref flags)
}
setupWrapper verbosity setupScriptOptions Nothing
configureCommand flags' extraArgs
......
Supports Markdown
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