Commit 7059f018 authored by phigley's avatar phigley
Browse files

Moved --program-prefix and --program-suffix out of InstallDirs

The program prefix and suffix have been moved out of InstallDirs so that InstallDirs is now all directories.  The prefix and suffix have been moved into LocalBuildInfo as stand-alone PathTemplate flags.
parent bba80735
......@@ -300,7 +300,9 @@ configure (pkg_descr0, pbi) cfg
withOptimization = fromFlag $ configOptimization cfg,
withGHCiLib = fromFlag $ configGHCiLib cfg,
splitObjs = split_objs,
withPackageDB = packageDb
withPackageDB = packageDb,
progPrefix = fromFlag $ configProgPrefix cfg,
progSuffix = fromFlag $ configProgSuffix cfg
}
let dirs = absoluteInstallDirs pkg_descr lbi NoCopyDest
......
......@@ -49,7 +49,8 @@ import Distribution.PackageDescription (
PackageDescription(..), BuildInfo(..), Library(..),
hasLibs, withLib, hasExes, withExe )
import Distribution.Simple.LocalBuildInfo (
LocalBuildInfo(..), InstallDirs(..), absoluteInstallDirs)
LocalBuildInfo(..), InstallDirs(..), absoluteInstallDirs,
substPathTemplate)
import Distribution.Simple.BuildPaths (haddockName, haddockPref)
import Distribution.Simple.Utils (createDirectoryIfMissingVerbose,
copyFileVerbose, die, info, notice,
......@@ -88,10 +89,12 @@ install pkg_descr lbi flags = do
docdir = docPref,
htmldir = htmlPref,
haddockdir = interfacePref,
includedir = incPref,
progprefix = progprefixPref,
progsuffix = progsuffixPref
includedir = incPref
} = absoluteInstallDirs pkg_descr lbi copydest
progPrefixPref = substPathTemplate pkg_descr lbi (progPrefix lbi)
progSuffixPref = substPathTemplate pkg_descr lbi (progSuffix lbi)
docExists <- doesDirectoryExist $ haddockPref pkg_descr
info verbosity ("directory " ++ haddockPref pkg_descr ++
" does exist: " ++ show docExists)
......@@ -131,15 +134,15 @@ install pkg_descr lbi flags = do
GHC -> do withLib pkg_descr () $ \_ ->
GHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
withExe pkg_descr $ \_ ->
GHC.installExe verbosity binPref buildPref (progprefixPref, progsuffixPref) pkg_descr
GHC.installExe verbosity binPref buildPref (progPrefixPref, progSuffixPref) pkg_descr
JHC -> do withLib pkg_descr () $ JHC.installLib verbosity libPref buildPref pkg_descr
withExe pkg_descr $ JHC.installExe verbosity binPref buildPref (progprefixPref, progsuffixPref) pkg_descr
withExe pkg_descr $ JHC.installExe verbosity binPref buildPref (progPrefixPref, progSuffixPref) pkg_descr
Hugs -> do
let targetProgPref = progdir (absoluteInstallDirs pkg_descr lbi NoCopyDest)
let scratchPref = scratchDir lbi
Hugs.install verbosity libPref progPref binPref targetProgPref scratchPref (progprefixPref, progsuffixPref) pkg_descr
Hugs.install verbosity libPref progPref binPref targetProgPref scratchPref (progPrefixPref, progSuffixPref) pkg_descr
NHC -> do withLib pkg_descr () $ NHC.installLib verbosity libPref buildPref (package pkg_descr)
withExe pkg_descr $ NHC.installExe verbosity binPref buildPref (progprefixPref, progsuffixPref)
withExe pkg_descr $ NHC.installExe verbosity binPref buildPref (progPrefixPref, progSuffixPref)
_ -> die ("only installing with GHC, JHC, Hugs or nhc98 is implemented")
return ()
-- register step should be performed by caller.
......
......@@ -109,9 +109,7 @@ data InstallDirs dir = InstallDirs {
docdir :: dir,
mandir :: dir,
htmldir :: dir,
haddockdir :: dir,
progprefix :: dir,
progsuffix :: dir
haddockdir :: dir
} deriving (Read, Show)
instance Functor InstallDirs where
......@@ -129,9 +127,7 @@ instance Functor InstallDirs where
docdir = f (docdir dirs),
mandir = f (mandir dirs),
htmldir = f (htmldir dirs),
haddockdir = f (haddockdir dirs),
progprefix = f (progprefix dirs),
progsuffix = f (progsuffix dirs)
haddockdir = f (haddockdir dirs)
}
instance Monoid dir => Monoid (InstallDirs dir) where
......@@ -149,9 +145,7 @@ instance Monoid dir => Monoid (InstallDirs dir) where
docdir = mempty,
mandir = mempty,
htmldir = mempty,
haddockdir = mempty,
progprefix = mempty,
progsuffix = mempty
haddockdir = mempty
}
mappend = combineInstallDirs mappend
......@@ -173,9 +167,7 @@ combineInstallDirs combine a b = InstallDirs {
docdir = docdir a `combine` docdir b,
mandir = mandir a `combine` mandir b,
htmldir = htmldir a `combine` htmldir b,
haddockdir = haddockdir a `combine` haddockdir b,
progprefix = progprefix a `combine` progprefix b,
progsuffix = progsuffix a `combine` progsuffix b
haddockdir = haddockdir a `combine` haddockdir b
}
appendSubdirs :: (a -> a -> a) -> InstallDirs a -> InstallDirs a
......@@ -247,9 +239,7 @@ defaultInstallDirs comp userInstall hasLibs = do
_other -> "$datadir" </> "doc" </> "$pkgid",
mandir = "$datadir" </> "man",
htmldir = "$docdir" </> "html",
haddockdir = "$htmldir",
progprefix = "",
progsuffix = ""
haddockdir = "$htmldir"
}
-- ---------------------------------------------------------------------------
......@@ -287,9 +277,7 @@ substituteTemplates pkgId compilerId dirs = dirs'
mandir = subst docdir (prefixBinLibDataVars ++ [docdirVar]),
htmldir = subst htmldir (prefixBinLibDataVars ++ [docdirVar]),
haddockdir = subst haddockdir (prefixBinLibDataVars ++
[docdirVar, htmldirVar]),
progprefix = subst progprefix [],
progsuffix = subst progsuffix []
[docdirVar, htmldirVar])
}
-- The initial environment has all the static stuff but no paths
env = initialPathTemplateEnv pkgId compilerId
......@@ -313,13 +301,7 @@ absoluteInstallDirs :: PackageIdentifier -> PackageIdentifier -> CopyDest
-> InstallDirTemplates -> InstallDirs FilePath
absoluteInstallDirs pkgId compilerId copydest dirs =
(case copydest of
CopyTo destdir -> \dirs -> (fmap ((destdir </>) . dropDrive) dirs) {
-- We add the destdir to all the paths, but the
-- program prefix and suffix are not paths, so we
-- keep their old values:
progprefix = progprefix dirs,
progsuffix = progsuffix dirs
}
CopyTo destdir -> fmap ((destdir </>) . dropDrive)
_ -> id)
. appendSubdirs (</>)
. fmap fromPathTemplate
......
......@@ -48,11 +48,13 @@ module Distribution.Simple.LocalBuildInfo (
-- * Installation directories
module Distribution.Simple.InstallDirs,
absoluteInstallDirs, prefixRelativeInstallDirs,
substPathTemplate
) where
import Distribution.Simple.InstallDirs hiding (absoluteInstallDirs,
prefixRelativeInstallDirs)
prefixRelativeInstallDirs,
substPathTemplate, )
import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.Simple.Setup (CopyDest(..))
import Distribution.Simple.Program (ProgramConfiguration)
......@@ -92,7 +94,9 @@ data LocalBuildInfo = LocalBuildInfo {
withProfExe :: Bool, -- ^Whether to build executables for profiling.
withOptimization :: Bool, -- ^Whether to build with optimization (if available).
withGHCiLib :: Bool, -- ^Whether to build libs suitable for use with GHCi.
splitObjs :: Bool -- ^Use -split-objs with GHC, if available
splitObjs :: Bool, -- ^Use -split-objs with GHC, if available
progPrefix :: PathTemplate, -- ^Prefix to be prepended to installed executables
progSuffix :: PathTemplate -- ^Suffix to be appended to installed executables
} deriving (Read, Show)
......@@ -118,3 +122,11 @@ prefixRelativeInstallDirs pkg_descr lbi =
(compilerId (compiler lbi))
(installDirTemplates lbi)
substPathTemplate :: PackageDescription -> LocalBuildInfo
-> PathTemplate -> FilePath
substPathTemplate pkg_descr lbi = fromPathTemplate
. ( InstallDirs.substPathTemplate env )
where env = initialPathTemplateEnv
(package pkg_descr)
(compilerId (compiler lbi))
......@@ -216,6 +216,8 @@ data ConfigFlags = ConfigFlags {
configProfExe :: Flag Bool, -- ^Enable profiling in the executables.
configConfigureArgs :: [String], -- ^Extra arguments to @configure@
configOptimization :: Flag Bool, -- ^Enable optimization.
configProgPrefix :: Flag PathTemplate, -- ^Installed executable prefix.
configProgSuffix :: Flag PathTemplate, -- ^Installed executable suffix.
configInstallDirs :: InstallDirs (Flag PathTemplate), -- ^Installation paths
configScratchDir :: Flag FilePath,
......@@ -237,6 +239,8 @@ defaultConfigFlags progConf = emptyConfigFlags {
configSharedLib = Flag False,
configProfExe = Flag False,
configOptimization = Flag True,
configProgPrefix = Flag (toPathTemplate ""),
configProgSuffix = Flag (toPathTemplate ""),
configVerbose = Flag normal,
configUserInstall = Flag False, --TODO: reverse this
configGHCiLib = Flag True,
......@@ -340,13 +344,14 @@ configureCommand progConf = makeCommand name shortDesc longDesc defaultFlags opt
,option "" ["program-prefix"]
"prefix to be applied to installed executables"
progprefix (\v flags -> flags { progprefix = v } )
(installDirArgTitle "PREFIX")
configProgPrefix
(\v flags -> flags { configProgPrefix = v })
(reqPathTemplateArgFlag "PREFIX")
,option "" ["program-suffix"]
"suffix to be applied to installed executables"
progsuffix (\v flags -> flags { progsuffix = v } )
(installDirArgTitle "SUFFIX")
configProgSuffix (\v flags -> flags { configProgSuffix = v } )
(reqPathTemplateArgFlag "SUFFIX")
,option "" ["enable-library-vanilla"]
"Enable vanilla libraries"
......@@ -464,12 +469,14 @@ configureCommand progConf = makeCommand name shortDesc longDesc defaultFlags opt
showFlagList :: [(String, Bool)] -> [String]
showFlagList fs = [ if not set then '-':fname else fname | (fname, set) <- fs]
installDirArgTitle title get set = reqArgFlag title
installDirArg get set = reqArgFlag "DIR"
(fmap fromPathTemplate.get.configInstallDirs)
(\v flags -> flags { configInstallDirs =
set (fmap toPathTemplate v) (configInstallDirs flags)})
installDirArg = installDirArgTitle "DIR"
reqPathTemplateArgFlag title get set = reqArgFlag title
(fmap fromPathTemplate.get)
(\v flags -> set (fmap toPathTemplate v) flags)
emptyConfigFlags :: ConfigFlags
emptyConfigFlags = mempty
......@@ -488,6 +495,8 @@ instance Monoid ConfigFlags where
configProfExe = mempty,
configConfigureArgs = mempty,
configOptimization = mempty,
configProgPrefix = mempty,
configProgSuffix = mempty,
configInstallDirs = mempty,
configScratchDir = mempty,
configVerbose = mempty,
......@@ -510,6 +519,8 @@ instance Monoid ConfigFlags where
configProfExe = combine configProfExe,
configConfigureArgs = combine configConfigureArgs,
configOptimization = combine configOptimization,
configProgPrefix = combine configProgPrefix,
configProgSuffix = combine configProgSuffix,
configInstallDirs = combine configInstallDirs,
configScratchDir = combine configScratchDir,
configVerbose = combine configVerbose,
......
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