Commit 58cfeb36 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Add ModuleName as a new type instead of using String everywhere

parent 4342f8ef
......@@ -54,6 +54,7 @@ Library
Distribution.InstalledPackageInfo,
Distribution.License,
Distribution.Make,
Distribution.ModuleName,
Distribution.Package,
Distribution.PackageDescription,
Distribution.PackageDescription.Configuration,
......
......@@ -66,6 +66,8 @@ import Distribution.Package
, packageName, packageVersion )
import qualified Distribution.Package as Package
( Package(..), PackageFixedDeps(..) )
import Distribution.ModuleName
( ModuleName )
import Distribution.Version
( Version(..) )
import Distribution.Text
......@@ -118,7 +120,7 @@ instance Package.Package (InstalledPackageInfo_ str) where
instance Package.PackageFixedDeps (InstalledPackageInfo_ str) where
depends = depends
type InstalledPackageInfo = InstalledPackageInfo_ String
type InstalledPackageInfo = InstalledPackageInfo_ ModuleName
emptyInstalledPackageInfo :: InstalledPackageInfo_ m
emptyInstalledPackageInfo
......@@ -242,10 +244,10 @@ installedFieldDescrs = [
boolField "exposed"
exposed (\val pkg -> pkg{exposed=val})
, listField "exposed-modules"
text parseModuleNameQ
disp parseModuleNameQ
exposedModules (\xs pkg -> pkg{exposedModules=xs})
, listField "hidden-modules"
text parseModuleNameQ
disp parseModuleNameQ
hiddenModules (\xs pkg -> pkg{hiddenModules=xs})
, listField "import-dirs"
showFilePath parseFilePathQ
......
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.ModuleName
-- Copyright : Duncan Coutts 2008
--
-- Maintainer : Duncan Coutts <duncan@haskell.org>
-- Stability : alpha
-- Portability : portable
--
-- Haskell module names
{- All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Isaac Jones nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.ModuleName (
ModuleName,
simple,
components,
toFilePath,
main,
) where
import Distribution.Text
( Text(..) )
import qualified Distribution.Compat.ReadP as Parse
import qualified Text.PrettyPrint as Disp
import qualified Data.Char as Char
( isAlphaNum, isUpper )
import System.FilePath
( pathSeparator )
import Data.List
( intersperse )
import Control.Exception
( assert )
newtype ModuleName = ModuleName [String]
deriving (Eq, Ord, Read, Show)
instance Text ModuleName where
disp (ModuleName ms) =
Disp.hcat (intersperse (Disp.char '.') (map Disp.text ms))
parse = do
ms <- Parse.sepBy1 component (Parse.char '.')
return (ModuleName ms)
where
component = do
c <- Parse.satisfy Char.isUpper
cs <- Parse.munch (\x -> Char.isAlphaNum x || x == '_' || x == '\'')
return (c:cs)
simple :: String -> ModuleName
simple name = assert (all (/='.') name)
(ModuleName [name])
main :: ModuleName
main = ModuleName ["Main"]
components :: ModuleName -> [String]
components (ModuleName ms) = ms
toFilePath :: ModuleName -> FilePath
toFilePath = concat . intersperse [pathSeparator] . components
......@@ -86,6 +86,7 @@ import qualified Data.Char as Char (isAlphaNum)
import Distribution.Package
( PackageName(PackageName), PackageIdentifier(PackageIdentifier)
, Dependency, Package(..) )
import Distribution.ModuleName (ModuleName)
import Distribution.Version (Version(Version), VersionRange(AnyVersion))
import Distribution.License (License(AllRightsReserved))
import Distribution.Compiler (CompilerFlavor)
......@@ -202,7 +203,7 @@ instance Text BuildType where
-- The Library type
data Library = Library {
exposedModules :: [String],
exposedModules :: [ModuleName],
libBuildInfo :: BuildInfo
}
deriving (Show, Eq, Read)
......@@ -232,7 +233,7 @@ withLib pkg_descr a f =
maybe (return a) f (maybeHasLibs pkg_descr)
-- |Get all the module names from the libraries in this package
libModules :: PackageDescription -> [String]
libModules :: PackageDescription -> [ModuleName]
libModules PackageDescription{library=lib}
= maybe [] exposedModules lib
++ maybe [] (otherModules . libBuildInfo) lib
......@@ -276,7 +277,7 @@ withExe pkg_descr f =
sequence_ [f exe | exe <- executables pkg_descr, buildable (buildInfo exe)]
-- |Get all the module names from the exes in this package
exeModules :: PackageDescription -> [String]
exeModules :: PackageDescription -> [ModuleName]
exeModules PackageDescription{executables=execs}
= concatMap (otherModules . buildInfo) execs
......@@ -307,7 +308,7 @@ data BuildInfo = BuildInfo {
frameworks :: [String], -- ^support frameworks for Mac OS X
cSources :: [FilePath],
hsSourceDirs :: [FilePath], -- ^ where to look for the haskell module hierarchy
otherModules :: [String], -- ^ non-exposed or non-main modules
otherModules :: [ModuleName], -- ^ non-exposed or non-main modules
extensions :: [Extension],
extraLibs :: [String], -- ^ what libraries to link with when compiling a program that uses your package
extraLibDirs :: [String],
......
......@@ -194,7 +194,7 @@ checkLibrary lib =
"Duplicate modules in library: " ++ commaSep moduleDuplicates
]
where moduleDuplicates = [ module_
where moduleDuplicates = [ display module_
| let modules = exposedModules lib
++ otherModules (libBuildInfo lib)
, (module_:_:_) <- group (sort modules) ]
......@@ -219,7 +219,7 @@ checkExecutable exe =
++ commaSep moduleDuplicates
]
where moduleDuplicates = [ module_
where moduleDuplicates = [ display module_
| let modules = otherModules (buildInfo exe)
, (module_:_:_) <- group (sort modules) ]
......
......@@ -167,7 +167,7 @@ storeXFieldsPD _ _ = Nothing
libFieldDescrs :: [FieldDescr Library]
libFieldDescrs = map biToLib binfoFieldDescrs
++ [
listField "exposed-modules" text parseModuleNameQ
listField "exposed-modules" disp parseModuleNameQ
exposedModules (\mods lib -> lib{exposedModules=mods})
]
where biToLib = liftField libBuildInfo (\bi lib -> lib{libBuildInfo=bi})
......@@ -251,7 +251,7 @@ binfoFieldDescrs =
showFilePath parseFilePathQ
hsSourceDirs (\paths binfo -> binfo{hsSourceDirs=paths})
, listField "other-modules"
text parseModuleNameQ
disp parseModuleNameQ
otherModules (\val binfo -> binfo{otherModules=val})
, listField "ghc-prof-options"
text parseTokenQ
......
......@@ -64,6 +64,7 @@ import Distribution.Compiler (CompilerFlavor, parseCompilerFlavorCompat)
import Distribution.License
import Distribution.Version
import Distribution.Package ( PackageName(..), Dependency(..) )
import Distribution.ModuleName (ModuleName)
import Distribution.Compat.ReadP as ReadP hiding (get)
import Distribution.ReadE
import Distribution.Text
......@@ -72,7 +73,7 @@ import Distribution.Simple.Utils (intercalate, lowercase)
import Language.Haskell.Extension (Extension)
import Text.PrettyPrint.HughesPJ hiding (braces)
import Data.Char (isSpace, isUpper, toLower, isAlphaNum, isDigit)
import Data.Char (isSpace, toLower, isAlphaNum, isDigit)
import Data.Maybe (fromMaybe)
import Data.Tree as Tree (Tree(..), flatten)
import System.FilePath (normalise)
......@@ -518,12 +519,8 @@ ifelse (f:fs) = do fs' <- ifelse fs
------------------------------------------------------------------------------
-- |parse a module name
parseModuleNameQ :: ReadP r String
parseModuleNameQ = parseQuoted modu <++ modu
where modu = do
c <- satisfy isUpper
cs <- munch (\x -> isAlphaNum x || x `elem` "_'.")
return (c:cs)
parseModuleNameQ :: ReadP r ModuleName
parseModuleNameQ = parseQuoted parse <++ parse
parseFilePathQ :: ReadP r FilePath
parseFilePathQ = parseTokenQ
......
......@@ -52,6 +52,7 @@ import Distribution.PackageDescription
Executable(..), Library(..) )
import Distribution.Package
( Package(..), packageName, packageVersion )
import qualified Distribution.ModuleName as ModuleName
import Distribution.Simple.Setup ( CopyDest(..), BuildFlags(..),
MakefileFlags(..), fromFlag )
import Distribution.Simple.PreProcess ( preprocessSources, PPSuffixHandler )
......@@ -66,7 +67,7 @@ import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, die, setupMessage, writeUTF8File )
import Distribution.System
import System.FilePath ( (</>), pathSeparator )
import System.FilePath ( (</>), (<.>), pathSeparator )
import Data.Maybe ( maybeToList, fromJust, isNothing )
import Control.Monad ( unless, when )
......@@ -165,7 +166,7 @@ buildPathsModule distPref pkg_descr lbi =
header =
pragmas++
"module " ++ paths_modulename ++ " (\n"++
"module " ++ display paths_modulename ++ " (\n"++
"\tversion,\n"++
"\tgetBinDir, getLibDir, getDataDir, getLibexecDir,\n"++
"\tgetDataFileName\n"++
......@@ -262,7 +263,7 @@ buildPathsModule distPref pkg_descr lbi =
supportsRelocatableProgs _ = False
paths_modulename = autogenModuleName pkg_descr
paths_filename = paths_modulename ++ ".hs"
paths_filename = ModuleName.toFilePath paths_modulename <.> "hs"
paths_filepath = autogenModulesDir lbi </> paths_filename
isHugs = compilerFlavor (compiler lbi) == Hugs
......
......@@ -64,6 +64,8 @@ import System.FilePath (FilePath, (</>), (<.>))
import Distribution.Package
( PackageIdentifier, packageName )
import Distribution.ModuleName (ModuleName)
import qualified Distribution.ModuleName as ModuleName
import Distribution.Compiler
( CompilerId(..) )
import Distribution.PackageDescription (PackageDescription)
......@@ -92,9 +94,9 @@ autogenModulesDir lbi = buildDir lbi </> "autogen"
-- |The name of the auto-generated module associated with a package
autogenModuleName :: PackageDescription -> String
autogenModuleName :: PackageDescription -> ModuleName
autogenModuleName pkg_descr =
"Paths_" ++ map fixchar (display (packageName pkg_descr))
ModuleName.simple $ "Paths_" ++ map fixchar (display (packageName pkg_descr))
where fixchar '-' = '_'
fixchar c = c
......
......@@ -70,6 +70,7 @@ import Distribution.Simple.BuildPaths
import Distribution.Simple.Utils
import Distribution.Package
( PackageIdentifier, Package(..) )
import qualified Distribution.ModuleName as ModuleName
import Distribution.Simple.Program
( Program(..), ConfiguredProgram(..), ProgramConfiguration
, rawSystemProgram, rawSystemProgramConf
......@@ -375,7 +376,7 @@ build pkg_descr lbi verbosity = do
let ghcArgs =
["-package-name", display pkgid ]
++ constructGHCCmdLine lbi libBi libTargetDir verbosity
++ (libModules pkg_descr)
++ map display (libModules pkg_descr)
ghcArgsProf = ghcArgs
++ ["-prof",
"-hisuf", "p_hi",
......@@ -415,15 +416,15 @@ build pkg_descr lbi verbosity = do
stubObjs <- fmap catMaybes $ sequence
[ findFileWithExtension [objExtension] [libTargetDir]
(dotToSep x ++"_stub")
(ModuleName.toFilePath x ++"_stub")
| x <- libModules pkg_descr ]
stubProfObjs <- fmap catMaybes $ sequence
[ findFileWithExtension ["p_" ++ objExtension] [libTargetDir]
(dotToSep x ++"_stub")
(ModuleName.toFilePath x ++"_stub")
| x <- libModules pkg_descr ]
stubSharedObjs <- fmap catMaybes $ sequence
[ findFileWithExtension ["dyn_" ++ objExtension] [libTargetDir]
(dotToSep x ++"_stub")
(ModuleName.toFilePath x ++"_stub")
| x <- libModules pkg_descr ]
hObjs <- getHaskellObjects pkg_descr libBi lbi
......@@ -576,7 +577,7 @@ getHaskellObjects :: PackageDescription -> BuildInfo -> LocalBuildInfo
-> FilePath -> String -> Bool -> IO [FilePath]
getHaskellObjects pkg_descr _ lbi pref wanted_obj_ext allow_split_objs
| splitObjs lbi && allow_split_objs = do
let dirs = [ pref </> (dotToSep x ++ "_split")
let dirs = [ pref </> (ModuleName.toFilePath x ++ "_split")
| x <- libModules pkg_descr ]
objss <- mapM getDirectoryContents dirs
let objs = [ dir </> obj
......@@ -585,7 +586,7 @@ getHaskellObjects pkg_descr _ lbi pref wanted_obj_ext allow_split_objs
'.':wanted_obj_ext == obj_ext ]
return objs
| otherwise =
return [ pref </> dotToSep x <.> wanted_obj_ext
return [ pref </> ModuleName.toFilePath x <.> wanted_obj_ext
| x <- libModules pkg_descr ]
......@@ -682,7 +683,7 @@ makefile pkg_descr lbi flags = do
let builddir = buildDir lbi
Just ghcProg = lookupProgram ghcProgram (withPrograms lbi)
let decls = [
("modules", unwords (exposedModules lib ++ otherModules bi)),
("modules", unwords (map display (exposedModules lib ++ otherModules bi))),
("GHC", programPath ghcProg),
("GHC_VERSION", (display (compilerVersion (compiler lbi)))),
("WAYS", (if withProfLib lbi then "p " else "") ++ (if withSharedLib lbi then "dyn" else "")),
......
......@@ -53,6 +53,8 @@ import qualified Distribution.Package as Current hiding (depends)
import qualified Distribution.License as Current
import Distribution.Version (Version)
import Distribution.ModuleName (ModuleName)
import Distribution.Text (simpleParse)
-- | This is the InstalledPackageInfo type used by ghc-6.4.2 and later.
--
......@@ -110,8 +112,8 @@ convertPackageId :: PackageIdentifier -> Current.PackageIdentifier
convertPackageId PackageIdentifier { pkgName = n, pkgVersion = v } =
Current.PackageIdentifier (Current.PackageName n) v
convertModuleName :: String -> String
convertModuleName s = s
convertModuleName :: String -> ModuleName
convertModuleName s = m where Just m = simpleParse s
convertLicense :: License -> Current.License
convertLicense GPL = Current.GPL
......
......@@ -48,6 +48,7 @@ module Distribution.Simple.Haddock (
-- local
import Distribution.Package
( PackageIdentifier, Package(..) )
import qualified Distribution.ModuleName as ModuleName
import Distribution.PackageDescription as PD
(PackageDescription(..), BuildInfo(..), hcOptions,
Library(..), hasLibs, withLib,
......@@ -78,7 +79,7 @@ import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo
import Distribution.Simple.Utils
( die, warn, notice, intercalate, setupMessage
, createDirectoryIfMissingVerbose, withTempFile
, findFileWithExtension, findFile, dotToSep )
, findFileWithExtension, findFile )
import Distribution.Text
( display, simpleParse )
......@@ -207,13 +208,14 @@ haddock pkg_descr lbi suffixes flags = do
hPutStrLn prologFileHandle prolog
hClose prologFileHandle
let targets
| isVersion2 = modules
| isVersion2 = map display modules
| otherwise = replaceLitExts inFiles
let haddockFile = haddockPref distPref pkg_descr
</> haddockName pkg_descr
-- FIX: replace w/ rawSystemProgramConf?
let hideArgs | fromFlag (haddockInternal flags) = []
| otherwise = map ("--hide=" ++) (otherModules bi)
| otherwise = [ "--hide=" ++ display m
| m <- otherModules bi ]
let exportsFlags | fromFlag (haddockInternal flags) = ["--ignore-all-exports"]
| otherwise = []
rawSystemProgram verbosity confHaddock
......@@ -251,7 +253,7 @@ haddock pkg_descr lbi suffixes flags = do
hPutStrLn prologFileHandle prolog
hClose prologFileHandle
let targets
| isVersion2 = srcMainPath : otherModules bi
| isVersion2 = srcMainPath : map display (otherModules bi)
| otherwise = replaceLitExts inFiles
let preprocessDir = buildDir lbi </> exeName exe </> exeName exe ++ "-tmp"
let exportsFlags | fromFlag (haddockInternal flags) = ["--ignore-all-exports"]
......@@ -365,7 +367,8 @@ hscolour pkg_descr lbi suffixes flags = do
preprocessSources pkg_descr lbi False verbosity suffixes
setupMessage verbosity "Running hscolour for" (packageId pkg_descr)
let replaceDot = map (\c -> if c == '.' then '-' else c)
let moduleNameToHtmlFilePath mn =
intercalate "-" (ModuleName.components mn) <.> "html"
withLib pkg_descr () $ \lib -> when (isJust $ library pkg_descr) $ do
let bi = libBuildInfo lib
......@@ -375,19 +378,19 @@ hscolour pkg_descr lbi suffixes flags = do
copyCSS hscolourProg outputDir
inFiles <- getLibSourceFiles lbi lib
flip mapM_ (zip modules inFiles) $ \(mo, inFile) ->
let outFile = outputDir </> replaceDot mo <.> "html"
let outFile = outputDir </> moduleNameToHtmlFilePath mo
in rawSystemProgram verbosity hscolourProg
["-css", "-anchor", "-o" ++ outFile, inFile]
withExe pkg_descr $ \exe -> when doExes $ do
let bi = buildInfo exe
modules = "Main" : otherModules bi
modules = ModuleName.main : otherModules bi
outputDir = hscolourPref distPref pkg_descr </> exeName exe </> "src"
createDirectoryIfMissingVerbose verbosity True outputDir
copyCSS hscolourProg outputDir
inFiles <- getExeSourceFiles lbi exe
flip mapM_ (zip modules inFiles) $ \(mo, inFile) ->
let outFile = outputDir </> replaceDot mo <.> "html"
let outFile = outputDir </> moduleNameToHtmlFilePath mo
in rawSystemProgram verbosity hscolourProg
["-css", "-anchor", "-o" ++ outFile, inFile]
......@@ -405,24 +408,24 @@ hscolour pkg_descr lbi suffixes flags = do
getLibSourceFiles :: LocalBuildInfo -> Library -> IO [FilePath]
getLibSourceFiles lbi lib = sequence
[ findFileWithExtension ["hs", "lhs"] (preprocessDir : hsSourceDirs bi)
(dotToSep module_) >>= maybe (notFound module_) (return . normalise)
(ModuleName.toFilePath module_) >>= maybe (notFound module_) (return . normalise)
| module_ <- modules ]
where
bi = libBuildInfo lib
modules = PD.exposedModules lib ++ otherModules bi
preprocessDir = buildDir lbi
notFound module_ = die $ "can't find source for module " ++ module_
notFound module_ = die $ "can't find source for module " ++ display module_
getExeSourceFiles :: LocalBuildInfo -> Executable -> IO [FilePath]
getExeSourceFiles lbi exe = do
srcMainPath <- findFile (hsSourceDirs bi) (modulePath exe)
moduleFiles <- sequence
[ findFileWithExtension ["hs", "lhs"] (preprocessDir : hsSourceDirs bi)
(dotToSep module_) >>= maybe (notFound module_) (return . normalise)
(ModuleName.toFilePath module_) >>= maybe (notFound module_) (return . normalise)
| module_ <- modules ]
return (srcMainPath : moduleFiles)
where
bi = buildInfo exe
modules = otherModules bi
preprocessDir = buildDir lbi </> exeName exe </> exeName exe ++ "-tmp"
notFound module_ = die $ "can't find source for module " ++ module_
notFound module_ = die $ "can't find source for module " ++ display module_
......@@ -47,6 +47,8 @@ module Distribution.Simple.Hugs (
import Distribution.PackageDescription
( PackageDescription(..), BuildInfo(..), hcOptions,
Executable(..), withExe, Library(..), withLib, libModules )
import Distribution.ModuleName (ModuleName)
import qualified Distribution.ModuleName as ModuleName
import Distribution.Simple.Compiler
( CompilerFlavor(..), CompilerId(..), Compiler(..), Flag )
import Distribution.Simple.Program ( ProgramConfiguration, userMaybeSpecifyPath,
......@@ -64,7 +66,7 @@ import Distribution.Simple.BuildPaths
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose
, withUTF8FileContents, writeFileAtomic
, findFile, dotToSep, findFileWithExtension, smartCopySources
, findFile, findFileWithExtension, smartCopySources
, die, info, notice )
import Language.Haskell.Extension
( Extension(..) )
......@@ -72,6 +74,8 @@ import System.FilePath ( (</>), takeExtension, (<.>),
searchPathSeparator, normalise, takeDirectory )
import Distribution.System
( OS(..), buildOS )
import Distribution.Text
( display )
import Distribution.Verbosity
import Data.Char ( isSpace )
......@@ -142,7 +146,8 @@ build pkg_descr lbi verbosity = do
where
srcDir = buildDir lbi
paths_modulename = autogenModuleName pkg_descr ++ ".hs"
paths_modulename = ModuleName.toFilePath (autogenModuleName pkg_descr)
<.> ".hs"
compileExecutable :: FilePath -> Executable -> IO ()
compileExecutable destDir (exe@Executable {modulePath=mainPath, buildInfo=bi}) = do
......@@ -159,7 +164,7 @@ build pkg_descr lbi verbosity = do
compileBuildInfo :: FilePath -- ^output directory
-> [FilePath] -- ^library source dirs, if building exes
-> [String] -- ^Modules
-> [ModuleName] -- ^Modules
-> BuildInfo -> IO ()
compileBuildInfo destDir mLibSrcDirs mods bi = do
-- Pass 1: copy or cpp files from build directory to scratch directory
......@@ -167,17 +172,17 @@ build pkg_descr lbi verbosity = do
let srcDirs = nub $ srcDir : hsSourceDirs bi ++ mLibSrcDirs
info verbosity $ "Source directories: " ++ show srcDirs
flip mapM_ mods $ \ m -> do
fs <- findFileWithExtension suffixes srcDirs (dotToSep m)
fs <- findFileWithExtension suffixes srcDirs (ModuleName.toFilePath m)
case fs of
Nothing ->
die ("can't find source for module " ++ m)
die ("can't find source for module " ++ display m)
Just srcFile -> do
let ext = takeExtension srcFile
copyModule useCpp bi srcFile
(destDir </> dotToSep m <.> ext)
(destDir </> ModuleName.toFilePath m <.> ext)
-- Pass 2: compile foreign stubs in scratch directory
stubsFileLists <- fmap catMaybes $ sequence
[ findFileWithExtension suffixes [destDir] (dotToSep modu)
[ findFileWithExtension suffixes [destDir] (ModuleName.toFilePath modu)
| modu <- mods]
compileFiles bi destDir stubsFileLists
......@@ -368,7 +373,9 @@ install verbosity libDir installProgDir binDir targetProgDir buildPref (progpref
let targetDir = targetProgDir </> exeName exe
try $ removeDirectoryRecursive installDir
smartCopySources verbosity [theBuildDir] installDir
("Main" : autogenModuleName pkg_descr : otherModules (buildInfo exe)) hugsInstallSuffixes
(ModuleName.main : autogenModuleName pkg_descr
: otherModules (buildInfo exe))
hugsInstallSuffixes
let targetName = "\"" ++ (targetDir </> hugsMainFilename exe) ++ "\""
-- FIX (HUGS): use extensions, and options from file too?
-- see http://hackage.haskell.org/trac/hackage/ticket/43
......
......@@ -138,7 +138,8 @@ build pkg_descr lbi verbosity = do
info verbosity "Building library..."
let libBi = libBuildInfo lib
let args = constructJHCCmdLine lbi libBi (buildDir lbi) verbosity
rawSystemProgram verbosity jhcProg (["-c"] ++ args ++ libModules pkg_descr)
rawSystemProgram verbosity jhcProg $
["-c"] ++ args ++ map display (libModules pkg_descr)
let pkgid = display (packageId pkg_descr)
pfile = buildDir lbi </> "jhc-pkg.conf"
hlfile= buildDir lbi </> (pkgid ++ ".hl")
......@@ -166,7 +167,7 @@ jhcPkgConf :: PackageDescription -> String
jhcPkgConf pd =
let sline name sel = name ++ ": "++sel pd
Just lib = library pd
comma = intercalate ","
comma = intercalate "," . map display
in unlines [sline "name" (display . packageId)
,"exposed-modules: " ++ (comma (PD.exposedModules lib))
,"hidden-modules: " ++ (comma (otherModules $ libBuildInfo lib))
......
......@@ -50,6 +50,8 @@ import Distribution.Package
import Distribution.PackageDescription
( PackageDescription(..), BuildInfo(..), Library(..), Executable(..),
withLib, withExe, hcOptions )
import Distribution.ModuleName (ModuleName)
import qualified Distribution.ModuleName as ModuleName
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(..) )
import Distribution.Simple.BuildPaths
......@@ -65,7 +67,7 @@ import Distribution.Simple.Program
nhcProgram, hmakeProgram, ldProgram, arProgram,
rawSystemProgramConf )
import Distribution.Simple.Utils
( die, info, findFileWithExtension, dotToSep,
( die, info, findFileWithExtension,
createDirectoryIfMissingVerbose, copyFileVerbose, smartCopySources )
import Distribution.Version
( Version(..), VersionRange(..), orLaterVersion )
......@@ -172,7 +174,7 @@ build pkg_descr lbi verbosity = do
let --cObjs = [ targetDir </> cFile `replaceExtension` objExtension
-- | cFile <- cSources bi ]
libFilePath = targetDir </> mkLibName (packageId pkg_descr)
hObjs = [ targetDir </> dotToSep m <.> objExtension
hObjs = [ targetDir </> ModuleName.toFilePath m <.> objExtension
| m <- modules ]
unless (null hObjs {-&& null cObjs-}) $ do
......@@ -221,12 +223,12 @@ nhcVerbosityOptions verbosity
| otherwise = ["-q"]
--TODO: where to put this? it's duplicated in .Simple too