Skip to content
This repository was archived by the owner on Jan 2, 2021. It is now read-only.

Commit cce9b29

Browse files
committed
Move Development.IDE.Session into ghcide itself
Sublibraries do not seem to play well. Hide this behind the ghc-lib flag so that the Haskell specific hie-bios stuff can be disabled
1 parent b2aa75a commit cce9b29

File tree

4 files changed

+25
-47
lines changed

4 files changed

+25
-47
lines changed

.hlint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
- Development.IDE.GHC.Util
8585
- Development.IDE.Import.FindImports
8686
- Development.IDE.LSP.Outline
87+
- Development.IDE.Session
8788
- Development.IDE.Spans.Calculate
8889
- Development.IDE.Spans.Documentation
8990
- Development.IDE.Spans.Common

ghcide.cabal

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cabal-version: 3.0
1+
cabal-version: 1.20
22
build-type: Simple
33
category: Development
44
name: ghcide
@@ -79,7 +79,14 @@ library
7979
build-depends:
8080
ghc-boot-th,
8181
ghc-boot,
82-
ghc >= 8.4
82+
ghc >= 8.4,
83+
-- These dependencies are used by Development.IDE.Session and are
84+
-- Haskell specific. So don't use them when building with -fghc-lib!
85+
ghc-check,
86+
ghc-paths,
87+
cryptohash-sha1 >=0.11.100 && <0.12,
88+
hie-bios == 0.6.*,
89+
base16-bytestring >=0.1.1 && <0.2
8390
if os(windows)
8491
build-depends:
8592
Win32
@@ -127,6 +134,7 @@ library
127134
Development.IDE.LSP.Outline
128135
Development.IDE.LSP.Protocol
129136
Development.IDE.LSP.Server
137+
Development.IDE.Session
130138
Development.IDE.Spans.Common
131139
Development.IDE.Types.Diagnostics
132140
Development.IDE.Types.Location
@@ -167,41 +175,6 @@ library
167175
Development.IDE.GHC.HieBin
168176
ghc-options: -Wall -Wno-name-shadowing
169177

170-
library ghcide-session-loader
171-
visibility: public
172-
default-language: Haskell2010
173-
hs-source-dirs: session-loader
174-
exposed-modules:
175-
Development.IDE.Session
176-
ghc-options: -Wall -Wno-name-shadowing
177-
build-depends:
178-
base == 4.*,
179-
aeson,
180-
async,
181-
base16-bytestring >=0.1.1 && <0.2,
182-
bytestring,
183-
containers,
184-
cryptohash-sha1 >=0.11.100 && <0.12,
185-
directory,
186-
extra,
187-
filepath,
188-
ghc,
189-
ghc-check,
190-
ghc-paths,
191-
ghcide,
192-
haskell-lsp,
193-
haskell-lsp-types,
194-
hie-bios >= 0.6.0 && < 0.7,
195-
safe-exceptions,
196-
shake,
197-
text,
198-
time,
199-
unordered-containers
200-
-- We can't build this with ghc-lib since it interfaces with hie-bios which
201-
-- uses plain ghc types
202-
if flag(ghc-lib)
203-
buildable: False
204-
205178
executable ghcide-test-preprocessor
206179
default-language: Haskell2010
207180
hs-source-dirs: test/preprocessor
@@ -269,7 +242,6 @@ executable ghcide
269242
directory,
270243
extra,
271244
filepath,
272-
ghcide-session-loader,
273245
gitrev,
274246
hashable,
275247
haskell-lsp,

hie.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ cradle:
1010
component: "ghcide:lib:ghcide"
1111
- path: "./exe"
1212
component: "ghcide:exe:ghcide"
13-
- path: "./session-loader"
14-
component: "ghcide:lib:ghcide-session-loader"
1513
- path: "./test"
1614
component: "ghcide:test:ghcide-tests"
1715
- path: "./bench"

session-loader/Development/IDE/Session.hs renamed to src/Development/IDE/Session.hs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
{-# LANGUAGE LambdaCase #-}
2-
{-# LANGUAGE NamedFieldPuns #-}
3-
{-# LANGUAGE OverloadedStrings #-}
4-
{-# LANGUAGE RecordWildCards #-}
5-
{-# LANGUAGE ScopedTypeVariables #-}
61
{-# LANGUAGE TemplateHaskell #-}
7-
{-# LANGUAGE TupleSections #-}
82
{-# LANGUAGE TypeFamilies #-}
3+
{-# LANGUAGE CPP #-}
94

105
{-|
116
The logic for setting up a ghcide session by tapping into hie-bios.
127
-}
13-
module Development.IDE.Session (loadSession) where
8+
module Development.IDE.Session
9+
#ifndef GHC_LIB
10+
(loadSession)
11+
#endif
12+
where
13+
14+
15+
-- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses
16+
-- the real GHC library and the types are incompatible. Furthermore, when
17+
-- building with ghc-lib we need to make this Haskell agnostic, so no hie-bios!
18+
#ifndef GHC_LIB
1419

1520
import Control.Concurrent.Async
1621
import Control.Concurrent.Extra
@@ -643,3 +648,5 @@ showPackageSetupException (PackageCheckFailed BasePackageAbiMismatch{..}) = unwo
643648
renderPackageSetupException :: FilePath -> PackageSetupException -> (NormalizedFilePath, ShowDiagnostic, Diagnostic)
644649
renderPackageSetupException fp e =
645650
ideErrorWithSource (Just "cradle") (Just DsError) (toNormalizedFilePath' fp) (T.pack $ showPackageSetupException e)
651+
652+
#endif

0 commit comments

Comments
 (0)