Hannes Siebenhandl pushed to branch wip/fendor/dep-stdout at Glasgow Haskell Compiler / GHC

Commits:

15 changed files:

Changes:

  • changelog.d/make-depends-streaming-output
    1
    +section: compiler
    
    2
    +synopsis: Allow streaming `ghc -M` output to stdout
    
    3
    +issues: #27937
    
    4
    +mrs: !16830
    
    5
    +description: {
    
    6
    +    Add options `-dep-makefile-stdout` and `-dep-json-stdout` which stream the dependency generation
    
    7
    +    output to stdout.
    
    8
    +
    
    9
    +    The Makefile and json dependency generation can stream to separate targets, e.g. `-dep-makefile target.Makefile -dep-json-stdout`
    
    10
    +    streams the JSON Lines output to stdout and the Makefile to `target.Makefile`.
    
    11
    +
    
    12
    +    If `-dep-makefile-stdout`, `-dep-json` or `-dep-json-stdout` is given, we no longer generate a Makefile by default, but only
    
    13
    +    if the user explicitly requests the Makefile dependency generation.
    
    14
    +
    
    15
    +    The output from a particular backend can be disabled via `-no-dep-json` and `-no-dep-makefile` respectively.
    
    16
    +}

  • compiler/GHC/Driver/DynFlags.hs
    ... ... @@ -73,6 +73,9 @@ module GHC.Driver.DynFlags (
    73 73
             IncludeSpecs(..), addGlobalInclude, addQuoteInclude, flattenIncludes,
    
    74 74
             addImplicitQuoteInclude,
    
    75 75
     
    
    76
    +        -- * `ghc -M` specification
    
    77
    +        MkDependOutput(..),
    
    78
    +
    
    76 79
             -- * SDoc
    
    77 80
             initSDocContext, initDefaultSDocContext,
    
    78 81
             initPromotionTickContext,
    
    ... ... @@ -350,8 +353,8 @@ data DynFlags = DynFlags {
    350 353
         -- ^ External plugins loaded from shared libraries
    
    351 354
     
    
    352 355
       --  For ghc -M
    
    353
    -  depMakefile           :: Maybe FilePath,
    
    354
    -  depJson               :: Maybe FilePath,
    
    356
    +  depMakefile           :: MkDependOutput,
    
    357
    +  depJson               :: MkDependOutput,
    
    355 358
       depIncludePkgDeps     :: Bool,
    
    356 359
       depIncludeCppDeps     :: Bool,
    
    357 360
       depExcludeMods        :: [ModuleName],
    
    ... ... @@ -694,8 +697,8 @@ defaultDynFlags mySettings =
    694 697
             llvmOptLevel            = 0,
    
    695 698
     
    
    696 699
             -- ghc -M values
    
    697
    -        depMakefile       = Just "Makefile",
    
    698
    -        depJson           = Nothing,
    
    700
    +        depMakefile       = MkDepend_Default "Makefile",
    
    701
    +        depJson           = MkDepend_None,
    
    699 702
             depIncludePkgDeps = False,
    
    700 703
             depIncludeCppDeps = False,
    
    701 704
             depExcludeMods    = [],
    
    ... ... @@ -801,6 +804,15 @@ flattenExtensionFlags ml = foldr g defaultExtensionFlags
    801 804
               g (Off f) flags = EnumSet.delete f flags
    
    802 805
               defaultExtensionFlags = EnumSet.fromList (languageExtensions ml)
    
    803 806
     
    
    807
    +-- -----------------------------------------------------------------------------
    
    808
    +-- -M -dep-*
    
    809
    +
    
    810
    +data MkDependOutput
    
    811
    +  = MkDepend_None
    
    812
    +  | MkDepend_Default !FilePath
    
    813
    +  | MkDepend_Explicit !FilePath
    
    814
    +  | MkDepend_StdOut
    
    815
    +
    
    804 816
     -- -----------------------------------------------------------------------------
    
    805 817
     -- -jN
    
    806 818
     
    

  • compiler/GHC/Driver/MakeFile.hs
    ... ... @@ -132,7 +132,7 @@ doMkDepend = do
    132 132
         module_graph <- GHC.depanal excl_mods True {- Allow dup roots -}
    
    133 133
         doMkDependModuleGraph dflags module_graph
    
    134 134
     
    
    135
    -doMkDependModuleGraph :: GhcMonad m =>  DynFlags -> ModuleGraph -> m ()
    
    135
    +doMkDependModuleGraph :: GhcMonad m => DynFlags -> ModuleGraph -> m ()
    
    136 136
     doMkDependModuleGraph dflags module_graph = do
    
    137 137
         hsc_env <- getSession
    
    138 138
         logger <- getLogger
    
    ... ... @@ -143,12 +143,14 @@ doMkDependModuleGraph dflags module_graph = do
    143 143
         root <- liftIO Directory.getCurrentDirectory
    
    144 144
     
    
    145 145
         let
    
    146
    +      suffixes = fmap unsafeEncodeUtf (depSuffixes dflags)
    
    147
    +      tmpdir = tmpDir dflags
    
    146 148
           backends = concat
    
    147
    -        [ [ initFileDepWriter logger root tmpfs dflags makefile_output
    
    148
    -          | Just makefile_output <- [depMakefile dflags]
    
    149
    +        [ [ initFileDepWriter logger root tmpfs tmpdir suffixes makefile_output
    
    150
    +          | Just makefile_output <- [initDepOutput (depMakefile dflags)]
    
    149 151
               ]
    
    150
    -        , [ initJsonDepWriter logger tmpfs dflags json_output
    
    151
    -          | Just json_output <- [depJson dflags]
    
    152
    +        , [ initJsonDepWriter logger tmpfs tmpdir json_output
    
    153
    +          | Just json_output <- [initDepOutput (depJson dflags)]
    
    152 154
               ]
    
    153 155
             ]
    
    154 156
     
    
    ... ... @@ -158,24 +160,14 @@ doMkDependModuleGraph dflags module_graph = do
    158 160
         liftIO $ debugTraceMsg logger 2 (text "Module dependencies" $$ ppr sorted)
    
    159 161
     
    
    160 162
         liftIO $ do
    
    161
    -
    
    162
    -      -- Setup the writers
    
    163
    -      writers <- sequenceA backends
    
    164
    -      sinks <- traverse dw_beginWriter writers
    
    165
    -
    
    166
    -      -- Do the actual work
    
    167
    -      do
    
    163
    +      withWriters backends $ \ depSink -> do
    
    164
    +        -- Do the actual work
    
    168 165
             -- Process them one by one, dumping results and complaining about cycles
    
    169
    -        mapM_ (processDeps hsc_env (UniqSet.mkUniqSet excl_mods) sinks) sorted
    
    166
    +        mapM_ (processDeps hsc_env (UniqSet.mkUniqSet excl_mods) depSink) sorted
    
    170 167
     
    
    171 168
             -- If -ddump-mod-cycles, show cycles in the module graph
    
    172 169
             liftIO $ dumpModCycles logger module_graph
    
    173 170
     
    
    174
    -      -- Tidy up
    
    175
    -      do
    
    176
    -        traverse_ dw_endWriter writers
    
    177
    -
    
    178
    -
    
    179 171
         -- Unconditional exiting is a bad idea.  If an error occurs we'll get an
    
    180 172
         --exception; if that is not caught it's fine, but at least we have a
    
    181 173
         --chance to find out exactly what went wrong.  Uncomment the following
    
    ... ... @@ -216,15 +208,119 @@ data Dep
    216 208
         { dep_path :: OsPath
    
    217 209
         }
    
    218 210
     
    
    211
    +-- | Consumer of the dependency information generated from the 'ModuleGraph'.
    
    212
    +--
    
    213
    +-- Use with 'withWriter'/'withWriters' to initialise the consumers of the dependency information
    
    214
    +-- generation.
    
    219 215
     data DependencyWriter = DependencyWriter
    
    220
    -  { dw_beginWriter :: IO DepSink
    
    216
    +  { dw_sink :: DepSink
    
    217
    +  -- ^ Sink for dependency information
    
    221 218
       , dw_endWriter :: IO ()
    
    219
    +  -- ^ We finished consuming the dependency information, perform final
    
    220
    +  -- tidy up operations. This may be a no-op, but could also
    
    221
    +  -- copy temporary files, close open handlers, etc...
    
    222
    +  --
    
    223
    +  -- If 'dw_endWriter' was called, calling 'dw_onError' is unnecessary,
    
    224
    +  -- but it must be safe to call 'dw_onError' any way.
    
    225
    +  , dw_onError :: IO ()
    
    226
    +  -- ^ Something crashed! Clean up any resources opened by this 'DependencyWriter'.
    
    222 227
       }
    
    223 228
     
    
    224
    -data DepSink = DepSink
    
    229
    +-- | Initialise multiple backends and combine them into one output function.
    
    230
    +--
    
    231
    +-- Combines the 'DepSink' of each 'DependencyWriter' into one single consumer.
    
    232
    +withWriters :: [IO DependencyWriter] -> (DepSink -> IO a) -> IO a
    
    233
    +withWriters [] k = k noopSink
    
    234
    +withWriters (dw : dws) k =
    
    235
    +  withWriter
    
    236
    +    dw
    
    237
    +    $ \s -> withWriters dws (\s' -> k (s `mappendSink` s'))
    
    238
    +
    
    239
    +-- | Initialise a single 'DependencyWriter', making sure any allocated resource
    
    240
    +-- get's tidied up again.
    
    241
    +--
    
    242
    +-- Accepts 'IO' 'DependencyWriter' since the initialisation may perform setup operations,
    
    243
    +-- such as opening file handles, or intermediate data types.
    
    244
    +withWriter :: IO DependencyWriter -> (DepSink -> IO r) -> IO r
    
    245
    +withWriter dwIO k =
    
    246
    +  bracketOnError dwIO dw_onError $ \ dw -> do
    
    247
    +    r <- k (dw_sink dw)
    
    248
    +    -- Clean up open resources
    
    249
    +    dw_endWriter dw
    
    250
    +    pure r
    
    251
    +
    
    252
    +-- | Process the dependency information for one node in the 'ModuleGraph'.
    
    253
    +newtype DepSink = DepSink
    
    225 254
       { ds_writeDependency :: DepNode -> [Dep] -> IO ()
    
    226 255
       }
    
    227 256
     
    
    257
    +noopSink :: DepSink
    
    258
    +noopSink = DepSink $ \ _ _ -> pure ()
    
    259
    +
    
    260
    +mappendSink :: DepSink -> DepSink -> DepSink
    
    261
    +mappendSink (DepSink s1) (DepSink s2) = DepSink (\ node deps -> s1 node deps >> s2 node deps)
    
    262
    +
    
    263
    +-- | Where should the dependency output end up?
    
    264
    +data DepOutput
    
    265
    +  = DepStreamHandle Handle
    
    266
    +  -- ^ The dependency information should be written to this 'Handle'.
    
    267
    +  | DepFileOutput FilePath
    
    268
    +  -- ^ The dependency information should be written to this 'FilePath'.
    
    269
    +
    
    270
    +-- | A 'DepStream' is an abstraction over how to output single elements
    
    271
    +-- of the dependency generation, e.g., a json object or one makefile rule.
    
    272
    +data DepStream = DepStream
    
    273
    +  { depStream_write :: String -> IO ()
    
    274
    +  , depStream_close :: IO ()
    
    275
    +  , depStream_onError :: IO ()
    
    276
    +  }
    
    277
    +
    
    278
    +initDepOutput :: MkDependOutput -> Maybe DepOutput
    
    279
    +initDepOutput = \ case
    
    280
    +  MkDepend_None -> Nothing
    
    281
    +  MkDepend_Default fp -> Just $ DepFileOutput fp
    
    282
    +  MkDepend_Explicit fp -> Just $ DepFileOutput fp
    
    283
    +  MkDepend_StdOut -> Just $ DepStreamHandle stdout
    
    284
    +
    
    285
    +initMakefileDepStream :: Logger -> TmpFs -> TempDir -> DepOutput -> IO DepStream
    
    286
    +initMakefileDepStream _ _ _ (DepStreamHandle h) =
    
    287
    +  pure $ depStreamHandle h
    
    288
    +initMakefileDepStream logger tmpfs tmpdir (DepFileOutput fp) = do
    
    289
    +  files <- beginMkDependHS logger tmpfs tmpdir fp
    
    290
    +  pure $
    
    291
    +    DepStream
    
    292
    +      { depStream_write = hPutStrLn (mkd_tmp_hdl files)
    
    293
    +      , depStream_onError = do
    
    294
    +          hClose $ mkd_tmp_hdl files
    
    295
    +          case mkd_make_hdl files of
    
    296
    +            Nothing -> return ()
    
    297
    +            Just hdl -> hClose hdl
    
    298
    +      , depStream_close = endMkDependHS logger files
    
    299
    +      }
    
    300
    +
    
    301
    +initJsonDepStream :: Logger -> TmpFs -> TempDir -> DepOutput -> IO DepStream
    
    302
    +initJsonDepStream _ _ _ (DepStreamHandle h) =
    
    303
    +  pure $ depStreamHandle h
    
    304
    +initJsonDepStream logger tmpfs tmpdir (DepFileOutput fp) = do
    
    305
    +  files <- initJsonDepFiles logger tmpfs tmpdir fp
    
    306
    +  pure $
    
    307
    +    DepStream
    
    308
    +      { depStream_write = hPutStrLn (json_tmp_hdl files)
    
    309
    +      , depStream_onError = hClose (json_tmp_hdl files)
    
    310
    +      , depStream_close = endJsonDepFiles logger files
    
    311
    +      }
    
    312
    +
    
    313
    +depStreamHandle :: Handle -> DepStream
    
    314
    +depStreamHandle h =
    
    315
    +    DepStream
    
    316
    +      { depStream_write =
    
    317
    +          \output -> do
    
    318
    +            hPutStrLn h output
    
    319
    +            hFlush h -- We flush to ensure the output is streamed per line.
    
    320
    +      , depStream_close = pure ()
    
    321
    +      , depStream_onError = pure ()
    
    322
    +      }
    
    323
    +
    
    228 324
     -----------------------------------------------------------------
    
    229 325
     --
    
    230 326
     --              processDeps
    
    ... ... @@ -233,7 +329,7 @@ data DepSink = DepSink
    233 329
     
    
    234 330
     processDeps :: HscEnv
    
    235 331
                 -> UniqSet ModuleName -- ^ Excludes
    
    236
    -            -> [DepSink]
    
    332
    +            -> DepSink
    
    237 333
                 -> SCC ModuleGraphNode
    
    238 334
                 -> IO ()
    
    239 335
     -- Write suitable dependencies to handle
    
    ... ... @@ -267,7 +363,7 @@ processDeps _ _ _ (AcyclicSCC (ModuleNode _ (ModuleNodeFixed {})))
    267 363
       -- No dependencies needed for fixed modules (already compiled)
    
    268 364
       = return ()
    
    269 365
     
    
    270
    -processDeps hsc_env0 excl_mods sinks (AcyclicSCC (ModuleNode _ (ModuleNodeCompile node))) = do
    
    366
    +processDeps hsc_env0 excl_mods sink (AcyclicSCC (ModuleNode _ (ModuleNodeCompile node))) = do
    
    271 367
       pp <- preprocessor
    
    272 368
       let
    
    273 369
         dep_node = mkDepNode pp
    
    ... ... @@ -279,7 +375,7 @@ processDeps hsc_env0 excl_mods sinks (AcyclicSCC (ModuleNode _ (ModuleNodeCompil
    279 375
     
    
    280 376
       if null missing_dep_errs
    
    281 377
         then do
    
    282
    -      traverse_ (\ sink -> ds_writeDependency sink dep_node deps) sinks
    
    378
    +      ds_writeDependency sink dep_node deps
    
    283 379
         else do
    
    284 380
           let sec = initSourceErrorContext (hsc_dflags local_hsc_env)
    
    285 381
           throwErrors sec (mkMessages (listToBag missing_dep_errs))
    
    ... ... @@ -380,17 +476,16 @@ find_preprocessor d = do
    380 476
     --
    
    381 477
     -----------------------------------------------------------------
    
    382 478
     
    
    383
    -initFileDepWriter :: Logger -> OsPath -> TmpFs -> DynFlags -> FilePath -> IO DependencyWriter
    
    384
    -initFileDepWriter logger root tmpfs dflags makefile = do
    
    385
    -  files <- beginMkDependHS logger tmpfs dflags makefile
    
    479
    +initFileDepWriter :: Logger -> OsPath -> TmpFs -> TempDir -> [OsPath] -> DepOutput -> IO DependencyWriter
    
    480
    +initFileDepWriter logger root tmpfs tmpdir suffixes output = do
    
    481
    +  stream <- initMakefileDepStream logger tmpfs tmpdir output
    
    386 482
       pure DependencyWriter
    
    387
    -    { dw_beginWriter = do
    
    388
    -        pure $ DepSink $ \ node deps -> do
    
    389
    -          writeDependencies root (mkd_tmp_hdl files) suffixes node deps
    
    390
    -    , dw_endWriter = endMkDependHS logger files
    
    483
    +    { dw_sink =
    
    484
    +        DepSink $ \ node deps -> do
    
    485
    +          traverse_ (depStream_write stream) (dependencyRules root suffixes node deps)
    
    486
    +    , dw_endWriter = depStream_close stream
    
    487
    +    , dw_onError = depStream_onError stream
    
    391 488
         }
    
    392
    -  where
    
    393
    -    suffixes = map unsafeEncodeUtf (depSuffixes dflags)
    
    394 489
     
    
    395 490
     data MkDepFiles
    
    396 491
       = MkDep { mkd_make_file :: FilePath,          -- Name of the makefile
    
    ... ... @@ -398,11 +493,11 @@ data MkDepFiles
    398 493
                 mkd_tmp_file  :: FilePath,          -- Name of the temporary file
    
    399 494
                 mkd_tmp_hdl   :: Handle }           -- Handle of the open temporary file
    
    400 495
     
    
    401
    -beginMkDependHS :: Logger -> TmpFs -> DynFlags -> FilePath -> IO MkDepFiles
    
    402
    -beginMkDependHS logger tmpfs dflags makefile = do
    
    496
    +beginMkDependHS :: Logger -> TmpFs -> TempDir -> FilePath -> IO MkDepFiles
    
    497
    +beginMkDependHS logger tmpfs tmpdir makefile = do
    
    403 498
             -- open a new temp file in which to stuff the dependency info
    
    404 499
             -- as we go along.
    
    405
    -  tmp_file <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "dep"
    
    500
    +  tmp_file <- newTempName logger tmpfs tmpdir TFL_CurrentModule "dep"
    
    406 501
       tmp_hdl <- openFile tmp_file WriteMode
    
    407 502
     
    
    408 503
             -- open the makefile
    
    ... ... @@ -443,16 +538,15 @@ beginMkDependHS logger tmpfs dflags makefile = do
    443 538
       return (MkDep { mkd_make_file = makefile, mkd_make_hdl = mb_make_hdl,
    
    444 539
                       mkd_tmp_file  = tmp_file, mkd_tmp_hdl  = tmp_hdl})
    
    445 540
     
    
    446
    -writeDependencies ::
    
    541
    +dependencyRules ::
    
    447 542
       OsPath ->
    
    448
    -  Handle ->
    
    449 543
       [OsString] ->
    
    450 544
       -- ^ Suffixes
    
    451 545
       DepNode ->
    
    452 546
       [Dep] ->
    
    453
    -  IO ()
    
    454
    -writeDependencies root hdl suffixes node deps =
    
    455
    -  traverse_ write tasks
    
    547
    +  [String]
    
    548
    +dependencyRules root suffixes node deps =
    
    549
    +  map rule tasks
    
    456 550
       where
    
    457 551
         tasks = source_dep : boot_dep ++ concatMap import_dep deps
    
    458 552
     
    
    ... ... @@ -479,7 +573,7 @@ writeDependencies root hdl suffixes node deps =
    479 573
     
    
    480 574
           DepCpp {dep_path} -> [(obj_files, dep_path)]
    
    481 575
     
    
    482
    -    write (from, to) = writeDependency root hdl from to
    
    576
    +    rule (from, to) = dependencyRule root from to
    
    483 577
     
    
    484 578
         obj_files = suffixed dn_obj
    
    485 579
     
    
    ... ... @@ -488,18 +582,18 @@ writeDependencies root hdl suffixes node deps =
    488 582
         DepNode {dn_src, dn_obj, dn_hi, dn_mod} = node
    
    489 583
     
    
    490 584
     -----------------------------
    
    491
    -writeDependency :: OsPath -> Handle -> [OsPath] -> OsPath -> IO ()
    
    492
    --- (writeDependency r h [t1,t2] dep) writes to handle h the dependency
    
    585
    +dependencyRule :: OsPath -> [OsPath] -> OsPath -> String
    
    586
    +-- (dependencyRule r [t1,t2] dep) renders the dependency
    
    493 587
     --      t1 t2 : dep
    
    494
    -writeDependency root hdl targets dep
    
    495
    -  = do let -- We need to avoid making deps on
    
    496
    -           --     c:/foo/...
    
    497
    -           -- on Windows as make gets confused by the :
    
    498
    -           -- Making relative deps avoids some instances of this.
    
    499
    -           dep' = OsPath.makeRelative root dep
    
    500
    -           forOutput = escapeSpaces . reslash Forwards . unsafeDecodeUtf . OsPath.normalise
    
    501
    -           output = unwords (map forOutput targets) ++ " : " ++ forOutput dep'
    
    502
    -       hPutStrLn hdl output
    
    588
    +dependencyRule root targets dep
    
    589
    +  = let -- We need to avoid making deps on
    
    590
    +        --     c:/foo/...
    
    591
    +        -- on Windows as make gets confused by the :
    
    592
    +        -- Making relative deps avoids some instances of this.
    
    593
    +        dep' = OsPath.makeRelative root dep
    
    594
    +        forOutput = escapeSpaces . reslash Forwards . unsafeDecodeUtf . OsPath.normalise
    
    595
    +    in
    
    596
    +        unwords (map forOutput targets) ++ " : " ++ forOutput dep'
    
    503 597
     
    
    504 598
     -----------------------------
    
    505 599
     insertSuffixes
    
    ... ... @@ -554,16 +648,27 @@ endMkDependHS logger
    554 648
     --
    
    555 649
     -----------------------------------------------------------------
    
    556 650
     
    
    557
    -initJsonDepWriter :: Logger -> TmpFs -> DynFlags -> FilePath -> IO DependencyWriter
    
    558
    -initJsonDepWriter logger tmpfs dflags output = do
    
    559
    -  json_var <- mkJsonOutput logger tmpfs dflags output initDepJson
    
    560
    -  pure DependencyWriter
    
    561
    -    { dw_beginWriter =
    
    562
    -        pure $ DepSink $ \ node deps ->
    
    563
    -          writeHomeUnitDeps json_var node deps
    
    564
    -    , dw_endWriter = do
    
    565
    -        writeJsonOutput logger json_var
    
    566
    -    }
    
    651
    +initJsonDepWriter :: Logger -> TmpFs -> TempDir -> DepOutput -> IO DependencyWriter
    
    652
    +initJsonDepWriter logger tmpfs tmpdir output = do
    
    653
    +  stream <- initJsonDepStream logger tmpfs tmpdir output
    
    654
    +  json_var <- mkJsonOutput
    
    655
    +  pure
    
    656
    +    DependencyWriter
    
    657
    +      { dw_sink =
    
    658
    +          DepSink $ \node deps -> do
    
    659
    +            extUnits <- readJson json_var
    
    660
    +            let
    
    661
    +              (extUnitsDeps, payload) = homeUnitDeps node deps
    
    662
    +              newExtUnits = Set.difference extUnitsDeps (externalDeps extUnits)
    
    663
    +            -- Write new external unit deps before the module that uses them
    
    664
    +            for_ newExtUnits $ \extUnit -> do
    
    665
    +              depStream_write stream (renderJsonl extUnit)
    
    666
    +            depStream_write stream (renderJsonl payload)
    
    667
    +            -- Cache external deps we already reported in the past
    
    668
    +            updateJson json_var $ cacheExternalDepsJson newExtUnits
    
    669
    +      , dw_endWriter = depStream_close stream
    
    670
    +      , dw_onError = depStream_onError stream
    
    671
    +      }
    
    567 672
     
    
    568 673
     --------------------------------------------------------------------------------
    
    569 674
     -- Output interface for json dumps
    
    ... ... @@ -572,65 +677,60 @@ initJsonDepWriter logger tmpfs dflags output = do
    572 677
     -- The flag @-dep-json@ add an additional output target for dependency
    
    573 678
     -- diagnostics.
    
    574 679
     --
    
    575
    --- Contains temporary file locations to stream output to.
    
    576
    -data JsonOutput =
    
    577
    -  JsonOutput {
    
    578
    -    -- | This ref is updated in @processDeps@ incrementally, using a
    
    579
    -    -- flag-specific type.
    
    580
    -    json_ref :: IORef DepJson,
    
    581
    -
    
    582
    -    -- | The output file path specified as argument to the flag.
    
    583
    -    json_path :: FilePath,
    
    584
    -    -- | Name of the temporary file
    
    585
    -    json_tmp_file  :: FilePath,
    
    586
    -    -- | Handle of the open temporary file
    
    587
    -    json_tmp_hdl   :: Handle
    
    680
    +data JsonOutput
    
    681
    +  = JsonOutput
    
    682
    +  { json_ref :: IORef DepJson
    
    683
    +  -- ^ This ref is updated in @processDeps@ incrementally, using a
    
    684
    +  -- flag-specific type.
    
    588 685
       }
    
    589 686
     
    
    590
    --- | Set up json generation for `ghc -M`.
    
    591
    ---
    
    592
    --- Creates a temporary file that we write the dependency information to.
    
    593
    --- The temporary file is written to the final output file path in 'writeJsonOutput'.
    
    594
    -mkJsonOutput ::
    
    595
    -  Logger ->
    
    596
    -  TmpFs ->
    
    597
    -  DynFlags ->
    
    598
    -  FilePath ->
    
    599
    -  IO (IORef DepJson) ->
    
    600
    -  IO JsonOutput
    
    601
    -mkJsonOutput logger tmpfs dflags json_path mk_ref = do
    
    602
    -  json_ref <- mk_ref
    
    603
    -  -- open a new temp file in which to stuff the dependency info
    
    687
    +data JsonDepFiles = JsonDepFiles
    
    688
    +  { json_path :: FilePath
    
    689
    +    -- ^ The output file path specified as argument to the flag.
    
    690
    +  , json_tmp_file  :: FilePath
    
    691
    +    -- ^ Name of the temporary file
    
    692
    +  , json_tmp_hdl   :: Handle
    
    693
    +    -- ^ Handle of the open temporary file
    
    694
    +  }
    
    695
    +
    
    696
    +initJsonDepFiles :: Logger -> TmpFs -> TempDir -> FilePath -> IO JsonDepFiles
    
    697
    +initJsonDepFiles logger tmpfs tmpdir path = do
    
    698
    +  -- open a new temp file in which to stuff the dependency info into
    
    604 699
       -- as we go along.
    
    605
    -  json_tmp_file <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "dep"
    
    700
    +  json_tmp_file <- newTempName logger tmpfs tmpdir TFL_CurrentModule "dep-json"
    
    606 701
       json_tmp_hdl <- openFile json_tmp_file WriteMode
    
    607
    -
    
    608
    -  pure JsonOutput {json_ref, json_path, json_tmp_file, json_tmp_hdl}
    
    609
    -
    
    610
    -updateJson :: JsonOutput -> (DepJson -> DepJson) -> IO ()
    
    611
    -updateJson JsonOutput {json_ref} f = modifyIORef' json_ref f
    
    612
    -
    
    613
    -readJson :: JsonOutput -> IO DepJson
    
    614
    -readJson JsonOutput {json_ref} = readIORef json_ref
    
    702
    +  pure $ JsonDepFiles
    
    703
    +    { json_path = path
    
    704
    +    , json_tmp_file = json_tmp_file
    
    705
    +    , json_tmp_hdl = json_tmp_hdl
    
    706
    +    }
    
    615 707
     
    
    616 708
     -- | Finalise the json generation by copying the temporary file to the final destination.
    
    617 709
     -- Avoids partial writes in the case of an error.
    
    618
    -writeJsonOutput ::
    
    619
    -  Logger ->
    
    620
    -  JsonOutput ->
    
    621
    -  IO ()
    
    622
    -writeJsonOutput logger JsonOutput {json_path, json_tmp_file, json_tmp_hdl} = do
    
    710
    +endJsonDepFiles :: Logger -> JsonDepFiles -> IO ()
    
    711
    +endJsonDepFiles logger JsonDepFiles {json_path, json_tmp_file, json_tmp_hdl} = do
    
    623 712
       hClose json_tmp_hdl
    
    624 713
       -- Copy the new jsonl in place
    
    625 714
       showPass logger "Installing new json output"
    
    626 715
       SysTools.copyFile json_tmp_file json_path
    
    627 716
     
    
    717
    +-- | Set up json generation for `ghc -M`.
    
    718
    +mkJsonOutput :: IO JsonOutput
    
    719
    +mkJsonOutput =
    
    720
    +  JsonOutput <$> newIORef (DepJson Set.empty)
    
    721
    +
    
    722
    +updateJson :: JsonOutput -> (DepJson -> DepJson) -> IO ()
    
    723
    +updateJson JsonOutput {json_ref} f = modifyIORef' json_ref f
    
    724
    +
    
    725
    +readJson :: JsonOutput -> IO DepJson
    
    726
    +readJson JsonOutput {json_ref} = readIORef json_ref
    
    727
    +
    
    628 728
     --------------------------------------------------------------------------------
    
    629 729
     -- Output helpers
    
    630 730
     
    
    631
    -writeJsonl :: ToJson a => JsonOutput -> a -> IO ()
    
    632
    -writeJsonl  JsonOutput {json_tmp_hdl} output = do
    
    633
    -  hPutStrLn json_tmp_hdl (showSDocUnsafe $ renderJSON $ json output)
    
    731
    +renderJsonl :: ToJson a => a -> String
    
    732
    +renderJsonl output =
    
    733
    +  showSDocUnsafe $ renderJSON $ json output
    
    634 734
     
    
    635 735
     --------------------------------------------------------------------------------
    
    636 736
     -- Payload for -dep-json
    
    ... ... @@ -788,9 +888,6 @@ instance ToJson ExtUnitDep where
    788 888
         where
    
    789 889
           showPackageId (DPackageId (PackageId pid)) = unpackFS pid
    
    790 890
     
    
    791
    -initDepJson :: IO (IORef DepJson)
    
    792
    -initDepJson = newIORef $ DepJson Set.empty
    
    793
    -
    
    794 891
     cacheExternalDepsJson :: Set.Set ExtUnitDep -> DepJson -> DepJson
    
    795 892
     cacheExternalDepsJson extUnits (DepJson e0) =
    
    796 893
       DepJson
    
    ... ... @@ -798,19 +895,10 @@ cacheExternalDepsJson extUnits (DepJson e0) =
    798 895
             Set.union e0 extUnits
    
    799 896
         }
    
    800 897
     
    
    801
    -writeHomeUnitDeps :: JsonOutput -> DepNode -> [Dep] -> IO ()
    
    802
    -writeHomeUnitDeps deps_json DepNode {..} deps = do
    
    803
    -  extUnits <- readJson deps_json
    
    804
    -  let newExtUnits = Set.difference extUnitsDeps (externalDeps extUnits)
    
    805
    -  -- Write new external unit deps before the module that uses them
    
    806
    -  for_ newExtUnits $ \ extUnit -> do
    
    807
    -    writeJsonl deps_json extUnit
    
    808
    -  writeJsonl deps_json payload
    
    809
    -  -- Cache external deps we already reported in the past
    
    810
    -  updateJson deps_json $ cacheExternalDepsJson newExtUnits
    
    898
    +homeUnitDeps :: Foldable t => DepNode -> t Dep -> (Set.Set ExtUnitDep, HomeUnitDep)
    
    899
    +homeUnitDeps DepNode {..} deps =
    
    900
    +  foldl' go (Set.empty, initial_node_data) deps
    
    811 901
       where
    
    812
    -    (extUnitsDeps, payload) = foldl' go (Set.empty, initial_node_data) deps
    
    813
    -
    
    814 902
         initial_node_data =
    
    815 903
           HomeUnitDep
    
    816 904
             { unitId = dn_unitId
    

  • compiler/GHC/Driver/Session.hs
    ... ... @@ -790,16 +790,44 @@ addOptCmmP f = alterToolSettings $ \s -> s
    790 790
               }
    
    791 791
     
    
    792 792
     setDepMakefile :: FilePath -> DynFlags -> DynFlags
    
    793
    -setDepMakefile f d = d { depMakefile = Just f }
    
    793
    +setDepMakefile f d = d { depMakefile = MkDepend_Explicit f
    
    794
    +                       -- depJson has no default value, we add this for symmetry with `setDepJson`
    
    795
    +                       -- and if anything changes in the future, then the code is already here :)
    
    796
    +                       , depJson = unsetMkDependOutputIfDefault (depJson d)
    
    797
    +                       }
    
    798
    +
    
    799
    +setDepMakefileStdout :: DynFlags -> DynFlags
    
    800
    +setDepMakefileStdout d = d { depMakefile = MkDepend_StdOut
    
    801
    +                           -- depJson has no default value, we add this for symmetry with `setDepJson`
    
    802
    +                           -- and if anything changes in the future, then the code is already here :)
    
    803
    +                           , depJson = unsetMkDependOutputIfDefault (depJson d)
    
    804
    +                           }
    
    794 805
     
    
    795 806
     unsetDepMakefile :: DynFlags -> DynFlags
    
    796
    -unsetDepMakefile d = d { depMakefile = Nothing }
    
    807
    +unsetDepMakefile d = d { depMakefile = MkDepend_None }
    
    797 808
     
    
    798 809
     setDepJson :: FilePath -> DynFlags -> DynFlags
    
    799
    -setDepJson f d = d { depJson = Just f }
    
    810
    +setDepJson f d = d { depJson = MkDepend_Explicit f
    
    811
    +                   -- We generate a Makefile by default, but if a user requests json
    
    812
    +                   -- output, then they most likely don't need a Makefile.
    
    813
    +                   -- Thus, we only generate it if the user requests it.
    
    814
    +                   , depMakefile = unsetMkDependOutputIfDefault (depMakefile d)
    
    815
    +                   }
    
    816
    +
    
    817
    +setDepJsonStdout :: DynFlags -> DynFlags
    
    818
    +setDepJsonStdout d = d { depJson = MkDepend_StdOut
    
    819
    +                       -- We generate a Makefile by default, but if a user requests json
    
    820
    +                       -- output, then they most likely don't need a Makefile.
    
    821
    +                       -- Thus, we only generate it if the user requests it.
    
    822
    +                       , depMakefile = unsetMkDependOutputIfDefault (depMakefile d)
    
    823
    +                       }
    
    800 824
     
    
    801 825
     unsetDepJson :: DynFlags -> DynFlags
    
    802
    -unsetDepJson d = d { depJson = Nothing }
    
    826
    +unsetDepJson d = d { depJson = MkDepend_None }
    
    827
    +
    
    828
    +unsetMkDependOutputIfDefault :: MkDependOutput -> MkDependOutput
    
    829
    +unsetMkDependOutputIfDefault (MkDepend_Default _) = MkDepend_None
    
    830
    +unsetMkDependOutputIfDefault mkDepend_output      = mkDepend_output
    
    803 831
     
    
    804 832
     setDepIncludeCppDeps :: Bool -> DynFlags -> DynFlags
    
    805 833
     setDepIncludeCppDeps b d = d { depIncludeCppDeps = b }
    
    ... ... @@ -1272,8 +1300,10 @@ dynamic_flags_deps = [
    1272 1300
       , make_ord_flag defGhcFlag "dep-suffix"              (hasArg addDepSuffix)
    
    1273 1301
       , make_ord_flag defGhcFlag "dep-makefile"            (hasArg setDepMakefile)
    
    1274 1302
       , make_ord_flag defGhcFlag "no-dep-makefile"         (noArg unsetDepMakefile)
    
    1303
    +  , make_ord_flag defGhcFlag "dep-makefile-stdout"     (noArg setDepMakefileStdout)
    
    1275 1304
       , make_ord_flag defGhcFlag "dep-json"                (hasArg setDepJson)
    
    1276 1305
       , make_ord_flag defGhcFlag "no-dep-json"             (noArg unsetDepJson)
    
    1306
    +  , make_ord_flag defGhcFlag "dep-json-stdout"         (noArg setDepJsonStdout)
    
    1277 1307
       , make_ord_flag defGhcFlag "include-cpp-deps"
    
    1278 1308
             (noArg (setDepIncludeCppDeps True))
    
    1279 1309
       , make_ord_flag defGhcFlag "include-pkg-deps"
    

  • docs/users_guide/separate_compilation.rst
    ... ... @@ -1511,6 +1511,23 @@ generation are:
    1511 1511
     
    
    1512 1512
         Introduced in GHC 10.1, ``-no-dep-makefile`` disables the generation of a Makefile altogether.
    
    1513 1513
     
    
    1514
    +.. ghc-flag:: -dep-makefile-stdout
    
    1515
    +    :shortdesc: Write dependency generation to stdout using makefile format
    
    1516
    +    :type: dynamic
    
    1517
    +    :reverse: -no-dep-makefile
    
    1518
    +    :category: redirect-output
    
    1519
    +
    
    1520
    +    :since: 10.1
    
    1521
    +
    
    1522
    +    Stream the dependency generation of :ghc-flag:`-dep-makefile โŸจfileโŸฉ` to stdout instead of โŸจfileโŸฉ.
    
    1523
    +
    
    1524
    +    Contrary to :ghc-flag:`-dep-makefile โŸจfileโŸฉ`, the markers
    
    1525
    +
    
    1526
    +    * "``# DO NOT DELETE: Beginning of Haskell dependencies``" and
    
    1527
    +    * "``# DO NOT DELETE: End of Haskell dependencies``"
    
    1528
    +
    
    1529
    +    are not emitted.
    
    1530
    +
    
    1514 1531
     .. ghc-flag:: -dep-json โŸจfileโŸฉ
    
    1515 1532
         :shortdesc: Write dependencies to โŸจfileโŸฉ as a JSON Lines format
    
    1516 1533
         :type: dynamic
    
    ... ... @@ -1540,8 +1557,19 @@ generation are:
    1540 1557
     
    
    1541 1558
         ``-no-dep-json`` disables the generation of the JSON file.
    
    1542 1559
     
    
    1543
    -    By default, :ghc-flag:`-dep-makefile โŸจfileโŸฉ` is enabled even if :ghc-flag:`-dep-json โŸจfileโŸฉ` is given.
    
    1544
    -    Disable the generation of any Makefile via ``-no-dep-makefile``.
    
    1560
    +    :ghc-flag:`-dep-json โŸจfileโŸฉ` and :ghc-flag:`-dep-json-stdout` disable the default generation of a Makefile.
    
    1561
    +    To generate a Makefile for the dependency information, explicitly use :ghc-flag:`-dep-makefile โŸจfileโŸฉ` or
    
    1562
    +    :ghc-flag:`-dep-makefile-stdout`.
    
    1563
    +
    
    1564
    +.. ghc-flag:: -dep-json-stdout
    
    1565
    +    :shortdesc: Write dependency generation to stdout using JSON Lines format
    
    1566
    +    :type: dynamic
    
    1567
    +    :reverse: -no-dep-json
    
    1568
    +    :category: redirect-output
    
    1569
    +
    
    1570
    +    :since: 10.1
    
    1571
    +
    
    1572
    +    Stream the dependency generation of :ghc-flag:`-dep-json โŸจfileโŸฉ` to stdout instead of โŸจfileโŸฉ.
    
    1545 1573
     
    
    1546 1574
     .. ghc-flag:: -dep-suffix โŸจsuffixโŸฉ
    
    1547 1575
         :shortdesc: Make dependencies that declare that files with suffix
    

  • testsuite/driver/my_typing.py
    ... ... @@ -10,7 +10,7 @@ The testsuite driver can be typechecked using mypy [1].
    10 10
     
    
    11 11
     from typing import *
    
    12 12
     import typing
    
    13
    -
    
    13
    +import enum
    
    14 14
     
    
    15 15
     ####################################################
    
    16 16
     # Backwards compatibility shims
    
    ... ... @@ -34,3 +34,7 @@ GitHash = NewType("GitHash", str) # a Git commit hash
    34 34
     GitRef = NewType("GitRef", str)
    
    35 35
     TestEnv = NewType("TestEnv", str)
    
    36 36
     MetricName = NewType("MetricName", str)
    
    37
    +
    
    38
    +# Used by `ghc -M` test mode
    
    39
    +DepMode = enum.Enum('DepMode', [('NONE', 0), ('FILE', 1), ('STDOUT', 2)])
    
    40
    +

  • testsuite/driver/testglobals.py
    ... ... @@ -390,8 +390,8 @@ class TestOptions:
    390 390
            self.ignore_extension = False
    
    391 391
     
    
    392 392
            # make_depend tests: which outputs to write and check
    
    393
    -       self.dep_makefile = False
    
    394
    -       self.dep_json = False
    
    393
    +       self.dep_makefile: DepMode = DepMode.NONE
    
    394
    +       self.dep_json: DepMode = DepMode.NONE
    
    395 395
            self.ignore_dep_outputs = False
    
    396 396
     
    
    397 397
            # Backpack test
    

  • testsuite/driver/testlib.py
    ... ... @@ -438,14 +438,26 @@ def dep_makefile( name, opts ):
    438 438
         For make_depend tests: write the -dep-makefile output and
    
    439 439
         compare it against <name>.dep-makefile.
    
    440 440
         """
    
    441
    -    opts.dep_makefile = True
    
    441
    +    opts.dep_makefile = DepMode.FILE
    
    442 442
     
    
    443 443
     def dep_json( name, opts ):
    
    444 444
         """
    
    445 445
         For make_depend tests: write the -dep-json output and
    
    446 446
         compare it against <name>.dep-json.
    
    447 447
         """
    
    448
    -    opts.dep_json = True
    
    448
    +    opts.dep_json = DepMode.FILE
    
    449
    +
    
    450
    +def dep_makefile_stdout( name, opts ):
    
    451
    +    """
    
    452
    +    For make_depend tests: write the -dep-makefile output to stdout.
    
    453
    +    """
    
    454
    +    opts.dep_makefile = DepMode.STDOUT
    
    455
    +
    
    456
    +def dep_json_stdout( name, opts ):
    
    457
    +    """
    
    458
    +    For make_depend tests: write the -dep-json output to stdout.
    
    459
    +    """
    
    460
    +    opts.dep_json = DepMode.STDOUT
    
    449 461
     
    
    450 462
     def ignore_dep_outputs( name, opts ):
    
    451 463
         """
    
    ... ... @@ -2060,14 +2072,19 @@ async def do_make_depend(name: TestName,
    2060 2072
     
    
    2061 2073
         outputs = []
    
    2062 2074
         output_flags = []
    
    2063
    -    if opts.dep_makefile:
    
    2075
    +    if opts.dep_makefile == DepMode.FILE:
    
    2064 2076
             outputs.append(('dep-makefile', normalise_dep_makefile))
    
    2065 2077
             output_flags.append('-dep-makefile %s' % actual_file('dep-makefile'))
    
    2066
    -    else:
    
    2067
    -        output_flags.append('-no-dep-makefile')
    
    2068
    -    if opts.dep_json:
    
    2078
    +    elif opts.dep_makefile == DepMode.STDOUT:
    
    2079
    +        outputs.append(('stdout', normalise_dep_makefile))
    
    2080
    +        output_flags.append('-dep-makefile-stdout')
    
    2081
    +
    
    2082
    +    if opts.dep_json == DepMode.FILE:
    
    2069 2083
             outputs.append(('dep-json', normalise_dep_json))
    
    2070 2084
             output_flags.append('-dep-json %s' % actual_file('dep-json'))
    
    2085
    +    elif opts.dep_json == DepMode.STDOUT:
    
    2086
    +        outputs.append(('stdout', normalise_dep_json))
    
    2087
    +        output_flags.append('-dep-json-stdout')
    
    2071 2088
     
    
    2072 2089
         result = await do_compile( name, way, False, None, [], units,
    
    2073 2090
                                    ' '.join(output_flags + [extra_hc_opts]),
    
    ... ... @@ -2077,9 +2094,9 @@ async def do_make_depend(name: TestName,
    2077 2094
     
    
    2078 2095
         for (kind, normaliser) in outputs:
    
    2079 2096
             output_match = await compare_outputs(way, kind,
    
    2080
    -                           join_normalisers(opts.extra_normaliser,
    
    2081
    -                                            normalise_slashes_, normaliser),
    
    2082
    -                           find_expected_file(name, kind, way), actual_file(kind))
    
    2097
    +                           join_normalisers(opts.extra_normaliser, normalise_slashes_, normaliser),
    
    2098
    +                           find_expected_file(name, kind, way),
    
    2099
    +                           actual_file(kind))
    
    2083 2100
             if not output_match:
    
    2084 2101
                 return failBecause(kind + ' mismatch', diff=output_match.diff)
    
    2085 2102
     
    

  • testsuite/tests/driver/mkdepend/all.T
    ... ... @@ -15,9 +15,20 @@ test('T24384b', [ *T24384_extras, when(opsys('mingw32'), skip), *json_normaliser
    15 15
     test('T24384c', [ *T24384_extras, when(opsys('mingw32'), skip), *json_normalisers ], makefile_test, [])
    
    16 16
     
    
    17 17
     # Multiple home units with explicit level imports.
    
    18
    -test('mkdepend_mhu01',
    
    18
    +test('mkdepend_mhu01a',
    
    19 19
          [ extra_files(['mhu01/']), dep_makefile, dep_json ],
    
    20 20
          make_depend_multiunit, [['mhu01/unitA', 'mhu01/unitB', 'mhu01/unitC'], ''])
    
    21
    +# test the output streaming and writing to files
    
    22
    +test('mkdepend_mhu01b',
    
    23
    +     [ extra_files(['mhu01/']), dep_json_stdout ],
    
    24
    +     make_depend_multiunit, [['mhu01/unitA', 'mhu01/unitB', 'mhu01/unitC'], ''])
    
    25
    +test('mkdepend_mhu01c',
    
    26
    +     [ extra_files(['mhu01/']), dep_makefile_stdout ],
    
    27
    +     make_depend_multiunit, [['mhu01/unitA', 'mhu01/unitB', 'mhu01/unitC'], ''])
    
    28
    +test('mkdepend_mhu01d',
    
    29
    +     [ extra_files(['mhu01/']), dep_json_stdout, dep_makefile ],
    
    30
    +     make_depend_multiunit, [['mhu01/unitA', 'mhu01/unitB', 'mhu01/unitC'], ''])
    
    31
    +
    
    21 32
     # Preprocessor must not be inherited by default active home unit
    
    22 33
     test('mkdepend_mhu02',
    
    23 34
          [ extra_files(['mhu02/']), dep_json
    

  • testsuite/tests/driver/mkdepend/mkdepend_mhu01.dep-json โ†’ testsuite/tests/driver/mkdepend/mkdepend_mhu01a.dep-json

  • testsuite/tests/driver/mkdepend/mkdepend_mhu01.dep-makefile โ†’ testsuite/tests/driver/mkdepend/mkdepend_mhu01a.dep-makefile
    1 1
     # DO NOT DELETE: Beginning of Haskell dependencies
    
    2
    +mhu01/a/A/Base.o-boot : mhu01/a/A/Base.hs-boot
    
    2 3
     mhu01/a/A/Base.o : mhu01/a/A/Base.hi-boot
    
    4
    +mhu01/a/Util.o : mhu01/a/Util.hs
    
    5
    +mhu01/a/Util.o : mhu01/a/A/Base.hi-boot
    
    3 6
     mhu01/a/A/Base.o : mhu01/a/A/Base.hs
    
    4 7
     mhu01/a/A/Base.o : mhu01/a/Util.hi
    
    5
    -mhu01/a/A/Base.o-boot : mhu01/a/A/Base.hs-boot
    
    6
    -mhu01/a/A/TH.o : mhu01/a/A/Base.hi
    
    7 8
     mhu01/a/A/TH.o : mhu01/a/A/TH.hs
    
    8
    -mhu01/a/Util.o : mhu01/a/A/Base.hi-boot
    
    9
    -mhu01/a/Util.o : mhu01/a/Util.hs
    
    10
    -mhu01/b/B/Normal.o : mhu01/a/A/Base.hi
    
    11
    -mhu01/b/B/Normal.o : mhu01/b/B/Normal.hs
    
    12
    -mhu01/b/B/Normal.o : mhu01/b/B/Splice.hi
    
    13
    -mhu01/b/B/Splice.o : mhu01/a/A/Base.hi
    
    14
    -mhu01/b/B/Splice.o : mhu01/a/A/TH.hi
    
    9
    +mhu01/a/A/TH.o : mhu01/a/A/Base.hi
    
    10
    +mhu01/b/Util.o : mhu01/b/Util.hs
    
    15 11
     mhu01/b/B/Splice.o : mhu01/b/B/Splice.hs
    
    16 12
     mhu01/b/B/Splice.o : mhu01/b/Util.hi
    
    17
    -mhu01/b/Util.o : mhu01/b/Util.hs
    
    18
    -mhu01/c/C.o : mhu01/a/Util.hi
    
    19
    -mhu01/c/C.o : mhu01/b/B/Normal.hi
    
    13
    +mhu01/b/B/Splice.o : mhu01/a/A/Base.hi
    
    14
    +mhu01/b/B/Splice.o : mhu01/a/A/TH.hi
    
    15
    +mhu01/b/B/Normal.o : mhu01/b/B/Normal.hs
    
    16
    +mhu01/b/B/Normal.o : mhu01/b/B/Splice.hi
    
    17
    +mhu01/b/B/Normal.o : mhu01/a/A/Base.hi
    
    18
    +mhu01/c/C.o : mhu01/c/C.hs
    
    20 19
     mhu01/c/C.o : mhu01/b/B/Splice.hi
    
    20
    +mhu01/c/C.o : mhu01/b/B/Normal.hi
    
    21 21
     mhu01/c/C.o : mhu01/b/Util.hi
    
    22
    -mhu01/c/C.o : mhu01/c/C.hs
    
    22
    +mhu01/c/C.o : mhu01/a/Util.hi
    
    23 23
     # DO NOT DELETE: End of Haskell dependencies

  • testsuite/tests/driver/mkdepend/mkdepend_mhu01b.stderr
    1
    +{"module":"A.Base","unit-id":"a","boot":true,"imports":{},"package-name":"a","source":"mhu01/a/A/Base.hs-boot"}
    
    2
    +{"module":"Util","unit-id":"a","imports":{"a":[{"module":"A.Base","boot":true}]},"package-name":"a","source":"mhu01/a/Util.hs"}
    
    3
    +{"module":"A.Base","unit-id":"a","imports":{"a":["Util"]},"package-name":"a","source":"mhu01/a/A/Base.hs"}
    
    4
    +{"module":"A.TH","unit-id":"a","imports":{"a":["A.Base"]},"package-name":"a","source":"mhu01/a/A/TH.hs"}
    
    5
    +{"module":"Util","unit-id":"b","imports":{},"package-name":"b","source":"mhu01/b/Util.hs"}
    
    6
    +{"module":"B.Splice","unit-id":"b","imports":{"a":[{"module":"A.Base","level":"quote"},{"module":"A.TH","level":"splice"}],"b":["Util"]},"package-name":"b","source":"mhu01/b/B/Splice.hs"}
    
    7
    +{"module":"B.Normal","unit-id":"b","imports":{"a":["A.Base"],"b":["B.Splice"]},"package-name":"b","source":"mhu01/b/B/Normal.hs"}
    
    8
    +{"module":"C","unit-id":"c","imports":{"a":[{"module":"Util","level":"splice"}],"b":["B.Normal",{"module":"B.Splice","level":"splice"},{"module":"Util","level":"quote"}]},"package-name":"c","source":"mhu01/c/C.hs"}

  • testsuite/tests/driver/mkdepend/mkdepend_mhu01c.stderr
    1
    +mhu01/a/A/Base.o-boot : mhu01/a/A/Base.hs-boot
    
    2
    +mhu01/a/A/Base.o : mhu01/a/A/Base.hi-boot
    
    3
    +mhu01/a/Util.o : mhu01/a/Util.hs
    
    4
    +mhu01/a/Util.o : mhu01/a/A/Base.hi-boot
    
    5
    +mhu01/a/A/Base.o : mhu01/a/A/Base.hs
    
    6
    +mhu01/a/A/Base.o : mhu01/a/Util.hi
    
    7
    +mhu01/a/A/TH.o : mhu01/a/A/TH.hs
    
    8
    +mhu01/a/A/TH.o : mhu01/a/A/Base.hi
    
    9
    +mhu01/b/Util.o : mhu01/b/Util.hs
    
    10
    +mhu01/b/B/Splice.o : mhu01/b/B/Splice.hs
    
    11
    +mhu01/b/B/Splice.o : mhu01/b/Util.hi
    
    12
    +mhu01/b/B/Splice.o : mhu01/a/A/Base.hi
    
    13
    +mhu01/b/B/Splice.o : mhu01/a/A/TH.hi
    
    14
    +mhu01/b/B/Normal.o : mhu01/b/B/Normal.hs
    
    15
    +mhu01/b/B/Normal.o : mhu01/b/B/Splice.hi
    
    16
    +mhu01/b/B/Normal.o : mhu01/a/A/Base.hi
    
    17
    +mhu01/c/C.o : mhu01/c/C.hs
    
    18
    +mhu01/c/C.o : mhu01/b/B/Splice.hi
    
    19
    +mhu01/c/C.o : mhu01/b/B/Normal.hi
    
    20
    +mhu01/c/C.o : mhu01/b/Util.hi
    
    21
    +mhu01/c/C.o : mhu01/a/Util.hi

  • testsuite/tests/driver/mkdepend/mkdepend_mhu01d.dep-makefile
    1
    +# DO NOT DELETE: Beginning of Haskell dependencies
    
    2
    +mhu01/a/A/Base.o-boot : mhu01/a/A/Base.hs-boot
    
    3
    +mhu01/a/A/Base.o : mhu01/a/A/Base.hi-boot
    
    4
    +mhu01/a/Util.o : mhu01/a/Util.hs
    
    5
    +mhu01/a/Util.o : mhu01/a/A/Base.hi-boot
    
    6
    +mhu01/a/A/Base.o : mhu01/a/A/Base.hs
    
    7
    +mhu01/a/A/Base.o : mhu01/a/Util.hi
    
    8
    +mhu01/a/A/TH.o : mhu01/a/A/TH.hs
    
    9
    +mhu01/a/A/TH.o : mhu01/a/A/Base.hi
    
    10
    +mhu01/b/Util.o : mhu01/b/Util.hs
    
    11
    +mhu01/b/B/Splice.o : mhu01/b/B/Splice.hs
    
    12
    +mhu01/b/B/Splice.o : mhu01/b/Util.hi
    
    13
    +mhu01/b/B/Splice.o : mhu01/a/A/Base.hi
    
    14
    +mhu01/b/B/Splice.o : mhu01/a/A/TH.hi
    
    15
    +mhu01/b/B/Normal.o : mhu01/b/B/Normal.hs
    
    16
    +mhu01/b/B/Normal.o : mhu01/b/B/Splice.hi
    
    17
    +mhu01/b/B/Normal.o : mhu01/a/A/Base.hi
    
    18
    +mhu01/c/C.o : mhu01/c/C.hs
    
    19
    +mhu01/c/C.o : mhu01/b/B/Splice.hi
    
    20
    +mhu01/c/C.o : mhu01/b/B/Normal.hi
    
    21
    +mhu01/c/C.o : mhu01/b/Util.hi
    
    22
    +mhu01/c/C.o : mhu01/a/Util.hi
    
    23
    +# DO NOT DELETE: End of Haskell dependencies

  • testsuite/tests/driver/mkdepend/mkdepend_mhu01d.stderr
    1
    +{"module":"A.Base","unit-id":"a","boot":true,"imports":{},"package-name":"a","source":"mhu01/a/A/Base.hs-boot"}
    
    2
    +{"module":"Util","unit-id":"a","imports":{"a":[{"module":"A.Base","boot":true}]},"package-name":"a","source":"mhu01/a/Util.hs"}
    
    3
    +{"module":"A.Base","unit-id":"a","imports":{"a":["Util"]},"package-name":"a","source":"mhu01/a/A/Base.hs"}
    
    4
    +{"module":"A.TH","unit-id":"a","imports":{"a":["A.Base"]},"package-name":"a","source":"mhu01/a/A/TH.hs"}
    
    5
    +{"module":"Util","unit-id":"b","imports":{},"package-name":"b","source":"mhu01/b/Util.hs"}
    
    6
    +{"module":"B.Splice","unit-id":"b","imports":{"a":[{"module":"A.Base","level":"quote"},{"module":"A.TH","level":"splice"}],"b":["Util"]},"package-name":"b","source":"mhu01/b/B/Splice.hs"}
    
    7
    +{"module":"B.Normal","unit-id":"b","imports":{"a":["A.Base"],"b":["B.Splice"]},"package-name":"b","source":"mhu01/b/B/Normal.hs"}
    
    8
    +{"module":"C","unit-id":"c","imports":{"a":[{"module":"Util","level":"splice"}],"b":["B.Normal",{"module":"B.Splice","level":"splice"},{"module":"Util","level":"quote"}]},"package-name":"c","source":"mhu01/c/C.hs"}