Commit 8e513352 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Rejig calls to per-compiler build functions

So it's now a bit clearer what is going on in the generic build code
Also shift info calls up to generic code
parent aa81a5de
......@@ -79,7 +79,8 @@ import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.BuildPaths
( autogenModulesDir, autogenModuleName, cppHeaderName )
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, die, setupMessage, rewriteFile )
( createDirectoryIfMissingVerbose, rewriteFile
, die, info, setupMessage )
import Distribution.Verbosity
( Verbosity )
......@@ -106,19 +107,32 @@ build pkg_descr lbi flags suffixes = do
verbosity = fromFlag (buildVerbosity flags)
initialBuildSteps distPref pkg_descr lbi verbosity suffixes
setupMessage verbosity "Building" (packageId pkg_descr)
case compilerFlavor (compiler lbi) of
GHC -> withLib pkg_descr (GHC.buildLib verbosity pkg_descr lbi)
>> withExe pkg_descr (GHC.buildExe verbosity pkg_descr lbi)
JHC -> withLib pkg_descr (JHC.buildLib verbosity pkg_descr lbi)
>> withExe pkg_descr (JHC.buildExe verbosity pkg_descr lbi)
LHC -> withLib pkg_descr (LHC.buildLib verbosity pkg_descr lbi)
>> withExe pkg_descr (LHC.buildExe verbosity pkg_descr lbi)
Hugs -> withLib pkg_descr (Hugs.buildLib verbosity pkg_descr lbi)
>> withExe pkg_descr (Hugs.buildExe verbosity pkg_descr lbi)
NHC -> withLib pkg_descr (NHC.buildLib verbosity pkg_descr lbi)
>> withExe pkg_descr (NHC.buildExe verbosity pkg_descr lbi)
_ -> die ("Building is not supported with this compiler.")
withLib pkg_descr $ \lib -> do
info verbosity "Building library..."
buildLib verbosity pkg_descr lbi lib
withExe pkg_descr $ \exe -> do
info verbosity $ "Building executable " ++ exeName exe ++ "..."
buildExe verbosity pkg_descr lbi exe
buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> IO ()
buildLib verbosity pkg_descr lbi lib = case compilerFlavor (compiler lbi) of
GHC -> GHC.buildLib verbosity pkg_descr lbi lib
JHC -> JHC.buildLib verbosity pkg_descr lbi lib
LHC -> LHC.buildLib verbosity pkg_descr lbi lib
Hugs -> Hugs.buildLib verbosity pkg_descr lbi lib
NHC -> NHC.buildLib verbosity pkg_descr lbi lib
_ -> die "Building is not supported with this compiler."
buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> IO ()
buildExe verbosity pkg_descr lbi exe = case compilerFlavor (compiler lbi) of
GHC -> GHC.buildExe verbosity pkg_descr lbi exe
JHC -> JHC.buildExe verbosity pkg_descr lbi exe
LHC -> LHC.buildExe verbosity pkg_descr lbi exe
Hugs -> Hugs.buildExe verbosity pkg_descr lbi exe
NHC -> NHC.buildExe verbosity pkg_descr lbi exe
_ -> die "Building is not supported with this compiler."
initialBuildSteps :: FilePath -- ^"dist" prefix
-> PackageDescription -- ^mostly information from the .cabal file
......
......@@ -469,8 +469,6 @@ buildLib verbosity pkg_descr lbi lib = do
ifSharedLib = when (withSharedLib lbi)
ifGHCiLib = when (withGHCiLib lbi && withVanillaLib lbi)
info verbosity "Building library..."
libBi <- hackThreadedFlag verbosity
(compiler lbi) (withProfLib lbi) (libBuildInfo lib)
......@@ -630,8 +628,6 @@ buildExe verbosity _pkg_descr lbi exe@Executable { exeName = exeName', modulePat
let pref = buildDir lbi
runGhcProg = rawSystemProgramConf verbosity ghcProgram (withPrograms lbi)
info verbosity $ "Building executable: " ++ exeName' ++ "..."
exeBi <- hackThreadedFlag verbosity
(compiler lbi) (withProfExe lbi) (buildInfo exe)
......
......@@ -73,7 +73,7 @@ import Distribution.Package
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, writeFileAtomic
, installOrdinaryFile, installExecutableFile
, die, info, intercalate )
, die, intercalate )
import System.FilePath ( (</>) )
import Distribution.Verbosity
import Distribution.Text
......@@ -139,7 +139,6 @@ getInstalledPackages verbosity packageDBs conf = do
buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> IO ()
buildLib verbosity pkg_descr lbi lib = do
let Just jhcProg = lookupProgram jhcProgram (withPrograms lbi)
info verbosity "Building library..."
let libBi = libBuildInfo lib
let args = constructJHCCmdLine lbi libBi (buildDir lbi) verbosity
rawSystemProgram verbosity jhcProg $
......@@ -155,7 +154,6 @@ buildLib verbosity pkg_descr lbi lib = do
buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> IO ()
buildExe verbosity _pkg_descr lbi exe = do
let Just jhcProg = lookupProgram jhcProgram (withPrograms lbi)
info verbosity ("Building executable "++exeName exe)
let exeBi = buildInfo exe
let out = buildDir lbi </> exeName exe
let args = constructJHCCmdLine lbi exeBi (buildDir lbi) verbosity
......
......@@ -334,8 +334,6 @@ buildLib verbosity pkg_descr lbi lib = do
ifSharedLib = when (withSharedLib lbi)
ifGHCiLib = when (withGHCiLib lbi && withVanillaLib lbi)
info verbosity "Building library..."
libBi <- hackThreadedFlag verbosity
(compiler lbi) (withProfLib lbi) (libBuildInfo lib)
......@@ -495,8 +493,6 @@ buildExe verbosity _pkg_descr lbi exe@Executable { exeName = exeName', modulePat
let pref = buildDir lbi
runGhcProg = rawSystemProgramConf verbosity lhcProgram (withPrograms lbi)
info verbosity $ "Building executable: " ++ exeName' ++ "..."
exeBi <- hackThreadedFlag verbosity
(compiler lbi) (withProfExe lbi) (buildInfo exe)
......
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