1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
{-# LANGUAGE RecordWildCards #-}
-- | This module manages storing the various GHC option flags in a modules
-- interface file as part of the recompilation checking infrastructure.
module FlagChecker (
fingerprintDynFlags
) where
import Binary
import BinIface ()
import DynFlags
import HscTypes
import Name
import Fingerprint
-- import Outputable
import Data.List (sort)
import System.FilePath (normalise)
-- | Produce a fingerprint of a @DynFlags@ value. We only base
-- the finger print on important fields in @DynFlags@ so that
-- the recompilation checker can use this fingerprint.
fingerprintDynFlags :: DynFlags -> (BinHandle -> Name -> IO ())
-> IO Fingerprint
fingerprintDynFlags DynFlags{..} nameio =
let mainis = (mainModIs, mainFunIs)
-- pkgopts = (thisPackage dflags, sort $ packageFlags dflags)
safeHs = setSafeMode safeHaskell
-- oflags = sort $ filter filterOFlags $ flags dflags
-- *all* the extension flags and the language
lang = (fmap fromEnum language,
sort $ map fromEnum $ extensionFlags)
-- -I, -D and -U flags affect CPP
cpp = (map normalise includePaths, sOpt_P settings)
-- normalise: eliminate spurious differences due to "./foo" vs "foo"
-- -i, -osuf, -hcsuf, -hisuf, -odir, -hidir, -stubdir, -o, -ohi
paths = (map normalise importPaths,
[ objectSuf, hcSuf, hiSuf ],
[ objectDir, hiDir, stubDir, outputFile, outputHi ])
in -- pprTrace "flags" (ppr (mainis, safeHs, lang, cpp, paths)) $
computeFingerprint nameio (mainis, safeHs, lang, cpp, paths)
|