Commit 84d769c9 authored by ijones's avatar ijones
Browse files

basic NHC build implementation with hmake

parent c4c73a51
......@@ -60,9 +60,24 @@ build :: PackageDescription -> LocalBuildInfo -> IO ()
build pkg_descr lbi = do
setupMessage "Building" pkg_descr
when (compilerFlavor (compiler lbi) /= GHC) $
die ("only building with GHC is implemented")
case compilerFlavor (compiler lbi) of
GHC -> buildGHC pkg_descr lbi
NHC -> buildNHC pkg_descr lbi
_ -> die ("only building with GHC is implemented")
-- |FIX: For now, the target must contain a main module :(
buildNHC :: PackageDescription -> LocalBuildInfo -> IO ()
buildNHC pkg_descr lbi = do
rawSystemExit (compilerPath (compiler lbi))
(["-nhc98"]
++ extensionsToNHCFlag (extensions pkg_descr)
++ [ opt | (NHC,opts) <- options pkg_descr, opt <- opts ]
++ allModules pkg_descr)
-- |Building for GHC
buildGHC :: PackageDescription -> LocalBuildInfo -> IO ()
buildGHC pkg_descr lbi = do
-- first, build the modules
let args = constructGHCCmdLine pkg_descr lbi
rawSystemExit (compilerPath (compiler lbi)) args
......@@ -89,6 +104,10 @@ constructGHCCmdLine pkg_descr _ =
extensionsToGHCFlag :: [ Extension ] -> [String]
extensionsToGHCFlag _ = [] -- ToDo
extensionsToNHCFlag :: [ Extension ] -> [String]
extensionsToNHCFlag _ = [] -- ToDo
objsuffix :: String
#ifdef mingw32_TARGET_OS
objsuffix = ".obj"
#else
......
......@@ -170,12 +170,12 @@ findCompiler flavor = do
compilerBinaryName :: CompilerFlavor -> String
compilerBinaryName GHC = "ghc"
compilerBinaryName NHC = "nhc98"
compilerBinaryName NHC = "hmake" -- FIX: uses hmake for now
compilerBinaryName Hugs = "hugs"
compilerPkgToolName :: CompilerFlavor -> String
compilerPkgToolName GHC = "ghc-pkg"
compilerPkgToolName NHC = "nhc98-pkg"
compilerPkgToolName NHC = "hmake" -- FIX: nhc98-pkg Does not yet exist
compilerPkgToolName Hugs = "hugs-package"
guessPkgToolFromHCPath :: CompilerFlavor -> FilePath -> IO FilePath
......
......@@ -61,15 +61,14 @@ register :: PackageDescription -> LocalBuildInfo -> IO ()
register pkg_descr lbi = do
setupMessage "Registering" pkg_descr
when (compilerFlavor (compiler lbi) /= GHC) $
die ("only registering with GHC is implemented")
let pkg_config = mkGHCPackageConfig pkg_descr lbi
writeFile installedPkgConfigFile (showGHCPackageConfig pkg_config)
case compilerFlavor (compiler lbi) of
GHC -> do let pkg_config = mkGHCPackageConfig pkg_descr lbi
writeFile installedPkgConfigFile (showGHCPackageConfig pkg_config)
rawSystemExit (compilerPkgTool (compiler lbi))
["--add-package", "--input-file="++installedPkgConfigFile]
_ -> die ("only registering with GHC is implemented")
rawSystemExit (compilerPkgTool (compiler lbi))
["--add-package", "--input-file="++installedPkgConfigFile]
installedPkgConfigFile :: String
installedPkgConfigFile = "installed-pkg-config"
-- -----------------------------------------------------------------------------
......
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