Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
alt-romes committed Jan 15, 2024
1 parent 3ec54bb commit 9437ee2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
1 change: 0 additions & 1 deletion Cabal/src/Distribution/Simple/GHC/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

6 changes: 3 additions & 3 deletions Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -223,7 +224,6 @@ buildExtraSources description componentSourceGhcOptions wantDyn viewSources ghcP
compileIfNeeded sharedSrcOpts
| otherwise ->
compileIfNeeded vanillaSrcOpts

in
-- build any sources
if (null sources || componentIsIndefinite clbi)
Expand Down
6 changes: 3 additions & 3 deletions Cabal/src/Distribution/Simple/GHC/Build/Link.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions Cabal/src/Distribution/Simple/GHC/Build/Modules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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')
Expand Down
33 changes: 19 additions & 14 deletions Cabal/src/Distribution/Simple/GHC/Build/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
--
Expand Down

0 comments on commit 9437ee2

Please sign in to comment.