Skip to content

Commit ed8f16e

Browse files
committed
Use new hie-bios
1 parent c3d56ec commit ed8f16e

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

Diff for: cabal.project

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ packages:
4242
-- See https://github.com/haskell/haskell-language-server/blob/master/.gitlab-ci.yml
4343
optional-packages: vendored/*/*.cabal
4444

45+
source-repository-package
46+
type: git
47+
location: https://github.com/wz1000/hie-bios
48+
tag: 9ddbddc902ea1749dce36c8994922b2d1a18210d
49+
4550
tests: True
4651

4752
-- mfsolve has duplicate instances in its test suite

Diff for: ghcide/session-loader/Development/IDE/Session.hs

+14-14
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ data SessionLoadingOptions = SessionLoadingOptions
230230
-- | Load the cradle with an optional 'hie.yaml' location.
231231
-- If a 'hie.yaml' is given, use it to load the cradle.
232232
-- 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)
234234
-- | Given the project name and a set of command line flags,
235235
-- return the path for storing generated GHC artifacts,
236236
-- or 'Nothing' to respect the cradle setting
@@ -267,23 +267,24 @@ instance Default SessionLoadingOptions where
267267
-- using the provided root directory for discovering the project.
268268
-- The implicit config uses different heuristics to determine the type
269269
-- of the project that may or may not be accurate.
270-
loadWithImplicitCradle :: Maybe FilePath
270+
loadWithImplicitCradle :: Recorder (WithPriority Log) -> Maybe FilePath
271271
-- ^ Optional 'hie.yaml' location. Will be used if given.
272272
-> FilePath
273273
-- ^ Root directory of the project. Required as a fallback
274274
-- if no 'hie.yaml' location is given.
275275
-> IO (HieBios.Cradle Void)
276-
loadWithImplicitCradle mHieYaml rootDir = do
276+
loadWithImplicitCradle recorder mHieYaml rootDir = do
277+
let logger = toCologActionWithPrio (cmapWithPrio LogHieBios recorder)
277278
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
280281

281282
getInitialGhcLibDirDefault :: Recorder (WithPriority Log) -> FilePath -> IO (Maybe LibDir)
282283
getInitialGhcLibDirDefault recorder rootDir = do
283284
let log = logWith recorder
284285
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
287288
case libDirRes of
288289
CradleSuccess libdir -> pure $ Just $ LibDir libdir
289290
CradleFail err -> do
@@ -614,7 +615,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
614615
when (isNothing hieYaml) $
615616
log Warning $ LogCradleNotFound lfp
616617

617-
cradle <- loadCradle hieYaml dir
618+
cradle <- loadCradle recorder hieYaml dir
618619
lfp <- flip makeRelative cfp <$> getCurrentDirectory
619620

620621
when optTesting $ mRunLspT lspEnv $
@@ -708,12 +709,11 @@ cradleToOptsAndLibDir recorder cradle file old_files = do
708709
-- noneCradleFoundMessage f = T.pack $ "none cradle found for " <> f <> ", ignoring the file"
709710
-- Start off by getting the session options
710711
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
713713
case cradleRes of
714714
CradleSuccess r -> do
715715
-- Now get the GHC lib dir
716-
libDirRes <- getRuntimeGhcLibDir logger cradle
716+
libDirRes <- getRuntimeGhcLibDir cradle
717717
case libDirRes of
718718
-- This is the successful path
719719
CradleSuccess libDir -> pure (Right (r, libDir))
@@ -814,7 +814,7 @@ newComponentCache recorder exts cradlePath cfp hsc_env old_cis new_cis = do
814814

815815
case closure_errs of
816816
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
818818
res = (rendered,Nothing)
819819
dep_info = foldMap componentDependencyInfo (filter isBad $ Map.elems cis)
820820
bad_units = OS.fromList $ concat $ do
@@ -1104,15 +1104,15 @@ setOptions (ComponentOptions theOpts compRoot _) dflags = do
11041104
(dflags', targets') <- addCmdOpts theOpts dflags
11051105
let dflags'' =
11061106
#if MIN_VERSION_ghc(9,3,0)
1107-
case unitIdString (homeUnitId_ df') of
1107+
case unitIdString (homeUnitId_ dflags') of
11081108
-- cabal uses main for the unit id of all executable packages
11091109
-- This makes multi-component sessions confused about what
11101110
-- options to use for that component.
11111111
-- Solution: hash the options and use that as part of the unit id
11121112
-- This works because there won't be any dependencies on the
11131113
-- executable unit.
11141114
"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)
11161116
hashed_uid = Compat.toUnitId (Compat.stringToUnit ("main-"++hash))
11171117
in setHomeUnitId_ hashed_uid dflags'
11181118
_ -> dflags'

0 commit comments

Comments
 (0)