Commit 064996dd authored by ijones's avatar ijones
Browse files

fixed pathSeparator typo, moved to pathJoin (rather than ++pathSeparatorString)

parent 95380127
......@@ -109,7 +109,7 @@ emptyPackageDescription
allModules = [],
mainModules = [],
cSources = [],
hsSourceDir = ".",
hsSourceDir = ".", -- FIX: FileUtils.currentDir
exposedModules = [],
extensions = [],
extraLibs = [],
......
......@@ -62,7 +62,7 @@ import Distribution.Simple.Register ( register, unregister )
import Distribution.Simple.Configure(LocalBuildInfo(..), getPersistBuildConfig,
configure, writePersistBuildConfig)
import Distribution.Simple.Install(install)
import Distribution.Simple.Utils (die, pathSeperatorStr)
import Distribution.Simple.Utils (die, pathJoin)
import Distribution.Misc (License(..))
import Distribution.Version (Version(..))
......@@ -90,8 +90,8 @@ defaultMain :: PackageDescription -> IO ()
defaultMain pkg_descr
= do args <- getArgs
let distPref = "dist"
let buildPref = distPref ++ pathSeperatorStr ++ "build"
let srcPref = distPref ++ pathSeperatorStr ++ "src"
let buildPref = pathJoin [distPref, "build"]
let srcPref = pathJoin [distPref, "src"]
case parseArgs args of
Right (HelpCmd, _) -> hPutStr stderr (optionHelpString helpprefix)
......
......@@ -53,8 +53,8 @@ import Distribution.Package (PackageDescription(..), showPackageId)
import Distribution.Simple.Configure (LocalBuildInfo, compiler)
import Distribution.Simple.Utils (rawSystemExit, setupMessage,
die, rawSystemPathExit,
pathSeperatorStr, split, createIfNotExists,
mkLibName, moveSources
split, createIfNotExists,
mkLibName, moveSources, pathJoin
)
......@@ -104,7 +104,7 @@ buildGHC pref pkg_descr lbi = do
-- now, build the library
let objs = map (++objsuffix) (map dotToSep (allModules pkg_descr))
lib = mkLibName pref (showPackageId (package pkg_descr))
rawSystemPathExit "ar" (["q", lib] ++ (map ((pref ++ pathSeperatorStr) ++) objs))
rawSystemPathExit "ar" (["q", lib] ++ [pathJoin [pref, x] | x <- objs])
constructGHCCmdLine :: FilePath -> PackageDescription -> LocalBuildInfo -> [String]
constructGHCCmdLine pref pkg_descr _ =
......@@ -130,7 +130,7 @@ objsuffix = ".o"
#endif
dotToSep :: String -> String
dotToSep s = concat $ intersperse pathSeperatorStr (split '.' s)
dotToSep s = pathJoin (split '.' s)
-- |Copy and (possibly) preprocess sources from hsSourceDirs
preprocessSources :: PackageDescription
......
......@@ -53,7 +53,7 @@ module Distribution.Simple.Install (
import Distribution.Package (PackageDescription(..), showPackageId)
import Distribution.Simple.Configure(LocalBuildInfo(..))
import Distribution.Simple.Utils(setupMessage, moveSources,
pathSeperatorStr, mkLibName, pathJoin,
mkLibName, pathJoin,
copyFile, die
)
import Distribution.Setup (CompilerFlavor(..), Compiler(..))
......
......@@ -49,7 +49,7 @@ module Distribution.Simple.SrcDist (
import Distribution.Package(PackageDescription(..), showPackageId)
import Distribution.Simple.Configure(LocalBuildInfo)
import Distribution.Simple.Utils(setupMessage, moveSources, pathSeperatorStr, die)
import Distribution.Simple.Utils(setupMessage, moveSources, die, pathJoin)
import Control.Monad(when)
import System.Cmd (system)
......@@ -68,10 +68,10 @@ sdist srcPref targetPref pkg_descr _ = do
setupMessage "Building source dist for" pkg_descr
ex <- doesDirectoryExist srcPref
when ex (die $ "Source distribution already in place. please move: " ++ srcPref)
moveSources "" (srcPref++pathSeperatorStr++nameVersion pkg_descr)
moveSources "" (pathJoin [srcPref, nameVersion pkg_descr])
(allModules pkg_descr) (mainModules pkg_descr) ["lhs", "hs"]
system $ "tar --directory=" ++ srcPref ++ " -zcf "
++ targetPref ++ pathSeperatorStr ++ (tarBallName pkg_descr)
system $ "tar --directory=" ++ srcPref ++ " -zcf " ++
(pathJoin [targetPref, tarBallName pkg_descr])
++ " " ++ (nameVersion pkg_descr)
system $ "rm -rf " ++ srcPref
putStrLn "Source tarball created."
......
......@@ -46,7 +46,7 @@ module Distribution.Simple.Utils (
splitFilenameDir,
split,
isPathSeparator,
pathSeperatorStr,
pathSeparatorStr,
setupMessage,
die,
findBinary,
......@@ -179,11 +179,15 @@ rawSystemPathExit prog args = do
-- |FIX: Do we actually have to make something differnet for windows,
-- or does this work?
pathSeperator :: Char
pathSeperator = '/'
pathSeparator :: Char
#ifdef mingw32_TARGET_OS
pathSeparator = '\\'
#else
pathSeparator = '/'
#endif
pathSeperatorStr :: String
pathSeperatorStr = [pathSeperator]
pathSeparatorStr :: String
pathSeparatorStr = [pathSeparator]
createIfNotExists :: Bool -- ^Create its parents too?
-> FilePath -- ^The path to the directory you want to make
......@@ -204,8 +208,7 @@ createDirectoryParents file
-- |Get this path and all its parents.
pathInits :: FilePath -> [FilePath]
pathInits path
= map (concat . intersperse pathSeperatorStr)
(inits $ mySplit pathSeperator path)
= map pathJoin (inits $ mySplit pathSeparator path)
-- |Give a list of lists breaking apart elements who match the given criteria
......@@ -220,14 +223,14 @@ mySplit a l = let (upto, rest) = break (== a) l
-- Foo/Bar.lhs into Foo
removeFilename :: FilePath -> FilePath
removeFilename path
= case findIndices (== pathSeperator) path of
= case findIndices (== pathSeparator) path of
[] -> path
l -> fst $ splitAt (maximum l) path
-- |If this filename doesn't end in the path separator, add it.
maybeAddSep :: FilePath -> FilePath
maybeAddSep [] = []
maybeAddSep p = if last p == pathSeperator then p else p ++ pathSeperatorStr
maybeAddSep p = if last p == pathSeparator then p else p ++ pathSeparatorStr
-- |Get the file path for this particular module. In the IO monad
-- because it looks for the actual file. Might eventually interface
......@@ -255,8 +258,7 @@ moduleToPossiblePaths searchPref s possibleSuffixes
= let splitted = mySplit '.' s
lastElem = last splitted
pref = if (not $ null $ init splitted)
then concat (intersperse pathSeperatorStr (init splitted))
++ pathSeperatorStr
then maybeAddSep (pathJoin (init splitted))
else ""
in [(maybeAddSep searchPref) ++ pref ++ x
| x <- map (lastElem++) (map ("."++)possibleSuffixes)]
......@@ -298,11 +300,11 @@ moveSources pref _targetDir sources mains searchSuffixes
mkLibName :: FilePath -- ^file Prefix
-> String -- ^library name.
-> String
mkLibName pref lib = pref ++ pathSeperatorStr ++ "libHS" ++ lib ++ ".a"
mkLibName pref lib = pathJoin [pref, ("libHS" ++ lib ++ ".a")]
-- | Create a path from a list of path elements
pathJoin :: [String] -> FilePath
pathJoin = concat . intersperse pathSeperatorStr
pathJoin = concat . intersperse pathSeparatorStr
-- FIX: does not preserve dates, does not set permissions
copyFile :: FilePath -> FilePath -> IO ()
......
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