| ... |
... |
@@ -55,6 +55,7 @@ import Data.IORef |
|
55
|
55
|
import qualified Data.Set as Set
|
|
56
|
56
|
import GHC.Iface.Errors.Types
|
|
57
|
57
|
import Data.Either
|
|
|
58
|
+import GHC.Data.Bag (listToBag)
|
|
58
|
59
|
|
|
59
|
60
|
-----------------------------------------------------------------
|
|
60
|
61
|
--
|
| ... |
... |
@@ -237,19 +238,6 @@ processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC (ModuleNode _ (ModuleN |
|
237
|
238
|
obj_file = msObjFilePath node
|
|
238
|
239
|
obj_files = insertSuffixes obj_file extra_suffixes
|
|
239
|
240
|
|
|
240
|
|
- do_imp loc is_boot pkg_qual imp_mod
|
|
241
|
|
- = do { mb_hi <- findDependency hsc_env loc pkg_qual imp_mod
|
|
242
|
|
- is_boot include_pkg_deps
|
|
243
|
|
- ; case mb_hi of {
|
|
244
|
|
- Nothing -> return () ;
|
|
245
|
|
- Just hi_file -> do
|
|
246
|
|
- { let hi_files = insertSuffixes hi_file extra_suffixes
|
|
247
|
|
- write_dep (obj,hi) = writeDependency root hdl [obj] hi
|
|
248
|
|
-
|
|
249
|
|
- -- Add one dependency for each suffix;
|
|
250
|
|
- -- e.g. A.o : B.hi
|
|
251
|
|
- -- A.x_o : B.x_hi
|
|
252
|
|
- ; mapM_ write_dep (obj_files `zip` hi_files) }}}
|
|
253
|
241
|
|
|
254
|
242
|
|
|
255
|
243
|
-- Emit std dependency of the object(s) on the source file
|
| ... |
... |
@@ -280,15 +268,33 @@ processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC (ModuleNode _ (ModuleN |
|
280
|
268
|
|
|
281
|
269
|
-- Emit a dependency for each import
|
|
282
|
270
|
|
|
283
|
|
- ; let do_imps is_boot idecls = sequence_
|
|
284
|
|
- [ do_imp loc is_boot mb_pkg mod
|
|
|
271
|
+ ; let find_dep loc is_boot pkg_qual imp_mod = findDependency hsc_env loc pkg_qual imp_mod is_boot include_pkg_deps
|
|
|
272
|
+
|
|
|
273
|
+ find_deps is_boot idecls = sequence
|
|
|
274
|
+ [ find_dep loc is_boot mb_pkg mod
|
|
285
|
275
|
| (_lvl, mb_pkg, L loc mod) <- idecls,
|
|
286
|
276
|
mod `notElem` excl_mods ]
|
|
287
|
277
|
|
|
288
|
|
- ; do_imps IsBoot (map ((,,) NormalLevel NoPkgQual) (ms_srcimps node))
|
|
289
|
|
- ; do_imps NotBoot (ms_imps node)
|
|
290
|
|
- }
|
|
|
278
|
+ do_imp hi_file = do
|
|
|
279
|
+ let hi_files = insertSuffixes hi_file extra_suffixes
|
|
|
280
|
+ write_dep (obj,hi) = writeDependency root hdl [obj] hi
|
|
|
281
|
+
|
|
|
282
|
+ -- Add one dependency for each suffix;
|
|
|
283
|
+ -- e.g. A.o : B.hi
|
|
|
284
|
+ -- A.x_o : B.x_hi
|
|
|
285
|
+ mapM_ write_dep (obj_files `zip` hi_files)
|
|
291
|
286
|
|
|
|
287
|
+ ; (missing_boot_dep_errs, boot_deps) <- partitionEithers <$> find_deps IsBoot (map ((,,) NormalLevel NoPkgQual) (ms_srcimps node))
|
|
|
288
|
+ ; (missing_not_boot_dep_errs, not_boot_deps) <- partitionEithers <$> find_deps NotBoot (ms_imps node)
|
|
|
289
|
+
|
|
|
290
|
+ ; let all_missing_errors = missing_boot_dep_errs ++ missing_not_boot_dep_errs
|
|
|
291
|
+
|
|
|
292
|
+ ; if null all_missing_errors
|
|
|
293
|
+ then mapM_ (mapM_ do_imp) (boot_deps ++ not_boot_deps)
|
|
|
294
|
+ else do
|
|
|
295
|
+ let sec = initSourceErrorContext (hsc_dflags hsc_env)
|
|
|
296
|
+ throwErrors sec (mkMessages (listToBag all_missing_errors))
|
|
|
297
|
+ }
|
|
292
|
298
|
|
|
293
|
299
|
findDependency :: HscEnv
|
|
294
|
300
|
-> SrcSpan
|
| ... |
... |
@@ -296,7 +302,7 @@ findDependency :: HscEnv |
|
296
|
302
|
-> ModuleName -- Imported module
|
|
297
|
303
|
-> IsBootInterface -- Source import
|
|
298
|
304
|
-> Bool -- Record dependency on package modules
|
|
299
|
|
- -> IO (Maybe FilePath) -- Interface file
|
|
|
305
|
+ -> IO (Either (MsgEnvelope GhcMessage) (Maybe FilePath)) -- Interface file
|
|
300
|
306
|
findDependency hsc_env srcloc pkg imp is_boot include_pkg_deps = do
|
|
301
|
307
|
-- Find the module; this will be fast because
|
|
302
|
308
|
-- we've done it once during downsweep
|
| ... |
... |
@@ -305,16 +311,15 @@ findDependency hsc_env srcloc pkg imp is_boot include_pkg_deps = do |
|
305
|
311
|
Found loc _
|
|
306
|
312
|
-- Home package: just depend on the .hi or hi-boot file
|
|
307
|
313
|
| isJust (ml_hs_file loc) || include_pkg_deps
|
|
308
|
|
- -> return (Just (ml_hi_file loc))
|
|
|
314
|
+ -> return (Right (Just (ml_hi_file loc)))
|
|
309
|
315
|
|
|
310
|
316
|
-- Not in this package: we don't need a dependency
|
|
311
|
317
|
| otherwise
|
|
312
|
|
- -> return Nothing
|
|
|
318
|
+ -> return (Right Nothing)
|
|
313
|
319
|
|
|
314
|
320
|
fail ->
|
|
315
|
|
- let sec = initSourceErrorContext (hsc_dflags hsc_env)
|
|
316
|
|
- in
|
|
317
|
|
- throwOneError sec $
|
|
|
321
|
+ return $
|
|
|
322
|
+ Left $
|
|
318
|
323
|
mkPlainErrorMsgEnvelope srcloc $
|
|
319
|
324
|
GhcDriverMessage $ DriverInterfaceError $
|
|
320
|
325
|
(Can'tFindInterface (cannotFindModule hsc_env imp fail) (LookingForModule imp is_boot))
|