@@ -230,7 +230,7 @@ data SessionLoadingOptions = SessionLoadingOptions
230
230
-- | Load the cradle with an optional 'hie.yaml' location.
231
231
-- If a 'hie.yaml' is given, use it to load the cradle.
232
232
-- Otherwise, use the provided project root directory to determine the cradle type.
233
- , loadCradle :: Maybe FilePath -> FilePath -> IO (HieBios. Cradle Void )
233
+ , loadCradle :: Recorder ( WithPriority Log ) -> Maybe FilePath -> FilePath -> IO (HieBios. Cradle Void )
234
234
-- | Given the project name and a set of command line flags,
235
235
-- return the path for storing generated GHC artifacts,
236
236
-- or 'Nothing' to respect the cradle setting
@@ -267,23 +267,24 @@ instance Default SessionLoadingOptions where
267
267
-- using the provided root directory for discovering the project.
268
268
-- The implicit config uses different heuristics to determine the type
269
269
-- of the project that may or may not be accurate.
270
- loadWithImplicitCradle :: Maybe FilePath
270
+ loadWithImplicitCradle :: Recorder ( WithPriority Log ) -> Maybe FilePath
271
271
-- ^ Optional 'hie.yaml' location. Will be used if given.
272
272
-> FilePath
273
273
-- ^ Root directory of the project. Required as a fallback
274
274
-- if no 'hie.yaml' location is given.
275
275
-> IO (HieBios. Cradle Void )
276
- loadWithImplicitCradle mHieYaml rootDir = do
276
+ loadWithImplicitCradle recorder mHieYaml rootDir = do
277
+ let logger = toCologActionWithPrio (cmapWithPrio LogHieBios recorder)
277
278
case mHieYaml of
278
- Just yaml -> HieBios. loadCradle yaml
279
- Nothing -> HieBios. loadImplicitCradle $ addTrailingPathSeparator rootDir
279
+ Just yaml -> HieBios. loadCradle logger yaml
280
+ Nothing -> HieBios. loadImplicitCradle logger $ addTrailingPathSeparator rootDir
280
281
281
282
getInitialGhcLibDirDefault :: Recorder (WithPriority Log ) -> FilePath -> IO (Maybe LibDir )
282
283
getInitialGhcLibDirDefault recorder rootDir = do
283
284
let log = logWith recorder
284
285
hieYaml <- findCradle def rootDir
285
- cradle <- loadCradle def hieYaml rootDir
286
- libDirRes <- getRuntimeGhcLibDir (toCologActionWithPrio (cmapWithPrio LogHieBios recorder)) cradle
286
+ cradle <- loadCradle def recorder hieYaml rootDir
287
+ libDirRes <- getRuntimeGhcLibDir cradle
287
288
case libDirRes of
288
289
CradleSuccess libdir -> pure $ Just $ LibDir libdir
289
290
CradleFail err -> do
@@ -614,7 +615,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
614
615
when (isNothing hieYaml) $
615
616
log Warning $ LogCradleNotFound lfp
616
617
617
- cradle <- loadCradle hieYaml dir
618
+ cradle <- loadCradle recorder hieYaml dir
618
619
lfp <- flip makeRelative cfp <$> getCurrentDirectory
619
620
620
621
when optTesting $ mRunLspT lspEnv $
@@ -708,12 +709,11 @@ cradleToOptsAndLibDir recorder cradle file old_files = do
708
709
-- noneCradleFoundMessage f = T.pack $ "none cradle found for " <> f <> ", ignoring the file"
709
710
-- Start off by getting the session options
710
711
logWith recorder Debug $ LogCradle cradle
711
- let logger = toCologActionWithPrio $ cmapWithPrio LogHieBios recorder
712
- cradleRes <- HieBios. getCompilerOptions logger (file: old_files) cradle
712
+ cradleRes <- HieBios. getCompilerOptions file old_files cradle
713
713
case cradleRes of
714
714
CradleSuccess r -> do
715
715
-- Now get the GHC lib dir
716
- libDirRes <- getRuntimeGhcLibDir logger cradle
716
+ libDirRes <- getRuntimeGhcLibDir cradle
717
717
case libDirRes of
718
718
-- This is the successful path
719
719
CradleSuccess libDir -> pure (Right (r, libDir))
@@ -814,7 +814,7 @@ newComponentCache recorder exts cradlePath cfp hsc_env old_cis new_cis = do
814
814
815
815
case closure_errs of
816
816
errs@ (_: _) -> do
817
- let rendered = map (ideErrorWithSource (Just " cradle" ) (Just DsError ) cfp . T. pack . Compat. printWithoutUniques) errs
817
+ let rendered = map (ideErrorWithSource (Just " cradle" ) (Just DiagnosticSeverity_Error ) cfp . T. pack . Compat. printWithoutUniques) errs
818
818
res = (rendered,Nothing )
819
819
dep_info = foldMap componentDependencyInfo (filter isBad $ Map. elems cis)
820
820
bad_units = OS. fromList $ concat $ do
@@ -1104,15 +1104,15 @@ setOptions (ComponentOptions theOpts compRoot _) dflags = do
1104
1104
(dflags', targets') <- addCmdOpts theOpts dflags
1105
1105
let dflags'' =
1106
1106
#if MIN_VERSION_ghc(9,3,0)
1107
- case unitIdString (homeUnitId_ df ') of
1107
+ case unitIdString (homeUnitId_ dflags ') of
1108
1108
-- cabal uses main for the unit id of all executable packages
1109
1109
-- This makes multi-component sessions confused about what
1110
1110
-- options to use for that component.
1111
1111
-- Solution: hash the options and use that as part of the unit id
1112
1112
-- This works because there won't be any dependencies on the
1113
1113
-- executable unit.
1114
1114
" main" ->
1115
- let hash = B. unpack $ B16. encode $ H. finalize $ H. updates H. init (map B. pack $ componentOptions opts )
1115
+ let hash = B. unpack $ B16. encode $ H. finalize $ H. updates H. init (map B. pack $ theOpts )
1116
1116
hashed_uid = Compat. toUnitId (Compat. stringToUnit (" main-" ++ hash))
1117
1117
in setHomeUnitId_ hashed_uid dflags'
1118
1118
_ -> dflags'
0 commit comments