Commit 68d342f0 authored by bjorn@bringert.net's avatar bjorn@bringert.net
Browse files

Added config file fields for all the install dir templates.

parent 45e894c1
...@@ -46,10 +46,10 @@ import Distribution.Package (PackageIdentifier(..), showPackageId) ...@@ -46,10 +46,10 @@ import Distribution.Package (PackageIdentifier(..), showPackageId)
import Distribution.PackageDescription (GenericPackageDescription(..) import Distribution.PackageDescription (GenericPackageDescription(..)
, PackageDescription(..) , PackageDescription(..)
, parsePackageDescription, ParseResult(..)) , parsePackageDescription, ParseResult(..))
import Distribution.ParseUtils (FieldDescr, simpleField, listField) import Distribution.ParseUtils (FieldDescr, simpleField, listField, liftField, field)
import Distribution.Simple.Compiler (Compiler) import Distribution.Simple.Compiler (Compiler)
import qualified Distribution.Simple.Configure as Configure (configCompiler) import qualified Distribution.Simple.Configure as Configure (configCompiler)
import Distribution.Simple.InstallDirs (InstallDirTemplates(..), defaultInstallDirs) import Distribution.Simple.InstallDirs (InstallDirTemplates(..), PathTemplate, defaultInstallDirs)
import Distribution.Simple.Program (ProgramConfiguration, defaultProgramConfiguration) import Distribution.Simple.Program (ProgramConfiguration, defaultProgramConfiguration)
import Distribution.Version (Dependency, showVersion) import Distribution.Version (Dependency, showVersion)
import Distribution.Verbosity import Distribution.Verbosity
...@@ -208,9 +208,15 @@ writeDefaultConfigFile file cfg = ...@@ -208,9 +208,15 @@ writeDefaultConfigFile file cfg =
-- | All config file fields. -- | All config file fields.
configFieldDescrs :: [FieldDescr ConfigFlags] configFieldDescrs :: [FieldDescr ConfigFlags]
configFieldDescrs = configFieldDescrs =
[ [ installDirField "bindir" binDirTemplate (\d ds -> ds { binDirTemplate = d })
, installDirField "libdir" libDirTemplate (\d ds -> ds { libDirTemplate = d })
, installDirField "libexecdir" libexecDirTemplate (\d ds -> ds { libexecDirTemplate = d })
, installDirField "datadir" dataDirTemplate (\d ds -> ds { dataDirTemplate = d })
, installDirField "docdir" docDirTemplate (\d ds -> ds { docDirTemplate = d })
, installDirField "htmldir" htmlDirTemplate (\d ds -> ds { htmlDirTemplate = d })
] ++ configWriteFieldDescrs ] ++ configWriteFieldDescrs
-- | The subset of the config file fields that we write out -- | The subset of the config file fields that we write out
-- if the config file is missing. -- if the config file is missing.
configWriteFieldDescrs :: [FieldDescr ConfigFlags] configWriteFieldDescrs :: [FieldDescr ConfigFlags]
...@@ -225,14 +231,17 @@ configWriteFieldDescrs = ...@@ -225,14 +231,17 @@ configWriteFieldDescrs =
(text . show) (readS_to_P reads) (text . show) (readS_to_P reads)
configCacheDir (\d cfg -> cfg { configCacheDir = d }) configCacheDir (\d cfg -> cfg { configCacheDir = d })
, boolField "user-install" configUserInstall (\u cfg -> cfg { configUserInstall = u }) , boolField "user-install" configUserInstall (\u cfg -> cfg { configUserInstall = u })
, simpleField "prefix" , installDirField "prefix" prefixDirTemplate (\d ds -> ds { prefixDirTemplate = d })
(text . show) (readS_to_P reads)
(prefixDirTemplate . configInstallDirs) (\d -> setInstallDir (\ds -> ds { prefixDirTemplate = d }))
] ]
setInstallDir :: (InstallDirTemplates -> InstallDirTemplates) -> ConfigFlags -> ConfigFlags installDirField :: String
setInstallDir f cfg = cfg { configInstallDirs = f (configInstallDirs cfg) } -> (InstallDirTemplates -> PathTemplate)
-> (PathTemplate -> InstallDirTemplates -> InstallDirTemplates)
-> FieldDescr ConfigFlags
installDirField name get set =
liftField (get . configInstallDirs)
(\d cfg -> cfg { configInstallDirs = set d (configInstallDirs cfg) }) $
field name (text . show) (readS_to_P reads)
parseCompilerFlavor :: ReadP r CompilerFlavor parseCompilerFlavor :: ReadP r CompilerFlavor
parseCompilerFlavor = parseCompilerFlavor =
......
module Network.Hackage.CabalInstall.Utils where module Network.Hackage.CabalInstall.Utils where
import Distribution.Compat.ReadP (ReadP, readP_to_S, pfail, get, look, choice) import Distribution.Compat.ReadP (ReadP, readP_to_S, readS_to_P, pfail, get, look, choice)
import Distribution.ParseUtils import Distribution.ParseUtils
import Distribution.Verbosity import Distribution.Verbosity
import Network.Hackage.CabalInstall.Types import Network.Hackage.CabalInstall.Types
......
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