Skip to content

Commit b969df1

Browse files
committed
lose the ghc-lib flag
1 parent 11f6bae commit b969df1

File tree

5 files changed

+17
-78
lines changed

5 files changed

+17
-78
lines changed

ghcide/ghcide.cabal

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ source-repository head
2727
type: git
2828
location: https://github.com/haskell/ghcide.git
2929

30-
flag ghc-lib
31-
description: build against ghc-lib instead of the ghc package
32-
default: False
33-
manual: True
34-
3530
library
3631
default-language: Haskell2010
3732
build-depends:
@@ -88,19 +83,10 @@ library
8883
vector,
8984
bytestring-encoding,
9085
opentelemetry >=0.6.1,
91-
heapsize ==0.3.*
92-
if flag(ghc-lib)
93-
build-depends:
94-
ghc-lib >= 8.8,
95-
ghc-lib-parser >= 8.8
96-
cpp-options: -DGHC_LIB
97-
else
98-
build-depends:
86+
heapsize ==0.3.*,
9987
ghc-boot-th,
10088
ghc-boot,
10189
ghc >= 8.6,
102-
-- These dependencies are used by Development.IDE.Session and are
103-
-- Haskell specific. So don't use them when building with -fghc-lib!
10490
ghc-check >=0.5.0.1,
10591
ghc-paths,
10692
cryptohash-sha1 >=0.11.100 && <0.12,
@@ -134,6 +120,7 @@ library
134120

135121
hs-source-dirs:
136122
src
123+
session-loader
137124
include-dirs:
138125
include
139126
exposed-modules:
@@ -162,6 +149,7 @@ library
162149
Development.IDE.LSP.Outline
163150
Development.IDE.LSP.Protocol
164151
Development.IDE.LSP.Server
152+
Development.IDE.Session
165153
Development.IDE.Spans.Common
166154
Development.IDE.Spans.Documentation
167155
Development.IDE.Spans.AtPoint
@@ -184,19 +172,6 @@ library
184172
Development.IDE.Plugin.Test
185173
Development.IDE.Plugin.TypeLenses
186174

187-
-- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses
188-
-- the real GHC library and the types are incompatible. Furthermore, when
189-
-- building with ghc-lib we need to make this Haskell agnostic, so no
190-
-- hie-bios!
191-
-- We also put these modules into a separate hs-source-dirs so we can avoid
192-
-- compiling them at all if ghc-lib is not set
193-
if !flag(ghc-lib)
194-
hs-source-dirs:
195-
session-loader
196-
exposed-modules:
197-
Development.IDE.Session
198-
other-modules:
199-
Development.IDE.Session.VersionCheck
200175
other-modules:
201176
Development.IDE.Core.FileExists
202177
Development.IDE.GHC.CPP
@@ -206,6 +181,7 @@ library
206181
Development.IDE.Plugin.CodeAction.PositionIndexed
207182
Development.IDE.Plugin.Completions.Logic
208183
Development.IDE.Plugin.HLS.Formatter
184+
Development.IDE.Session.VersionCheck
209185
Development.IDE.Types.Action
210186
ghc-options: -Wall -Wno-name-shadowing -Wincomplete-uni-patterns
211187

@@ -256,8 +232,6 @@ benchmark benchHist
256232
yaml
257233

258234
executable ghcide
259-
if flag(ghc-lib)
260-
buildable: False
261235
default-language: Haskell2010
262236
include-dirs:
263237
include
@@ -317,8 +291,6 @@ executable ghcide
317291
ViewPatterns
318292

319293
test-suite ghcide-tests
320-
if flag(ghc-lib)
321-
buildable: False
322294
type: exitcode-stdio-1.0
323295
default-language: Haskell2010
324296
build-tool-depends:

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -636,17 +636,7 @@ getDocMapRule =
636636
(hscEnv -> hsc, _) <- useWithStale_ GhcSessionDeps file
637637
(HAR{refMap=rf}, _) <- useWithStale_ GetHieAst file
638638

639-
-- When possible, rely on the haddocks embedded in our interface files
640-
-- This creates problems on ghc-lib, see comment on 'getDocumentationTryGhc'
641-
#if !defined(GHC_LIB)
642-
let parsedDeps = []
643-
#else
644-
deps <- fromMaybe (TransitiveDependencies [] [] []) <$> use GetDependencies file
645-
let tdeps = transitiveModuleDeps deps
646-
parsedDeps <- uses_ GetParsedModule tdeps
647-
#endif
648-
649-
dkMap <- liftIO $ mkDocMap hsc parsedDeps rf tc
639+
dkMap <- liftIO $ mkDocMap hsc rf tc
650640
return ([],Just dkMap)
651641

652642
-- | Persistent rule to ensure that hover doesn't block on startup
@@ -924,7 +914,6 @@ generateCoreRule =
924914

925915
getModIfaceRule :: Rules ()
926916
getModIfaceRule = defineEarlyCutoff $ \GetModIface f -> do
927-
#if !defined(GHC_LIB)
928917
fileOfInterest <- use_ IsFileOfInterest f
929918
res@(_,(_,mhmi)) <- case fileOfInterest of
930919
IsFOI status -> do
@@ -951,13 +940,6 @@ getModIfaceRule = defineEarlyCutoff $ \GetModIface f -> do
951940
compiledLinkables <- getCompiledLinkables <$> getIdeGlobalAction
952941
liftIO $ modifyVar_ compiledLinkables $ \old -> pure $ extendModuleEnv old mod time
953942
pure res
954-
#else
955-
tm <- use_ TypeCheck f
956-
hsc <- hscEnv <$> use_ GhcSessionDeps f
957-
(diags, !hiFile) <- liftIO $ compileToObjCodeIfNeeded hsc Nothing (error "can't compile with ghc-lib") tm
958-
let fp = hiFileFingerPrint <$> hiFile
959-
return (fp, (diags, hiFile))
960-
#endif
961943

962944
getModIfaceWithoutLinkableRule :: Rules ()
963945
getModIfaceWithoutLinkableRule = defineEarlyCutoff $ \GetModIfaceWithoutLinkable f -> do

ghcide/src/Development/IDE/Plugin/Completions.hs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ import Ide.PluginUtils (getClientConfig)
3636
import Ide.Types
3737
import TcRnDriver (tcRnImportDecls)
3838
import Control.Concurrent.Async (concurrently)
39-
#if defined(GHC_LIB)
40-
import Development.IDE.Import.DependencyInformation
41-
#endif
4239

4340
descriptor :: PluginId -> PluginDescriptor IdeState
4441
descriptor plId = (defaultPluginDescriptor plId)
@@ -64,15 +61,6 @@ produceCompletions = do
6461
ms <- fmap fst <$> useWithStale GetModSummaryWithoutTimestamps file
6562
sess <- fmap fst <$> useWithStale GhcSessionDeps file
6663

67-
-- When possible, rely on the haddocks embedded in our interface files
68-
-- This creates problems on ghc-lib, see comment on 'getDocumentationTryGhc'
69-
#if !defined(GHC_LIB)
70-
let parsedDeps = []
71-
#else
72-
deps <- maybe (TransitiveDependencies [] [] []) fst <$> useWithStale GetDependencies file
73-
parsedDeps <- mapMaybe (fmap fst) <$> usesWithStale GetParsedModule (transitiveModuleDeps deps)
74-
#endif
75-
7664
case (ms, sess) of
7765
(Just (ms,imps), Just sess) -> do
7866
let env = hscEnv sess
@@ -81,7 +69,7 @@ produceCompletions = do
8169
case (global, inScope) of
8270
((_, Just globalEnv), (_, Just inScopeEnv)) -> do
8371
let uri = fromNormalizedUri $ normalizedFilePathToUri file
84-
cdata <- liftIO $ cacheDataProducer uri env (ms_mod ms) globalEnv inScopeEnv imps parsedDeps
72+
cdata <- liftIO $ cacheDataProducer uri env (ms_mod ms) globalEnv inScopeEnv imps
8573
return ([], Just cdata)
8674
(_diag, _) ->
8775
return ([], Nothing)

ghcide/src/Development/IDE/Plugin/Completions/Logic.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ mkPragmaCompl label insertText =
294294
Nothing Nothing Nothing Nothing Nothing
295295

296296

297-
cacheDataProducer :: Uri -> HscEnv -> Module -> GlobalRdrEnv-> GlobalRdrEnv -> [LImportDecl GhcPs] -> [ParsedModule] -> IO CachedCompletions
298-
cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports deps = do
297+
cacheDataProducer :: Uri -> HscEnv -> Module -> GlobalRdrEnv-> GlobalRdrEnv -> [LImportDecl GhcPs] -> IO CachedCompletions
298+
cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports = do
299299
let dflags = hsc_dflags packageState
300300
curModName = moduleName curMod
301301

@@ -344,7 +344,7 @@ cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports deps = d
344344

345345
toCompItem :: Parent -> Module -> ModuleName -> Name -> Maybe (LImportDecl GhcPs) -> IO [CompItem]
346346
toCompItem par m mn n imp' = do
347-
docs <- getDocumentationTryGhc packageState curMod deps n
347+
docs <- getDocumentationTryGhc packageState curMod n
348348
let (mbParent, originName) = case par of
349349
NoParent -> (Nothing, nameOccName n)
350350
ParentIs n' -> (Just $ showNameWithoutUniques n', nameOccName n)

ghcide/src/Development/IDE/Spans/Documentation.hs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ import HscTypes (HscEnv(hsc_dflags))
4343

4444
mkDocMap
4545
:: HscEnv
46-
-> [ParsedModule]
4746
-> RefMap a
4847
-> TcGblEnv
4948
-> IO DocAndKindMap
50-
mkDocMap env sources rm this_mod =
49+
mkDocMap env rm this_mod =
5150
do let (_ , DeclDocMap this_docs, _) = extractDocs this_mod
5251
d <- foldrM getDocs (mkNameEnv $ M.toList $ fmap (`SpanDocString` SpanDocUris Nothing Nothing) this_docs) names
5352
k <- foldrM getType (tcg_type_env this_mod) names
@@ -56,7 +55,7 @@ mkDocMap env sources rm this_mod =
5655
getDocs n map
5756
| maybe True (mod ==) $ nameModule_maybe n = pure map -- we already have the docs in this_docs, or they do not exist
5857
| otherwise = do
59-
doc <- getDocumentationTryGhc env mod sources n
58+
doc <- getDocumentationTryGhc env mod n
6059
pure $ extendNameEnv map n doc
6160
getType n map
6261
| isTcOcc $ occName n = do
@@ -71,23 +70,21 @@ lookupKind :: HscEnv -> Module -> Name -> IO (Maybe TyThing)
7170
lookupKind env mod =
7271
fmap (fromRight Nothing) . catchSrcErrors (hsc_dflags env) "span" . lookupName env mod
7372

74-
getDocumentationTryGhc :: HscEnv -> Module -> [ParsedModule] -> Name -> IO SpanDoc
75-
getDocumentationTryGhc env mod deps n = head <$> getDocumentationsTryGhc env mod deps [n]
73+
getDocumentationTryGhc :: HscEnv -> Module -> Name -> IO SpanDoc
74+
getDocumentationTryGhc env mod n = head <$> getDocumentationsTryGhc env mod [n]
7675

77-
getDocumentationsTryGhc :: HscEnv -> Module -> [ParsedModule] -> [Name] -> IO [SpanDoc]
78-
-- Interfaces are only generated for GHC >= 8.6.
79-
-- In older versions, interface files do not embed Haddocks anyway
80-
getDocumentationsTryGhc env mod sources names = do
76+
getDocumentationsTryGhc :: HscEnv -> Module -> [Name] -> IO [SpanDoc]
77+
getDocumentationsTryGhc env mod names = do
8178
res <- catchSrcErrors (hsc_dflags env) "docs" $ getDocsBatch env mod names
8279
case res of
83-
Left _ -> mapM mkSpanDocText names
80+
Left _ -> return []
8481
Right res -> zipWithM unwrap res names
8582
where
8683
unwrap (Right (Just docs, _)) n = SpanDocString docs <$> getUris n
8784
unwrap _ n = mkSpanDocText n
8885

8986
mkSpanDocText name =
90-
SpanDocText (getDocumentation sources name) <$> getUris name
87+
SpanDocText [] <$> getUris name
9188

9289
-- Get the uris to the documentation and source html pages if they exist
9390
getUris name = do

0 commit comments

Comments
 (0)