Commit 02f6ad33 authored by Malcolm.Wallace's avatar Malcolm.Wallace
Browse files

minor tweaks to nhc98 branches of case distinctions

parent 7611bab7
......@@ -77,7 +77,7 @@ import System.Directory ( getModificationTime, doesFileExist)
import qualified Distribution.Simple.GHC as GHC
import qualified Distribution.Simple.JHC as JHC
-- import qualified Distribution.Simple.NHC as NHC
import qualified Distribution.Simple.NHC as NHC
import qualified Distribution.Simple.Hugs as Hugs
import Distribution.PackageDescription (hasLibs)
......@@ -140,6 +140,12 @@ initialBuildSteps pkg_descr lbi verbose suffixes = do
buildPathsModule pkg_descr lbi
preprocessSources pkg_descr lbi verbose suffixes
setupMessage verbose "Building" pkg_descr
case compilerFlavor (compiler lbi) of
GHC -> GHC.build pkg_descr lbi verbose
JHC -> JHC.build pkg_descr lbi verbose
Hugs -> Hugs.build pkg_descr lbi verbose
_ -> die ("Building is not supported with this compiler.")
-- ------------------------------------------------------------
-- * Building Paths_<pkg>.hs
......
......@@ -437,7 +437,7 @@ configCompilerVersion GHC compilerP verbose = do
case pCheck (readP_to_S parseVersion str) of
[v] -> return v
_ -> die ("cannot determine version of " ++ compilerP ++ ":\n "++ str)
configCompilerVersion JHC compilerP verbose = do
configCompilerVersion comp compilerP verbose | comp `elem` [JHC,NHC] = do
str <- systemGetStdout verbose ("\"" ++ compilerP ++ "\" --version")
case words str of
(_:ver:_) -> case pCheck $ readP_to_S parseVersion ver of
......
......@@ -69,7 +69,7 @@ import Distribution.Setup (CopyFlags(..), CopyDest(..))
import qualified Distribution.Simple.GHC as GHC
import qualified Distribution.Simple.JHC as JHC
-- import qualified Distribution.Simple.NHC as NHC
import qualified Distribution.Simple.NHC as NHC
import qualified Distribution.Simple.Hugs as Hugs
import Control.Monad(when)
......@@ -122,6 +122,7 @@ install pkg_descr lbi (CopyFlags copydest verbose) = do
let progPref = mkProgDir pkg_descr lbi copydest
let targetProgPref = mkProgDir pkg_descr lbi NoCopyDest
Hugs.install verbose libPref progPref binPref targetProgPref buildPref pkg_descr
NHC -> die ("installing with nhc98 is not yet implemented")
_ -> die ("only installing with GHC, JHC or Hugs is implemented")
return ()
-- register step should be performed by caller.
......
......@@ -39,9 +39,10 @@ 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.Simple.NHC (
build{-, install -}
) where
module Distribution.Simple.NHC
( build
{-, install -}
) where
import Distribution.PackageDescription
( PackageDescription(..), BuildInfo(..),
......@@ -55,12 +56,16 @@ import Distribution.Compiler ( Compiler(..), CompilerFlavor(..),
-- |FIX: For now, the target must contain a main module. Not used
-- ATM. Re-add later.
build :: PackageDescription -> LocalBuildInfo -> Int -> IO ()
build pkg_descr lbi verbose = do
build pkg_descr lbi verbose =
-- Unsupported extensions have already been checked by configure
let flags = snd $ extensionsToNHCFlag (maybe [] (extensions . libBuildInfo) (library pkg_descr))
let flags = ( snd
. extensionsToNHCFlag
. maybe [] (extensions . libBuildInfo)
. library ) pkg_descr in
rawSystemExit verbose (compilerPath (compiler lbi))
(["-nhc98"]
(["-hc=nhc98"]
++ flags
++ maybe [] (hcOptions NHC . options . libBuildInfo) (library pkg_descr)
++ (libModules pkg_descr))
++ maybe [] (hcOptions NHC . options . libBuildInfo)
(library pkg_descr)
++ libModules pkg_descr)
......@@ -193,7 +193,8 @@ register pkg_descr lbi regFlags
copyFileVerbose verbose installedPkgConfigFile
(the_libdir `joinFileName` "package.conf")
JHC -> when (verbose > 0) $ putStrLn "registering for JHC (nothing to do)"
_ -> die ("only registering with GHC is implemented")
NHC -> when (verbose > 0) $ putStrLn "registering nhc98 (nothing to do)"
_ -> die ("only registering with GHC/Hugs/jhc/nhc98 is implemented")
userPkgConfErr :: String -> IO a
userPkgConfErr local_conf =
......@@ -330,6 +331,9 @@ unregister pkg_descr lbi regFlags = do
Hugs -> do
try $ removeDirectoryRecursive (mkLibDir pkg_descr lbi NoCopyDest)
return ()
NHC -> do
try $ removeDirectoryRecursive (mkLibDir pkg_descr lbi NoCopyDest)
return ()
_ ->
die ("only unregistering with GHC and Hugs is implemented")
......
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