Skip to content

Commit dce01ea

Browse files
committed
lose the ghc-lib flag
1 parent 3909291 commit dce01ea

File tree

5 files changed

+18
-79
lines changed

5 files changed

+18
-79
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:
@@ -92,19 +87,10 @@ library
9287
opentelemetry >=0.6.1,
9388
heapsize ==0.3.*,
9489
unliftio,
95-
unliftio-core
96-
if flag(ghc-lib)
97-
build-depends:
98-
ghc-lib >= 8.8,
99-
ghc-lib-parser >= 8.8
100-
cpp-options: -DGHC_LIB
101-
else
102-
build-depends:
90+
unliftio-core,
10391
ghc-boot-th,
10492
ghc-boot,
10593
ghc >= 8.6,
106-
-- These dependencies are used by Development.IDE.Session and are
107-
-- Haskell specific. So don't use them when building with -fghc-lib!
10894
ghc-check >=0.5.0.1,
10995
ghc-paths,
11096
cryptohash-sha1 >=0.11.100 && <0.12,
@@ -141,6 +127,7 @@ library
141127

142128
hs-source-dirs:
143129
src
130+
session-loader
144131
include-dirs:
145132
include
146133
exposed-modules:
@@ -169,6 +156,7 @@ library
169156
Development.IDE.LSP.LanguageServer
170157
Development.IDE.LSP.Outline
171158
Development.IDE.LSP.Server
159+
Development.IDE.Session
172160
Development.IDE.Spans.Common
173161
Development.IDE.Spans.Documentation
174162
Development.IDE.Spans.AtPoint
@@ -191,26 +179,14 @@ library
191179
Development.IDE.Plugin.Test
192180
Development.IDE.Plugin.TypeLenses
193181

194-
-- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses
195-
-- the real GHC library and the types are incompatible. Furthermore, when
196-
-- building with ghc-lib we need to make this Haskell agnostic, so no
197-
-- hie-bios!
198-
-- We also put these modules into a separate hs-source-dirs so we can avoid
199-
-- compiling them at all if ghc-lib is not set
200-
if !flag(ghc-lib)
201-
hs-source-dirs:
202-
session-loader
203-
exposed-modules:
204-
Development.IDE.Session
205-
other-modules:
206-
Development.IDE.Session.VersionCheck
207182
other-modules:
208183
Development.IDE.Core.FileExists
209184
Development.IDE.GHC.CPP
210185
Development.IDE.GHC.Warnings
211186
Development.IDE.LSP.Notifications
212187
Development.IDE.Plugin.CodeAction.PositionIndexed
213188
Development.IDE.Plugin.Completions.Logic
189+
Development.IDE.Session.VersionCheck
214190
Development.IDE.Types.Action
215191
ghc-options: -Wall -Wno-name-shadowing -Wincomplete-uni-patterns -Wno-unticked-promoted-constructors
216192

@@ -261,8 +237,6 @@ benchmark benchHist
261237
yaml
262238

263239
executable ghcide
264-
if flag(ghc-lib)
265-
buildable: False
266240
default-language: Haskell2010
267241
include-dirs:
268242
include
@@ -322,8 +296,6 @@ executable ghcide
322296
ViewPatterns
323297

324298
test-suite ghcide-tests
325-
if flag(ghc-lib)
326-
buildable: False
327299
type: exitcode-stdio-1.0
328300
default-language: Haskell2010
329301
build-tool-depends:

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

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

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

649639
-- | Persistent rule to ensure that hover doesn't block on startup
@@ -921,7 +911,6 @@ generateCoreRule =
921911

922912
getModIfaceRule :: Rules ()
923913
getModIfaceRule = defineEarlyCutoff $ \GetModIface f -> do
924-
#if !defined(GHC_LIB)
925914
fileOfInterest <- use_ IsFileOfInterest f
926915
res@(_,(_,mhmi)) <- case fileOfInterest of
927916
IsFOI status -> do
@@ -948,13 +937,6 @@ getModIfaceRule = defineEarlyCutoff $ \GetModIface f -> do
948937
compiledLinkables <- getCompiledLinkables <$> getIdeGlobalAction
949938
liftIO $ modifyVar_ compiledLinkables $ \old -> pure $ extendModuleEnv old mod time
950939
pure res
951-
#else
952-
tm <- use_ TypeCheck f
953-
hsc <- hscEnv <$> use_ GhcSessionDeps f
954-
(diags, !hiFile) <- liftIO $ compileToObjCodeIfNeeded hsc Nothing (error "can't compile with ghc-lib") tm
955-
let fp = hiFileFingerPrint <$> hiFile
956-
return (fp, (diags, hiFile))
957-
#endif
958940

959941
getModIfaceWithoutLinkableRule :: Rules ()
960942
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
@@ -41,9 +41,6 @@ import Control.Concurrent.Async (concurrently)
4141
import GHC.Exts (toList)
4242
import Development.IDE.GHC.Error (rangeToSrcSpan)
4343
import Development.IDE.GHC.Util (prettyPrint)
44-
#if defined(GHC_LIB)
45-
import Development.IDE.Import.DependencyInformation
46-
#endif
4744

4845
descriptor :: PluginId -> PluginDescriptor IdeState
4946
descriptor plId = (defaultPluginDescriptor plId)
@@ -69,15 +66,6 @@ produceCompletions = do
6966
ms <- fmap fst <$> useWithStale GetModSummaryWithoutTimestamps file
7067
sess <- fmap fst <$> useWithStale GhcSessionDeps file
7168

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

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

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

296296

297-
cacheDataProducer :: Uri -> HscEnvEq -> Module -> GlobalRdrEnv-> GlobalRdrEnv -> [LImportDecl GhcPs] -> [ParsedModule] -> IO CachedCompletions
298-
cacheDataProducer uri env curMod globalEnv inScopeEnv limports deps = do
299-
let
297+
cacheDataProducer :: Uri -> HscEnvEq -> Module -> GlobalRdrEnv-> GlobalRdrEnv -> [LImportDecl GhcPs] -> IO CachedCompletions
298+
cacheDataProducer uri env curMod globalEnv inScopeEnv limports = do
299+
let
300300
packageState = hscEnv env
301301
curModName = moduleName curMod
302302

@@ -343,7 +343,7 @@ cacheDataProducer uri env curMod globalEnv inScopeEnv limports deps = do
343343

344344
toCompItem :: Parent -> Module -> ModuleName -> Name -> Maybe (LImportDecl GhcPs) -> IO [CompItem]
345345
toCompItem par m mn n imp' = do
346-
docs <- getDocumentationTryGhc packageState curMod deps n
346+
docs <- getDocumentationTryGhc packageState curMod n
347347
let (mbParent, originName) = case par of
348348
NoParent -> (Nothing, nameOccName n)
349349
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)