Marge Bot pushed to branch master 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,
    
    ... ... @@ -335,8 +338,8 @@ data DynFlags = DynFlags {
    335 338
         -- ^ External plugins loaded from shared libraries
    
    336 339
     
    
    337 340
       --  For ghc -M
    
    338
    -  depMakefile           :: Maybe FilePath,
    
    339
    -  depJson               :: Maybe FilePath,
    
    341
    +  depMakefile           :: MkDependOutput,
    
    342
    +  depJson               :: MkDependOutput,
    
    340 343
       depIncludePkgDeps     :: Bool,
    
    341 344
       depIncludeCppDeps     :: Bool,
    
    342 345
       depExcludeMods        :: [ModuleName],
    
    ... ... @@ -670,8 +673,8 @@ defaultDynFlags mySettings =
    670 673
             llvmOptLevel            = 0,
    
    671 674
     
    
    672 675
             -- ghc -M values
    
    673
    -        depMakefile       = Just "Makefile",
    
    674
    -        depJson           = Nothing,
    
    676
    +        depMakefile       = MkDepend_Default "Makefile",
    
    677
    +        depJson           = MkDepend_None,
    
    675 678
             depIncludePkgDeps = False,
    
    676 679
             depIncludeCppDeps = False,
    
    677 680
             depExcludeMods    = [],
    
    ... ... @@ -766,6 +769,15 @@ flattenExtensionFlags ml = foldr g defaultExtensionFlags
    766 769
               g (Off f) flags = EnumSet.delete f flags
    
    767 770
               defaultExtensionFlags = EnumSet.fromList (languageExtensions ml)
    
    768 771
     
    
    772
    +-- -----------------------------------------------------------------------------
    
    773
    +-- -M -dep-*
    
    774
    +
    
    775
    +data MkDependOutput
    
    776
    +  = MkDepend_None
    
    777
    +  | MkDepend_Default !FilePath
    
    778
    +  | MkDepend_Explicit !FilePath
    
    779
    +  | MkDepend_StdOut
    
    780
    +
    
    769 781
     -- -----------------------------------------------------------------------------
    
    770 782
     -- -jN
    
    771 783
     
    

  • 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
     
    
    ... ... @@ -160,28 +162,20 @@ doMkDependModuleGraph dflags module_graph = do
    160 162
         liftIO $ do
    
    161 163
     
    
    162 164
           -- Setup the writers
    
    163
    -      writers <- sequenceA backends
    
    164
    -
    
    165
    -      -- Do the actual work
    
    166
    -      do
    
    165
    +      withWriters backends $ \ write_dep -> do
    
    166
    +        -- Do the actual work
    
    167 167
             -- Process them one by one, dumping results and complaining about cycles
    
    168 168
             forM_
    
    169 169
               sorted
    
    170 170
               (\ mod_graph_node ->
    
    171 171
                 processDeps hsc_env (UniqSet.mkUniqSet excl_mods) mod_graph_node >>= \ case
    
    172 172
                   Nothing -> pure ()
    
    173
    -              Just dep_node ->
    
    174
    -                traverse_ (\ s -> dw_writeDependency s dep_node) writers
    
    173
    +              Just dep_node -> write_dep dep_node
    
    175 174
               )
    
    176 175
     
    
    177 176
             -- If -ddump-mod-cycles, show cycles in the module graph
    
    178 177
             liftIO $ dumpModCycles logger module_graph
    
    179 178
     
    
    180
    -      -- Tidy up
    
    181
    -      do
    
    182
    -        traverse_ dw_endWriter writers
    
    183
    -
    
    184
    -
    
    185 179
         -- Unconditional exiting is a bad idea.  If an error occurs we'll get an
    
    186 180
         --exception; if that is not caught it's fine, but at least we have a
    
    187 181
         --chance to find out exactly what went wrong.  Uncomment the following
    
    ... ... @@ -261,11 +255,102 @@ data DependencyWriter = DependencyWriter
    261 255
       { dw_writeDependency :: DepNode -> IO ()
    
    262 256
       -- ^ Serialise a 'DepNode' and write it out.
    
    263 257
       , dw_endWriter :: IO ()
    
    264
    -  -- ^ End the serialiation of dependency information and perform
    
    265
    -  -- final steps, such as cleaning up temporary files and copying intermediate
    
    266
    -  -- files to their final location.
    
    258
    +  -- ^ We finished consuming the dependency information, perform final
    
    259
    +  -- tidy up operations. This may be a no-op, but could also
    
    260
    +  -- copy temporary files, close open handlers, etc...
    
    261
    +  --
    
    262
    +  -- If 'dw_endWriter' was called, calling 'dw_onError' is unnecessary,
    
    263
    +  -- but it must be safe to call 'dw_onError' any way.
    
    264
    +  , dw_onError :: IO ()
    
    265
    +  -- ^ Something crashed! Clean up any resources opened by this 'DependencyWriter'.
    
    267 266
       }
    
    268 267
     
    
    268
    +-- | Initialise multiple backends and combine them into one output function.
    
    269
    +--
    
    270
    +-- Combines the 'DepSink' of each 'DependencyWriter' into one single consumer.
    
    271
    +withWriters :: [IO DependencyWriter] -> ((DepNode -> IO ()) -> IO a) -> IO a
    
    272
    +withWriters [] k = k (\ _ -> pure ())
    
    273
    +withWriters (dw : dws) k =
    
    274
    +  withWriter
    
    275
    +    dw
    
    276
    +    $ \s -> withWriters dws (\s' -> k (s `mappendWriter` s'))
    
    277
    +  where
    
    278
    +    mappendWriter w1 w2 = \ node -> w1 node >> w2 node
    
    279
    +
    
    280
    +-- | Initialise a single 'DependencyWriter', making sure any allocated resource
    
    281
    +-- get's tidied up again.
    
    282
    +--
    
    283
    +-- Accepts 'IO' 'DependencyWriter' since the initialisation may perform setup operations,
    
    284
    +-- such as opening file handles, or intermediate data types.
    
    285
    +withWriter :: IO DependencyWriter -> ((DepNode -> IO ()) -> IO r) -> IO r
    
    286
    +withWriter dwIO k =
    
    287
    +  bracketOnError dwIO dw_onError $ \ dw -> do
    
    288
    +    r <- k (dw_writeDependency dw)
    
    289
    +    -- Clean up open resources
    
    290
    +    dw_endWriter dw
    
    291
    +    pure r
    
    292
    +
    
    293
    +-- | Where should the dependency output end up?
    
    294
    +data DepOutput
    
    295
    +  = DepStreamHandle Handle
    
    296
    +  -- ^ The dependency information should be written to this 'Handle'.
    
    297
    +  | DepFileOutput FilePath
    
    298
    +  -- ^ The dependency information should be written to this 'FilePath'.
    
    299
    +
    
    300
    +-- | A 'DepStream' is an abstraction over how to output single elements
    
    301
    +-- of the dependency generation, e.g., a json object or one makefile rule.
    
    302
    +data DepStream = DepStream
    
    303
    +  { depStream_write :: String -> IO ()
    
    304
    +  , depStream_close :: IO ()
    
    305
    +  , depStream_onError :: IO ()
    
    306
    +  }
    
    307
    +
    
    308
    +initDepOutput :: MkDependOutput -> Maybe DepOutput
    
    309
    +initDepOutput = \ case
    
    310
    +  MkDepend_None -> Nothing
    
    311
    +  MkDepend_Default fp -> Just $ DepFileOutput fp
    
    312
    +  MkDepend_Explicit fp -> Just $ DepFileOutput fp
    
    313
    +  MkDepend_StdOut -> Just $ DepStreamHandle stdout
    
    314
    +
    
    315
    +initMakefileDepStream :: Logger -> TmpFs -> TempDir -> DepOutput -> IO DepStream
    
    316
    +initMakefileDepStream _ _ _ (DepStreamHandle h) =
    
    317
    +  pure $ depStreamHandle h
    
    318
    +initMakefileDepStream logger tmpfs tmpdir (DepFileOutput fp) = do
    
    319
    +  files <- beginMkDependHS logger tmpfs tmpdir fp
    
    320
    +  pure $
    
    321
    +    DepStream
    
    322
    +      { depStream_write = hPutStrLn (mkd_tmp_hdl files)
    
    323
    +      , depStream_onError = do
    
    324
    +          hClose $ mkd_tmp_hdl files
    
    325
    +          case mkd_make_hdl files of
    
    326
    +            Nothing -> return ()
    
    327
    +            Just hdl -> hClose hdl
    
    328
    +      , depStream_close = endMkDependHS logger files
    
    329
    +      }
    
    330
    +
    
    331
    +initJsonDepStream :: Logger -> TmpFs -> TempDir -> DepOutput -> IO DepStream
    
    332
    +initJsonDepStream _ _ _ (DepStreamHandle h) =
    
    333
    +  pure $ depStreamHandle h
    
    334
    +initJsonDepStream logger tmpfs tmpdir (DepFileOutput fp) = do
    
    335
    +  files <- initJsonDepFiles logger tmpfs tmpdir fp
    
    336
    +  pure $
    
    337
    +    DepStream
    
    338
    +      { depStream_write = hPutStrLn (json_tmp_hdl files)
    
    339
    +      , depStream_onError = hClose (json_tmp_hdl files)
    
    340
    +      , depStream_close = endJsonDepFiles logger files
    
    341
    +      }
    
    342
    +
    
    343
    +depStreamHandle :: Handle -> DepStream
    
    344
    +depStreamHandle h =
    
    345
    +    DepStream
    
    346
    +      { depStream_write =
    
    347
    +          \output -> do
    
    348
    +            hPutStrLn h output
    
    349
    +            hFlush h -- We flush to ensure the output is streamed per line.
    
    350
    +      , depStream_close = pure ()
    
    351
    +      , depStream_onError = pure ()
    
    352
    +      }
    
    353
    +
    
    269 354
     -----------------------------------------------------------------
    
    270 355
     --
    
    271 356
     --              processDeps
    
    ... ... @@ -415,17 +500,16 @@ findDependency hsc_env (L srcloc imp) = do
    415 500
     --
    
    416 501
     -----------------------------------------------------------------
    
    417 502
     
    
    418
    -initFileDepWriter :: Logger -> OsPath -> TmpFs -> DynFlags -> FilePath -> IO DependencyWriter
    
    419
    -initFileDepWriter logger root tmpfs dflags makefile = do
    
    420
    -  files <- beginMkDependHS logger tmpfs dflags makefile
    
    503
    +initFileDepWriter :: Logger -> OsPath -> TmpFs -> TempDir -> [OsPath] -> DepOutput -> IO DependencyWriter
    
    504
    +initFileDepWriter logger root tmpfs tmpdir suffixes output = do
    
    505
    +  stream <- initMakefileDepStream logger tmpfs tmpdir output
    
    421 506
       pure DependencyWriter
    
    422 507
         { dw_writeDependency = \ case
    
    423 508
             ModuleDepNode node deps -> do
    
    424
    -          writeDependencies root (mkd_tmp_hdl files) suffixes node deps
    
    425
    -    , dw_endWriter = endMkDependHS logger files
    
    509
    +          traverse_ (depStream_write stream) (dependencyRules root suffixes node deps)
    
    510
    +    , dw_endWriter = depStream_close stream
    
    511
    +    , dw_onError = depStream_onError stream
    
    426 512
         }
    
    427
    -  where
    
    428
    -    suffixes = map unsafeEncodeUtf (depSuffixes dflags)
    
    429 513
     
    
    430 514
     data MkDepFiles
    
    431 515
       = MkDep { mkd_make_file :: FilePath,          -- Name of the makefile
    
    ... ... @@ -433,11 +517,11 @@ data MkDepFiles
    433 517
                 mkd_tmp_file  :: FilePath,          -- Name of the temporary file
    
    434 518
                 mkd_tmp_hdl   :: Handle }           -- Handle of the open temporary file
    
    435 519
     
    
    436
    -beginMkDependHS :: Logger -> TmpFs -> DynFlags -> FilePath -> IO MkDepFiles
    
    437
    -beginMkDependHS logger tmpfs dflags makefile = do
    
    520
    +beginMkDependHS :: Logger -> TmpFs -> TempDir -> FilePath -> IO MkDepFiles
    
    521
    +beginMkDependHS logger tmpfs tmpdir makefile = do
    
    438 522
             -- open a new temp file in which to stuff the dependency info
    
    439 523
             -- as we go along.
    
    440
    -  tmp_file <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "dep"
    
    524
    +  tmp_file <- newTempName logger tmpfs tmpdir TFL_CurrentModule "dep"
    
    441 525
       tmp_hdl <- openFile tmp_file WriteMode
    
    442 526
     
    
    443 527
             -- open the makefile
    
    ... ... @@ -478,16 +562,15 @@ beginMkDependHS logger tmpfs dflags makefile = do
    478 562
       return (MkDep { mkd_make_file = makefile, mkd_make_hdl = mb_make_hdl,
    
    479 563
                       mkd_tmp_file  = tmp_file, mkd_tmp_hdl  = tmp_hdl})
    
    480 564
     
    
    481
    -writeDependencies ::
    
    565
    +dependencyRules ::
    
    482 566
       OsPath ->
    
    483
    -  Handle ->
    
    484 567
       [OsString] ->
    
    485 568
       -- ^ Suffixes
    
    486 569
       HomeModuleNode ->
    
    487 570
       [Dep] ->
    
    488
    -  IO ()
    
    489
    -writeDependencies root hdl suffixes node deps =
    
    490
    -  traverse_ write tasks
    
    571
    +  [String]
    
    572
    +dependencyRules root suffixes node deps =
    
    573
    +  map rule tasks
    
    491 574
       where
    
    492 575
         tasks = source_dep : boot_dep ++ concatMap import_dep deps
    
    493 576
     
    
    ... ... @@ -514,7 +597,7 @@ writeDependencies root hdl suffixes node deps =
    514 597
     
    
    515 598
           DepCpp {dep_path} -> [(obj_files, dep_path)]
    
    516 599
     
    
    517
    -    write (from, to) = writeDependency root hdl from to
    
    600
    +    rule (from, to) = dependencyRule root from to
    
    518 601
     
    
    519 602
         obj_files = suffixed hmn_obj
    
    520 603
     
    
    ... ... @@ -523,18 +606,18 @@ writeDependencies root hdl suffixes node deps =
    523 606
         HomeModuleNode {hmn_src, hmn_obj, hmn_hi, hmn_mod, hmn_includePkgDeps} = node
    
    524 607
     
    
    525 608
     -----------------------------
    
    526
    -writeDependency :: OsPath -> Handle -> [OsPath] -> OsPath -> IO ()
    
    527
    --- (writeDependency r h [t1,t2] dep) writes to handle h the dependency
    
    609
    +dependencyRule :: OsPath -> [OsPath] -> OsPath -> String
    
    610
    +-- (dependencyRule r [t1,t2] dep) renders the dependency
    
    528 611
     --      t1 t2 : dep
    
    529
    -writeDependency root hdl targets dep
    
    530
    -  = do let -- We need to avoid making deps on
    
    531
    -           --     c:/foo/...
    
    532
    -           -- on Windows as make gets confused by the :
    
    533
    -           -- Making relative deps avoids some instances of this.
    
    534
    -           dep' = OsPath.makeRelative root dep
    
    535
    -           forOutput = escapeSpaces . reslash Forwards . unsafeDecodeUtf . OsPath.normalise
    
    536
    -           output = unwords (map forOutput targets) ++ " : " ++ forOutput dep'
    
    537
    -       hPutStrLn hdl output
    
    612
    +dependencyRule root targets dep
    
    613
    +  = let -- We need to avoid making deps on
    
    614
    +        --     c:/foo/...
    
    615
    +        -- on Windows as make gets confused by the :
    
    616
    +        -- Making relative deps avoids some instances of this.
    
    617
    +        dep' = OsPath.makeRelative root dep
    
    618
    +        forOutput = escapeSpaces . reslash Forwards . unsafeDecodeUtf . OsPath.normalise
    
    619
    +    in
    
    620
    +        unwords (map forOutput targets) ++ " : " ++ forOutput dep'
    
    538 621
     
    
    539 622
     -----------------------------
    
    540 623
     insertSuffixes
    
    ... ... @@ -589,82 +672,86 @@ endMkDependHS logger
    589 672
     --
    
    590 673
     -----------------------------------------------------------------
    
    591 674
     
    
    592
    -initJsonDepWriter :: Logger -> TmpFs -> DynFlags -> FilePath -> IO DependencyWriter
    
    593
    -initJsonDepWriter logger tmpfs dflags output = do
    
    594
    -  json_var <- mkJsonOutput logger tmpfs dflags output initDepJson
    
    595
    -  pure DependencyWriter
    
    596
    -    { dw_writeDependency = \ case
    
    597
    -        ModuleDepNode node deps ->
    
    598
    -          writeHomeUnitDeps json_var node deps
    
    599
    -    , dw_endWriter = do
    
    600
    -        writeJsonOutput logger json_var
    
    601
    -    }
    
    675
    +initJsonDepWriter :: Logger -> TmpFs -> TempDir -> DepOutput -> IO DependencyWriter
    
    676
    +initJsonDepWriter logger tmpfs tmpdir output = do
    
    677
    +  stream <- initJsonDepStream logger tmpfs tmpdir output
    
    678
    +  json_var <- mkJsonOutput
    
    679
    +  pure
    
    680
    +    DependencyWriter
    
    681
    +      { dw_writeDependency = \ case
    
    682
    +          ModuleDepNode node deps -> do
    
    683
    +            extUnits <- readJson json_var
    
    684
    +            let
    
    685
    +              (extUnitsDeps, payload) = homeUnitDeps node deps
    
    686
    +              newExtUnits = Set.difference extUnitsDeps (externalDeps extUnits)
    
    687
    +            -- Write new external unit deps before the module that uses them
    
    688
    +            for_ newExtUnits $ \extUnit -> do
    
    689
    +              depStream_write stream (renderJsonl extUnit)
    
    690
    +            depStream_write stream (renderJsonl payload)
    
    691
    +            -- Cache external deps we already reported in the past
    
    692
    +            updateJson json_var $ cacheExternalDepsJson newExtUnits
    
    693
    +      , dw_endWriter = depStream_close stream
    
    694
    +      , dw_onError = depStream_onError stream
    
    695
    +      }
    
    602 696
     
    
    603 697
     --------------------------------------------------------------------------------
    
    604 698
     -- Output interface for json dumps
    
    605 699
     
    
    606
    --- | Resources for a json dump option, used in "GHC.Driver.MakeFile".
    
    607
    --- The flag @-dep-json@ add an additional output target for dependency
    
    608
    --- diagnostics.
    
    609
    ---
    
    610
    --- Contains temporary file locations to stream output to.
    
    611
    -data JsonOutput =
    
    612
    -  JsonOutput {
    
    613
    -    -- | @-dep-json@ specific state for json lines dependency information generation.
    
    614
    -    json_ref :: IORef DepJson,
    
    615
    -
    
    616
    -    -- | The output file path specified as argument to the flag.
    
    617
    -    json_path :: FilePath,
    
    618
    -    -- | Name of the temporary file
    
    619
    -    json_tmp_file  :: FilePath,
    
    620
    -    -- | Handle of the open temporary file
    
    621
    -    json_tmp_hdl   :: Handle
    
    700
    +-- | State to keep track of during `-dep-json` generation.
    
    701
    +newtype JsonState
    
    702
    +  = JsonState
    
    703
    +  { json_ref :: IORef DepJson
    
    704
    +  -- ^ This ref is updated in @processDeps@ incrementally, using a
    
    705
    +  -- flag-specific type.
    
    622 706
       }
    
    623 707
     
    
    624
    --- | Set up json generation for `ghc -M`.
    
    625
    ---
    
    626
    --- Creates a temporary file that we write the dependency information to.
    
    627
    --- The temporary file is written to the final output file path in 'writeJsonOutput'.
    
    628
    -mkJsonOutput ::
    
    629
    -  Logger ->
    
    630
    -  TmpFs ->
    
    631
    -  DynFlags ->
    
    632
    -  FilePath ->
    
    633
    -  IO (IORef DepJson) ->
    
    634
    -  IO JsonOutput
    
    635
    -mkJsonOutput logger tmpfs dflags json_path mk_ref = do
    
    636
    -  json_ref <- mk_ref
    
    637
    -  -- open a new temp file in which to stuff the dependency info
    
    708
    +data JsonDepFiles = JsonDepFiles
    
    709
    +  { json_path :: FilePath
    
    710
    +    -- ^ The output file path specified as argument to the flag.
    
    711
    +  , json_tmp_file  :: FilePath
    
    712
    +    -- ^ Name of the temporary file
    
    713
    +  , json_tmp_hdl   :: Handle
    
    714
    +    -- ^ Handle of the open temporary file
    
    715
    +  }
    
    716
    +
    
    717
    +initJsonDepFiles :: Logger -> TmpFs -> TempDir -> FilePath -> IO JsonDepFiles
    
    718
    +initJsonDepFiles logger tmpfs tmpdir path = do
    
    719
    +  -- open a new temp file in which to stuff the dependency info into
    
    638 720
       -- as we go along.
    
    639
    -  json_tmp_file <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "dep"
    
    721
    +  json_tmp_file <- newTempName logger tmpfs tmpdir TFL_CurrentModule "dep-json"
    
    640 722
       json_tmp_hdl <- openFile json_tmp_file WriteMode
    
    641
    -
    
    642
    -  pure JsonOutput {json_ref, json_path, json_tmp_file, json_tmp_hdl}
    
    643
    -
    
    644
    -updateJson :: JsonOutput -> (DepJson -> DepJson) -> IO ()
    
    645
    -updateJson JsonOutput {json_ref} f = modifyIORef' json_ref f
    
    646
    -
    
    647
    -readJson :: JsonOutput -> IO DepJson
    
    648
    -readJson JsonOutput {json_ref} = readIORef json_ref
    
    723
    +  pure $ JsonDepFiles
    
    724
    +    { json_path = path
    
    725
    +    , json_tmp_file = json_tmp_file
    
    726
    +    , json_tmp_hdl = json_tmp_hdl
    
    727
    +    }
    
    649 728
     
    
    650 729
     -- | Finalise the json generation by copying the temporary file to the final destination.
    
    651 730
     -- Avoids partial writes in the case of an error.
    
    652
    -writeJsonOutput ::
    
    653
    -  Logger ->
    
    654
    -  JsonOutput ->
    
    655
    -  IO ()
    
    656
    -writeJsonOutput logger JsonOutput {json_path, json_tmp_file, json_tmp_hdl} = do
    
    731
    +endJsonDepFiles :: Logger -> JsonDepFiles -> IO ()
    
    732
    +endJsonDepFiles logger JsonDepFiles {json_path, json_tmp_file, json_tmp_hdl} = do
    
    657 733
       hClose json_tmp_hdl
    
    658 734
       -- Copy the new jsonl in place
    
    659 735
       showPass logger "Installing new json output"
    
    660 736
       SysTools.copyFile json_tmp_file json_path
    
    661 737
     
    
    738
    +-- | Set up json generation for `ghc -M`.
    
    739
    +mkJsonOutput :: IO JsonState
    
    740
    +mkJsonOutput =
    
    741
    +  JsonState <$> newIORef (DepJson Set.empty)
    
    742
    +
    
    743
    +updateJson :: JsonState -> (DepJson -> DepJson) -> IO ()
    
    744
    +updateJson JsonState {json_ref} f = modifyIORef' json_ref f
    
    745
    +
    
    746
    +readJson :: JsonState -> IO DepJson
    
    747
    +readJson JsonState {json_ref} = readIORef json_ref
    
    748
    +
    
    662 749
     --------------------------------------------------------------------------------
    
    663 750
     -- Output helpers
    
    664 751
     
    
    665
    -writeJsonl :: ToJson a => JsonOutput -> a -> IO ()
    
    666
    -writeJsonl  JsonOutput {json_tmp_hdl} output = do
    
    667
    -  hPutStrLn json_tmp_hdl (showSDocUnsafe $ renderJSON $ json output)
    
    752
    +renderJsonl :: ToJson a => a -> String
    
    753
    +renderJsonl output =
    
    754
    +  showSDocUnsafe $ renderJSON $ json output
    
    668 755
     
    
    669 756
     --------------------------------------------------------------------------------
    
    670 757
     -- Payload for -dep-json
    
    ... ... @@ -846,9 +933,6 @@ instance ToJson ExtUnitDep where
    846 933
         where
    
    847 934
           showPackageId (DPackageId (PackageId pid)) = unpackFS pid
    
    848 935
     
    
    849
    -initDepJson :: IO (IORef DepJson)
    
    850
    -initDepJson = newIORef $ DepJson Set.empty
    
    851
    -
    
    852 936
     cacheExternalDepsJson :: Set.Set ExtUnitDep -> DepJson -> DepJson
    
    853 937
     cacheExternalDepsJson extUnits (DepJson e0) =
    
    854 938
       DepJson
    
    ... ... @@ -856,19 +940,10 @@ cacheExternalDepsJson extUnits (DepJson e0) =
    856 940
             Set.union e0 extUnits
    
    857 941
         }
    
    858 942
     
    
    859
    -writeHomeUnitDeps :: JsonOutput -> HomeModuleNode -> [Dep] -> IO ()
    
    860
    -writeHomeUnitDeps deps_json HomeModuleNode {..} deps = do
    
    861
    -  extUnits <- readJson deps_json
    
    862
    -  let newExtUnits = Set.difference extUnitsDeps (externalDeps extUnits)
    
    863
    -  -- Write new external unit deps before the module that uses them
    
    864
    -  for_ newExtUnits $ \ extUnit -> do
    
    865
    -    writeJsonl deps_json extUnit
    
    866
    -  writeJsonl deps_json payload
    
    867
    -  -- Cache external deps we already reported in the past
    
    868
    -  updateJson deps_json $ cacheExternalDepsJson newExtUnits
    
    943
    +homeUnitDeps :: Foldable t => HomeModuleNode -> t Dep -> (Set.Set ExtUnitDep, HomeUnitDep)
    
    944
    +homeUnitDeps HomeModuleNode {..} deps =
    
    945
    +  foldl' go (Set.empty, initial_node_data) deps
    
    869 946
       where
    
    870
    -    (extUnitsDeps, payload) = foldl' go (Set.empty, initial_node_data) deps
    
    871
    -
    
    872 947
         initial_node_data =
    
    873 948
           HomeUnitDep
    
    874 949
             { unitId = hmn_unitId
    

  • compiler/GHC/Driver/Session.hs
    ... ... @@ -774,16 +774,44 @@ addOptCmmP f = alterToolSettings $ \s -> s
    774 774
               }
    
    775 775
     
    
    776 776
     setDepMakefile :: FilePath -> DynFlags -> DynFlags
    
    777
    -setDepMakefile f d = d { depMakefile = Just f }
    
    777
    +setDepMakefile f d = d { depMakefile = MkDepend_Explicit f
    
    778
    +                       -- depJson has no default value, we add this for symmetry with `setDepJson`
    
    779
    +                       -- and if anything changes in the future, then the code is already here :)
    
    780
    +                       , depJson = unsetMkDependOutputIfDefault (depJson d)
    
    781
    +                       }
    
    782
    +
    
    783
    +setDepMakefileStdout :: DynFlags -> DynFlags
    
    784
    +setDepMakefileStdout d = d { depMakefile = MkDepend_StdOut
    
    785
    +                           -- depJson has no default value, we add this for symmetry with `setDepJson`
    
    786
    +                           -- and if anything changes in the future, then the code is already here :)
    
    787
    +                           , depJson = unsetMkDependOutputIfDefault (depJson d)
    
    788
    +                           }
    
    778 789
     
    
    779 790
     unsetDepMakefile :: DynFlags -> DynFlags
    
    780
    -unsetDepMakefile d = d { depMakefile = Nothing }
    
    791
    +unsetDepMakefile d = d { depMakefile = MkDepend_None }
    
    781 792
     
    
    782 793
     setDepJson :: FilePath -> DynFlags -> DynFlags
    
    783
    -setDepJson f d = d { depJson = Just f }
    
    794
    +setDepJson f d = d { depJson = MkDepend_Explicit f
    
    795
    +                   -- We generate a Makefile by default, but if a user requests json
    
    796
    +                   -- output, then they most likely don't need a Makefile.
    
    797
    +                   -- Thus, we only generate it if the user requests it.
    
    798
    +                   , depMakefile = unsetMkDependOutputIfDefault (depMakefile d)
    
    799
    +                   }
    
    800
    +
    
    801
    +setDepJsonStdout :: DynFlags -> DynFlags
    
    802
    +setDepJsonStdout d = d { depJson = MkDepend_StdOut
    
    803
    +                       -- We generate a Makefile by default, but if a user requests json
    
    804
    +                       -- output, then they most likely don't need a Makefile.
    
    805
    +                       -- Thus, we only generate it if the user requests it.
    
    806
    +                       , depMakefile = unsetMkDependOutputIfDefault (depMakefile d)
    
    807
    +                       }
    
    784 808
     
    
    785 809
     unsetDepJson :: DynFlags -> DynFlags
    
    786
    -unsetDepJson d = d { depJson = Nothing }
    
    810
    +unsetDepJson d = d { depJson = MkDepend_None }
    
    811
    +
    
    812
    +unsetMkDependOutputIfDefault :: MkDependOutput -> MkDependOutput
    
    813
    +unsetMkDependOutputIfDefault (MkDepend_Default _) = MkDepend_None
    
    814
    +unsetMkDependOutputIfDefault mkDepend_output      = mkDepend_output
    
    787 815
     
    
    788 816
     setDepIncludeCppDeps :: Bool -> DynFlags -> DynFlags
    
    789 817
     setDepIncludeCppDeps b d = d { depIncludeCppDeps = b }
    
    ... ... @@ -1248,8 +1276,10 @@ dynamic_flags_deps = [
    1248 1276
     
    
    1249 1277
             -------- ghc -M -----------------------------------------------------
    
    1250 1278
       , make_ord_flag defGhcFlag "dep-suffix"              (hasArg addDepSuffix)
    
    1279
    +  , make_ord_flag defGhcFlag "dep-makefile-stdout"     (noArg setDepMakefileStdout)
    
    1251 1280
       , make_ord_flag defGhcFlag "dep-makefile"            (hasArg setDepMakefile)
    
    1252 1281
       , make_ord_flag defGhcFlag "no-dep-makefile"         (noArg unsetDepMakefile)
    
    1282
    +  , make_ord_flag defGhcFlag "dep-json-stdout"         (noArg setDepJsonStdout)
    
    1253 1283
       , make_ord_flag defGhcFlag "dep-json"                (hasArg setDepJson)
    
    1254 1284
       , make_ord_flag defGhcFlag "no-dep-json"             (noArg unsetDepJson)
    
    1255 1285
       , make_ord_flag defGhcFlag "include-cpp-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
    ... ... @@ -412,8 +412,8 @@ class TestOptions:
    412 412
            self.ignore_extension = False
    
    413 413
     
    
    414 414
            # make_depend tests: which outputs to write and check
    
    415
    -       self.dep_makefile = False
    
    416
    -       self.dep_json = False
    
    415
    +       self.dep_makefile: DepMode = DepMode.NONE
    
    416
    +       self.dep_json: DepMode = DepMode.NONE
    
    417 417
            self.ignore_dep_outputs = False
    
    418 418
     
    
    419 419
            # Backpack test
    

  • testsuite/driver/testlib.py
    ... ... @@ -439,14 +439,26 @@ def dep_makefile( name, opts ):
    439 439
         For make_depend tests: write the -dep-makefile output and
    
    440 440
         compare it against <name>.dep-makefile.
    
    441 441
         """
    
    442
    -    opts.dep_makefile = True
    
    442
    +    opts.dep_makefile = DepMode.FILE
    
    443 443
     
    
    444 444
     def dep_json( name, opts ):
    
    445 445
         """
    
    446 446
         For make_depend tests: write the -dep-json output and
    
    447 447
         compare it against <name>.dep-json.
    
    448 448
         """
    
    449
    -    opts.dep_json = True
    
    449
    +    opts.dep_json = DepMode.FILE
    
    450
    +
    
    451
    +def dep_makefile_stdout( name, opts ):
    
    452
    +    """
    
    453
    +    For make_depend tests: add -dep-makefile-stdout flag.
    
    454
    +    """
    
    455
    +    opts.dep_makefile = DepMode.STDOUT
    
    456
    +
    
    457
    +def dep_json_stdout( name, opts ):
    
    458
    +    """
    
    459
    +    For make_depend tests: add -dep-json-stdout flag.
    
    460
    +    """
    
    461
    +    opts.dep_json = DepMode.STDOUT
    
    450 462
     
    
    451 463
     def ignore_dep_outputs( name, opts ):
    
    452 464
         """
    
    ... ... @@ -2118,6 +2130,10 @@ async def do_make_depend(name: TestName,
    2118 2130
             against <name>.dep-makefile. Otherwise, -no-dep-makefile is passed.
    
    2119 2131
           * 'dep_json': write the -dep-json output and compare it
    
    2120 2132
             against <name>.dep-json.
    
    2133
    +      * 'dep_json_stdout': write the -dep-json-stdout and compare it with
    
    2134
    +        <name>.stderr
    
    2135
    +      * 'dep_makefile_stdout': write the -dep-makefile-stdout and compare it with
    
    2136
    +        <name>.stderr
    
    2121 2137
         """
    
    2122 2138
         opts = getTestOpts()
    
    2123 2139
     
    
    ... ... @@ -2126,14 +2142,29 @@ async def do_make_depend(name: TestName,
    2126 2142
     
    
    2127 2143
         outputs = []
    
    2128 2144
         output_flags = []
    
    2129
    -    if opts.dep_makefile:
    
    2145
    +    if opts.dep_makefile == DepMode.FILE:
    
    2130 2146
             outputs.append(('dep-makefile', normalise_dep_makefile))
    
    2131 2147
             output_flags.append('-dep-makefile %s' % actual_file('dep-makefile'))
    
    2132
    -    else:
    
    2133
    -        output_flags.append('-no-dep-makefile')
    
    2134
    -    if opts.dep_json:
    
    2148
    +    elif opts.dep_makefile == DepMode.STDOUT:
    
    2149
    +        outputs.append(('stdout', normalise_dep_makefile))
    
    2150
    +        output_flags.append('-dep-makefile-stdout')
    
    2151
    +
    
    2152
    +    if opts.dep_json == DepMode.FILE:
    
    2135 2153
             outputs.append(('dep-json', normalise_dep_json))
    
    2136 2154
             output_flags.append('-dep-json %s' % actual_file('dep-json'))
    
    2155
    +    elif opts.dep_json == DepMode.STDOUT:
    
    2156
    +        outputs.append(('stdout', normalise_dep_json))
    
    2157
    +        output_flags.append('-dep-json-stdout')
    
    2158
    +
    
    2159
    +    # Somewhat non-sensical here, but `do_compile` outputs stdout and stderr into the same.
    
    2160
    +    # Then, it only applies the `normalise_errmsg_fun` to the output, and compares it against
    
    2161
    +    # <name>.stderr as the golden file.
    
    2162
    +    #
    
    2163
    +    # This is not really what we want in this situation, but it seems this requires more refactoring
    
    2164
    +    # of the `do_compile` function than what fendor is ready to commit to.
    
    2165
    +    # Thus, as a workaround, we simply add the normalisers for the stderr...
    
    2166
    +    stdout_normalisers = [ n for (k, n) in outputs if k == 'stdout' ]
    
    2167
    +    opts.extra_errmsg_normaliser = join_normalisers(opts.extra_errmsg_normaliser, normalise_slashes_, *stdout_normalisers)
    
    2137 2168
     
    
    2138 2169
         result = await do_compile( name, way, False, None, [], units,
    
    2139 2170
                                    ' '.join(output_flags + [extra_hc_opts]),
    
    ... ... @@ -2143,9 +2174,9 @@ async def do_make_depend(name: TestName,
    2143 2174
     
    
    2144 2175
         for (kind, normaliser) in outputs:
    
    2145 2176
             output_match = await compare_outputs(way, kind,
    
    2146
    -                           join_normalisers(opts.extra_normaliser,
    
    2147
    -                                            normalise_slashes_, normaliser),
    
    2148
    -                           find_expected_file(name, kind, way), actual_file(kind))
    
    2177
    +                           join_normalisers(opts.extra_normaliser, normalise_slashes_, normaliser),
    
    2178
    +                           find_expected_file(name, kind, way),
    
    2179
    +                           actual_file(kind))
    
    2149 2180
             if not output_match:
    
    2150 2181
                 return failBecause(kind + ' mismatch', diff=output_match.diff)
    
    2151 2182
     
    

  • 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"}