Commit 95380127 authored by ijones's avatar ijones
Browse files

preprocessing and hsSourceDir

** added "preprocessing" from bringert's code
** hugs now doesn't complain on build.
** hugs install now looks in dist directory
** added hsSourceDir field
parent 3ea29a70
......@@ -131,7 +131,7 @@ tests = [TestCase $
instRetCode <- system "./setup install --user"
let targetDir = ",tmp/lib/test-1.0/"
checkTargetDir targetDir [".hs"]
assertEqual "install returned error code" ExitSuccess instRetCode
assertEqual "install HUGS returned error code" ExitSuccess instRetCode
]
main :: IO ()
......
......@@ -88,6 +88,7 @@ data PackageDescription
allModules :: [ String ],
mainModules :: [ String ],
cSources :: [ FilePath ],
hsSourceDir :: FilePath,
exposedModules :: [ String ],
extensions :: [ Extension ],
extraLibs :: [ String ],
......@@ -108,6 +109,7 @@ emptyPackageDescription
allModules = [],
mainModules = [],
cSources = [],
hsSourceDir = ".",
exposedModules = [],
extensions = [],
extraLibs = [],
......
......@@ -54,7 +54,7 @@ import Distribution.Simple.Configure (LocalBuildInfo, compiler)
import Distribution.Simple.Utils (rawSystemExit, setupMessage,
die, rawSystemPathExit,
pathSeperatorStr, split, createIfNotExists,
mkLibName
mkLibName, moveSources
)
......@@ -71,12 +71,14 @@ import HUnit (Test)
build :: FilePath -- ^Build location
-> PackageDescription -> LocalBuildInfo -> IO ()
build pref pkg_descr lbi = do
setupMessage "Building" pkg_descr
createIfNotExists True pref
preprocessSources pkg_descr lbi pref
setupMessage "Building" pkg_descr
case compilerFlavor (compiler lbi) of
GHC -> buildGHC pref pkg_descr lbi
NHC -> buildNHC pkg_descr lbi
_ -> die ("only building with GHC is implemented")
Hugs -> return ()
_ -> die ("building with GHC & NHC is implemented, preprocessing for hugs.")
-- |FIX: For now, the target must contain a main module :(
buildNHC :: PackageDescription -> LocalBuildInfo -> IO ()
......@@ -130,6 +132,20 @@ objsuffix = ".o"
dotToSep :: String -> String
dotToSep s = concat $ intersperse pathSeperatorStr (split '.' s)
-- |Copy and (possibly) preprocess sources from hsSourceDirs
preprocessSources :: PackageDescription
-> LocalBuildInfo
-> FilePath -- ^ Directory to put preprocessed
-- sources in
-> IO ()
preprocessSources pkg_descr lbi pref =
do
setupMessage "Preprocessing" pkg_descr
putStrLn (hsSourceDir pkg_descr)
moveSources (hsSourceDir pkg_descr) pref
(allModules pkg_descr) (mainModules pkg_descr)
["hs","lhs"]
-- Todo: includes, includeDirs
-- ------------------------------------------------------------
......
......@@ -75,7 +75,7 @@ install buildPref pkg_descr lbi install_prefixM = do
setupMessage ("Installing: " ++ pref) pkg_descr
case compilerFlavor (compiler lbi) of
GHC -> installGHC pref buildPref pkg_descr
Hugs -> installHugs pref pkg_descr
Hugs -> installHugs pref buildPref pkg_descr
_ -> die ("only installing with GHC or Hugs is implemented")
return ()
-- register step should be performed by caller.
......@@ -91,9 +91,10 @@ installGHC pref buildPref pkg_descr
-- |Install for hugs, .lhs and .hs
installHugs :: FilePath -- ^Install location
-> FilePath -- ^Build location
-> PackageDescription -> IO ()
installHugs pref pkg_descr
= moveSources "" pref (allModules pkg_descr) (mainModules pkg_descr) ["lhs", "hs"]
installHugs pref buildPref pkg_descr
= moveSources buildPref pref (allModules pkg_descr) (mainModules pkg_descr) ["lhs", "hs"]
-- -----------------------------------------------------------------------------
-- Installation policies
......
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