diff --git a/Cabal/src/Distribution/Simple/GHC/Build.hs b/Cabal/src/Distribution/Simple/GHC/Build.hs index 10945011d2d..47c6d4ead97 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build.hs @@ -156,4 +156,3 @@ build numJobs pkg_descr = do buildOpts <- buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir_absolute wantedWays extraSources <- buildAllExtraSources ghcProg buildTargetDir linkOrLoadComponent ghcProg pkg_descr extraSources (buildTargetDir, targetDir_absolute) (wantedWays, buildOpts) - diff --git a/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs b/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs index a128238968a..518a07b3b12 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs @@ -36,8 +36,9 @@ buildAllExtraSources -> BuildM [FilePath] -- ^ Returns the list of extra sources that were built buildAllExtraSources ghcProg buildTargetDir = - concat <$> - traverse (($ buildTargetDir) . ($ ghcProg)) + concat + <$> traverse + (($ buildTargetDir) . ($ ghcProg)) [ buildCSources , buildCxxSources , buildJsSources @@ -223,7 +224,6 @@ buildExtraSources description componentSourceGhcOptions wantDyn viewSources ghcP compileIfNeeded sharedSrcOpts | otherwise -> compileIfNeeded vanillaSrcOpts - in -- build any sources if (null sources || componentIsIndefinite clbi) diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs index aa940baf34b..65ba4ec9aa6 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs @@ -411,9 +411,9 @@ linkExecutable (linkerOpts, rpaths) (wantedWays, buildOpts) targetDir targetName let baseOpts = buildOpts way linkOpts = (baseOpts `mappend` linkerOpts) - -- If there are no input Haskell files we pass -no-hs-main, and - -- assume there is a main function in another non-haskell object - { ghcOptLinkNoHsMain = toFlag (ghcOptInputFiles baseOpts == mempty && ghcOptInputScripts baseOpts == mempty) + { -- If there are no input Haskell files we pass -no-hs-main, and + -- assume there is a main function in another non-haskell object + ghcOptLinkNoHsMain = toFlag (ghcOptInputFiles baseOpts == mempty && ghcOptInputScripts baseOpts == mempty) } & (if withDynExe lbi then \x -> x{ghcOptRPaths = rpaths} else id) comp = compiler lbi diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs b/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs index db3001b368d..4e6f595e823 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs @@ -178,9 +178,10 @@ buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir wantedWays = do { ghcOptHiSuffix = optSuffixFlag (buildWayPrefix way) "hi" , ghcOptObjSuffix = optSuffixFlag (buildWayPrefix way) "o" , ghcOptHPCDir = hpcdir (buildWayHpcWay way) - } where - optSuffixFlag "" _ = NoFlag - optSuffixFlag pre x = toFlag (pre ++ x) + } + where + optSuffixFlag "" _ = NoFlag + optSuffixFlag pre x = toFlag (pre ++ x) vanillaOpts = baseOpts VanillaWay @@ -268,7 +269,7 @@ buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir wantedWays = do sequence_ orderedBuilds return buildOpts -data BuildWay = VanillaWay | StaticWay | DynWay | ProfWay +data BuildWay = VanillaWay | StaticWay | DynWay | ProfWay deriving (Eq, Ord, Show, Enum) -- | Returns the object/interface extension prefix for the given build way (e.g. "dyn_" for 'DynWay') diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Utils.hs b/Cabal/src/Distribution/Simple/GHC/Build/Utils.hs index 1f437b80208..fa8b907f5d3 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Utils.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Utils.hs @@ -3,37 +3,41 @@ module Distribution.Simple.GHC.Build.Utils where import Distribution.Compat.Prelude import Prelude () -import Distribution.Simple.BuildPaths -import Distribution.Types.LocalBuildInfo import Control.Monad (msum) import Data.Char (isLower) import Distribution.ModuleName (ModuleName) import qualified Distribution.ModuleName as ModuleName -import Distribution.System import Distribution.PackageDescription as PD import Distribution.PackageDescription.Utils (cabalBug) +import Distribution.Simple.BuildPaths import Distribution.Simple.Compiler import qualified Distribution.Simple.GHC.Internal as Internal import Distribution.Simple.Program.GHC import Distribution.Simple.Setup.Common import Distribution.Simple.Utils +import Distribution.System +import Distribution.Types.LocalBuildInfo +import Distribution.Utils.Path (getSymbolicPath) import Distribution.Verbosity import System.FilePath ( replaceExtension , takeExtension - , () , (<.>) + , () ) -import Distribution.Utils.Path (getSymbolicPath) -- | Find the path to the entry point of an executable (typically specified in -- @main-is@, and found in @hs-source-dirs@). -findExecutableMain :: Verbosity - -> FilePath -- ^ Build directory - -> (BuildInfo, FilePath) -- ^ The build info and module path of an executable-like component (Exe, Test, Bench) - -> IO FilePath -- ^ The path to the main source file. -findExecutableMain verbosity bdir (bnfo, modPath) - = findFileEx verbosity (bdir : map getSymbolicPath (hsSourceDirs bnfo)) modPath +findExecutableMain + :: Verbosity + -> FilePath + -- ^ Build directory + -> (BuildInfo, FilePath) + -- ^ The build info and module path of an executable-like component (Exe, Test, Bench) + -> IO FilePath + -- ^ The path to the main source file. +findExecutableMain verbosity bdir (bnfo, modPath) = + findFileEx verbosity (bdir : map getSymbolicPath (hsSourceDirs bnfo)) modPath -- | Does this compiler support the @-dynamic-too@ option supportsDynamicToo :: Compiler -> Bool @@ -165,9 +169,10 @@ exeTargetName platform name = unUnqualComponentName name `withExt` exeExtension -- or 'Nothing' if no @-main-is@ flag could be found. -- -- In case of 'Nothing', 'Distribution.ModuleName.main' can be assumed. -exeMainModuleName :: BuildInfo - -- ^ The build info of the executable-like component (Exe, Test, Bench) - -> ModuleName +exeMainModuleName + :: BuildInfo + -- ^ The build info of the executable-like component (Exe, Test, Bench) + -> ModuleName exeMainModuleName bnfo = -- GHC honors the last occurrence of a module name updated via -main-is --