Skip to content

Commit 8c136c5

Browse files
committed
Formatting
1 parent c822cbc commit 8c136c5

3 files changed

Lines changed: 91 additions & 83 deletions

File tree

Cabal/src/Distribution/Simple/HashValue.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ module Distribution.Simple.HashValue
1313
import Distribution.Compat.Prelude
1414

1515
import Control.Monad ((<=<))
16-
import qualified Data.Binary as Binary
1716
import qualified Crypto.Hash.SHA256 as SHA256
17+
import qualified Data.Binary as Binary
1818
import qualified Data.ByteString.Base16 as Base16
1919
import qualified Data.ByteString.Char8 as BS
2020
import qualified Data.ByteString.Lazy.Char8 as LBS

Cabal/src/Distribution/Simple/PreProcess.hs

Lines changed: 85 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ import Distribution.Simple.CCompiler
5555
import Distribution.Simple.Compiler
5656
import Distribution.Simple.Errors
5757
import Distribution.Simple.LocalBuildInfo
58-
import Distribution.Simple.RebuildMonad
5958
import qualified Distribution.Simple.PackageIndex as PackageIndex
6059
import Distribution.Simple.PreProcess.Types
6160
import Distribution.Simple.PreProcess.Unlit
6261
import Distribution.Simple.Program
6362
import Distribution.Simple.Program.ResponseFile
63+
import Distribution.Simple.RebuildMonad
6464
import Distribution.Simple.Test.LibV09
6565
import Distribution.Simple.Utils
6666
import Distribution.System
@@ -69,8 +69,8 @@ import Distribution.Utils.Path
6969
import Distribution.Verbosity
7070
import Distribution.Version
7171

72-
import Control.Monad.Writer
7372
import Control.Monad (sequence)
73+
import Control.Monad.Writer
7474
import System.Directory (doesDirectoryExist, doesFileExist)
7575
import System.FilePath
7676
( normalise
@@ -206,11 +206,12 @@ preprocessComponent pd comp lbi clbi isSrcDist verbosity handlers =
206206
BenchmarkUnsupported tt ->
207207
dieWithException verbosity $ NoSupportForPreProcessingBenchmark tt
208208
where
209-
orderingFromHandlers :: Verbosity
210-
-> [SymbolicPath Pkg (Dir Source)]
211-
-> [(Suffix, PreProcessor)]
212-
-> [ModuleName]
213-
-> IO [ModuleName]
209+
orderingFromHandlers
210+
:: Verbosity
211+
-> [SymbolicPath Pkg (Dir Source)]
212+
-> [(Suffix, PreProcessor)]
213+
-> [ModuleName]
214+
-> IO [ModuleName]
214215
orderingFromHandlers v d hndlrs mods =
215216
foldM (\acc (_, pp) -> ppOrdering pp v d acc) mods hndlrs
216217
builtinCSuffixes = map Suffix cSourceExtensions
@@ -341,7 +342,6 @@ preprocessFile mbWorkDir searchLoc buildLoc forSDist baseFile verbosity builtinS
341342
-- look for existing pre-processed source file in the dest dir to
342343
-- see if we really have to re-run the preprocessor.
343344

344-
-- ppsrcFileMay <- findFileCwdWithExtension mbWorkDir builtinSuffixes [buildAsSrcLoc] baseFile
345345
(runPreProcessor, key) <- configurePreProcessor pp verbosity
346346
let recompile = liftIO $ do
347347
let destDir = i buildLoc </> takeDirectory srcStem
@@ -350,11 +350,17 @@ preprocessFile mbWorkDir searchLoc buildLoc forSDist baseFile verbosity builtinS
350350
runPreProcessor
351351
(psrcLoc, getSymbolicPath psrcRelFile)
352352
(buildLoc, srcStem <.> "hs")
353-
void . execWriterT $ rerunIfChanged'
354-
verbosity
355-
(interpretSymbolicPath mbWorkDir (makeSymbolicPath ""))
356-
sequence
357-
[(newFileMonitor (interpretSymbolicPath mbWorkDir psrcFile), key, recompile)]
353+
void . execWriterT $
354+
rerunIfChanged'
355+
verbosity
356+
(interpretSymbolicPath mbWorkDir (makeSymbolicPath ""))
357+
sequence
358+
[
359+
( newFileMonitor (interpretSymbolicPath mbWorkDir psrcFile)
360+
, key
361+
, recompile
362+
)
363+
]
358364
where
359365
i = interpretSymbolicPath mbWorkDir -- See Note [Symbolic paths] in Distribution.Utils.Path
360366
buildAsSrcLoc :: SymbolicPath Pkg (Dir Source)
@@ -462,14 +468,16 @@ ppGhcCpp program xHs extraArgs _bi lbi clbi =
462468
++ ["-o", outFile, inFile]
463469
++ extraArgs
464470

465-
getProgVersion :: Verbosity
466-
-> IO (ConfiguredProgram, Version)
471+
getProgVersion
472+
:: Verbosity
473+
-> IO (ConfiguredProgram, Version)
467474
getProgVersion verbosity = do
468-
(prog, version, _) <- requireProgramVersion
469-
verbosity
470-
program
471-
anyVersion
472-
(withPrograms lbi)
475+
(prog, version, _) <-
476+
requireProgramVersion
477+
verbosity
478+
program
479+
anyVersion
480+
(withPrograms lbi)
473481
return (prog, version)
474482

475483
ppCpphs :: [String] -> BuildInfo -> LocalBuildInfo -> ComponentLocalBuildInfo -> PreProcessor
@@ -497,8 +505,9 @@ ppCpphs extraArgs _bi lbi clbi =
497505
: ["--include=" ++ u (autogenComponentModulesDir lbi clbi </> makeRelativePathEx cppHeaderName) | cpphsVersion >= mkVersion [1, 6]]
498506
++ extraArgs
499507

500-
getProgVersion :: Verbosity
501-
-> IO (ConfiguredProgram, Version)
508+
getProgVersion
509+
:: Verbosity
510+
-> IO (ConfiguredProgram, Version)
502511
getProgVersion verbosity = do
503512
(prog, version, _) <-
504513
requireProgramVersion
@@ -546,17 +555,18 @@ ppHsc2hs bi lbi clbi =
546555
)
547556
else runHsc2hs (prependCrossFlags pureArgs)
548557

549-
getProgVersion :: Verbosity
550-
-> IO (ConfiguredProgram, ConfiguredProgram, Version)
558+
getProgVersion
559+
:: Verbosity
560+
-> IO (ConfiguredProgram, ConfiguredProgram, Version)
551561
getProgVersion verbosity = do
552-
(gccProg, _) <- requireProgram verbosity gccProgram (withPrograms lbi)
553-
(hsc2hsProg, hsc2hsVersion, _) <-
554-
requireProgramVersion
555-
verbosity
556-
hsc2hsProgram
557-
anyVersion
558-
(withPrograms lbi)
559-
pure (gccProg, hsc2hsProg, hsc2hsVersion)
562+
(gccProg, _) <- requireProgram verbosity gccProgram (withPrograms lbi)
563+
(hsc2hsProg, hsc2hsVersion, _) <-
564+
requireProgramVersion
565+
verbosity
566+
hsc2hsProgram
567+
anyVersion
568+
(withPrograms lbi)
569+
pure (gccProg, hsc2hsProg, hsc2hsVersion)
560570

561571
-- Returns a list of command line arguments that can either be passed
562572
-- directly, or via a response file.
@@ -725,42 +735,42 @@ ppC2hs bi lbi clbi =
725735
u = interpretSymbolicPathCWD
726736

727737
runPreProcessor
728-
(gccProg, c2hsProg, _)
729-
(inBaseDir, inRelativeFile)
730-
(outBaseDir, outRelativeFile)
731-
verbosity = do
732-
runProgramCwd verbosity mbWorkDir c2hsProg $
733-
-- Options from the current package:
734-
["--cpp=" ++ programPath gccProg, "--cppopts=-E"]
735-
++ ["--cppopts=" ++ opt | opt <- getCppOptions bi lbi]
736-
++ ["--cppopts=-include" ++ u (autogenComponentModulesDir lbi clbi </> makeRelativePathEx cppHeaderName)]
737-
++ ["--include=" ++ outBaseDir]
738-
-- Options from dependent packages
739-
++ [ "--cppopts=" ++ opt
740-
| pkg <- pkgs
741-
, opt <-
742-
["-I" ++ opt | opt <- Installed.includeDirs pkg]
743-
++ [ opt | opt@('-' : c : _) <- Installed.ccOptions pkg,
744-
-- c2hs uses the C ABI
745-
-- We assume that there are only C sources
746-
-- and C++ functions are exported via a C
747-
-- interface and wrapped in a C source file.
748-
-- Therefore we do not supply C++ flags
749-
-- because there will not be C++ sources.
750-
--
751-
--
752-
-- DO NOT add Installed.cxxOptions unless this changes!
753-
c `elem` "DIU"
754-
]
755-
]
756-
-- TODO: install .chi files for packages, so we can --include
757-
-- those dirs here, for the dependencies
758-
759-
-- input and output files
760-
++ [ "--output-dir=" ++ outBaseDir
761-
, "--output=" ++ outRelativeFile
762-
, inBaseDir </> inRelativeFile
763-
]
738+
(gccProg, c2hsProg, _)
739+
(inBaseDir, inRelativeFile)
740+
(outBaseDir, outRelativeFile)
741+
verbosity = do
742+
runProgramCwd verbosity mbWorkDir c2hsProg $
743+
-- Options from the current package:
744+
["--cpp=" ++ programPath gccProg, "--cppopts=-E"]
745+
++ ["--cppopts=" ++ opt | opt <- getCppOptions bi lbi]
746+
++ ["--cppopts=-include" ++ u (autogenComponentModulesDir lbi clbi </> makeRelativePathEx cppHeaderName)]
747+
++ ["--include=" ++ outBaseDir]
748+
-- Options from dependent packages
749+
++ [ "--cppopts=" ++ opt
750+
| pkg <- pkgs
751+
, opt <-
752+
["-I" ++ opt | opt <- Installed.includeDirs pkg]
753+
++ [ opt | opt@('-' : c : _) <- Installed.ccOptions pkg,
754+
-- c2hs uses the C ABI
755+
-- We assume that there are only C sources
756+
-- and C++ functions are exported via a C
757+
-- interface and wrapped in a C source file.
758+
-- Therefore we do not supply C++ flags
759+
-- because there will not be C++ sources.
760+
--
761+
--
762+
-- DO NOT add Installed.cxxOptions unless this changes!
763+
c `elem` "DIU"
764+
]
765+
]
766+
-- TODO: install .chi files for packages, so we can --include
767+
-- those dirs here, for the dependencies
768+
769+
-- input and output files
770+
++ [ "--output-dir=" ++ outBaseDir
771+
, "--output=" ++ outRelativeFile
772+
, inBaseDir </> inRelativeFile
773+
]
764774

765775
getProgVersion verbosity = do
766776
(c2hsProg, c2hsVersion, _) <-
@@ -925,13 +935,13 @@ ppSuffixes = map fst
925935
-- | Standard preprocessors: c2hs, hsc2hs, happy, alex and cpphs.
926936
knownSuffixHandlers :: [PPSuffixHandler]
927937
knownSuffixHandlers =
928-
[ (Suffix "chs", ppC2hs)
929-
, (Suffix "hsc", ppHsc2hs)
930-
, (Suffix "x", ppAlex)
931-
, (Suffix "y", ppHappy)
932-
, (Suffix "ly", ppHappy)
933-
, (Suffix "cpphs", ppCpp)
934-
]
938+
[ (Suffix "chs", ppC2hs)
939+
, (Suffix "hsc", ppHsc2hs)
940+
, (Suffix "x", ppAlex)
941+
, (Suffix "y", ppHappy)
942+
, (Suffix "ly", ppHappy)
943+
, (Suffix "cpphs", ppCpp)
944+
]
935945

936946
-- | Standard preprocessors with possible extra C sources: c2hs, hsc2hs.
937947
knownExtrasHandlers :: [PreProcessorExtras]

Cabal/src/Distribution/Simple/PreProcess/Types.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ where
2323
import Distribution.Compat.Prelude
2424
import Prelude ()
2525

26-
import Distribution.Simple.Program.Types (ConfiguredProgram)
2726
import Distribution.ModuleName (ModuleName)
2827
import Distribution.Pretty
28+
import Distribution.Simple.Program.Types (ConfiguredProgram)
2929
import Distribution.Utils.Path
3030
import Distribution.Verbosity
3131
import qualified Text.PrettyPrint as Disp
@@ -90,24 +90,22 @@ data PreProcessor = PreProcessor
9090
-- well-behaved and not reorder modules it doesn't have dominion over!
9191
--
9292
-- @since 3.8.1.0
93-
9493
, configurePreProcessor
9594
:: Verbosity
9695
-> IO (PreProcessCommand, PreProcessorKey)
97-
9896
}
9997

10098
-- | Uniquely identifies a specific preprocessor (version) for change
10199
-- monitoring purposes.
102100
-- This value should change iff the preprocessor itself changes in a way that
103101
-- requires re-running it for a given input file.
104102
data PreProcessorKey
105-
= PreProcessorBuiltin
106-
-- ^ A built-in preprocessor; these only change when Cabal itself does, so
103+
= -- | A built-in preprocessor; these only change when Cabal itself does, so
107104
-- there is no need to track changes for these.
108-
| PreProcessorPrograms [ConfiguredProgram]
109-
-- ^ A preprocessor that runs some program, identified uniquely by the
105+
PreProcessorBuiltin
106+
| -- | A preprocessor that runs some program, identified uniquely by the
110107
-- configured program.
108+
PreProcessorPrograms [ConfiguredProgram]
111109
deriving (Generic, Eq)
112110

113111
instance Binary PreProcessorKey

0 commit comments

Comments
 (0)