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

Commit

Permalink
Move Development.IDE.Session into ghcide itself
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lukel97 committed Jul 20, 2020
1 parent 31ca6c4 commit 16a85ae
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 49 deletions.
1 change: 1 addition & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
- Development.IDE.GHC.Util
- Development.IDE.Import.FindImports
- Development.IDE.LSP.Outline
- Development.IDE.Session
- Development.IDE.Spans.Calculate
- Development.IDE.Spans.Documentation
- Development.IDE.Spans.Common
Expand Down
55 changes: 17 additions & 38 deletions ghcide.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 3.0
cabal-version: 1.20
build-type: Simple
category: Development
name: ghcide
Expand Down Expand Up @@ -79,7 +79,14 @@ library
build-depends:
ghc-boot-th,
ghc-boot,
ghc >= 8.4
ghc >= 8.4,
-- These dependencies are used by Development.IDE.Session and are
-- Haskell specific. So don't use them when building with -fghc-lib!
ghc-check,
ghc-paths,
cryptohash-sha1 >=0.11.100 && <0.12,
hie-bios == 0.6.*,
base16-bytestring >=0.1.1 && <0.2
if os(windows)
build-depends:
Win32
Expand Down Expand Up @@ -135,6 +142,14 @@ library
Development.IDE.Plugin
Development.IDE.Plugin.Completions
Development.IDE.Plugin.CodeAction

-- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses
-- the real GHC library and the types are incompatible. Furthermore, when
-- building with ghc-lib we need to make this Haskell agnostic, so no
-- hie-bios!
if !flag(ghc-lib)
exposed-modules:
Development.IDE.Session
other-modules:
Development.IDE.Core.Compile
Development.IDE.Core.Preprocessor
Expand Down Expand Up @@ -175,41 +190,6 @@ library
Development.IDE.GHC.HieBin
ghc-options: -Wall -Wno-name-shadowing

library ghcide-session-loader
visibility: public
default-language: Haskell2010
hs-source-dirs: session-loader
exposed-modules:
Development.IDE.Session
ghc-options: -Wall -Wno-name-shadowing
build-depends:
base == 4.*,
aeson,
async,
base16-bytestring >=0.1.1 && <0.2,
bytestring,
containers,
cryptohash-sha1 >=0.11.100 && <0.12,
directory,
extra,
filepath,
ghc,
ghc-check,
ghc-paths,
ghcide,
haskell-lsp,
haskell-lsp-types,
hie-bios >= 0.6.0 && < 0.7,
safe-exceptions,
shake,
text,
time,
unordered-containers
-- We can't build this with ghc-lib since it interfaces with hie-bios which
-- uses plain ghc types
if flag(ghc-lib)
buildable: False

executable ghcide-test-preprocessor
default-language: Haskell2010
hs-source-dirs: test/preprocessor
Expand Down Expand Up @@ -277,7 +257,6 @@ executable ghcide
directory,
extra,
filepath,
ghcide-session-loader,
gitrev,
hashable,
haskell-lsp,
Expand Down
2 changes: 0 additions & 2 deletions hie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ cradle:
component: "ghcide:lib:ghcide"
- path: "./exe"
component: "ghcide:exe:ghcide"
- path: "./session-loader"
component: "ghcide:lib:ghcide-session-loader"
- path: "./test"
component: "ghcide:test:ghcide-tests"
- path: "./bench"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE CPP #-}

{-|
The logic for setting up a ghcide session by tapping into hie-bios.
-}
module Development.IDE.Session (loadSession) where
module Development.IDE.Session
#ifndef GHC_LIB
(loadSession)
#endif
where

-- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses
-- the real GHC library and the types are incompatible. Furthermore, when
-- building with ghc-lib we need to make this Haskell agnostic, so no hie-bios!
#ifndef GHC_LIB

import Control.Concurrent.Async
import Control.Concurrent.Extra
Expand Down Expand Up @@ -66,10 +70,11 @@ import Module
import NameCache
import Packages

-- | Given a directory, return a Shake 'Action' which setups an 'IdeGhcSession'.
-- | Given a root directory, return a Shake 'Action' which setups an
-- 'IdeGhcSession' given a file.
-- Some of the many things this does:
--
-- * Find the cradle for the directory
-- * Find the cradle for the file
-- * Get the session options,
-- * Get the GHC lib directory
-- * Make sure the GHC compiletime and runtime versions match
Expand Down Expand Up @@ -643,3 +648,5 @@ showPackageSetupException (PackageCheckFailed BasePackageAbiMismatch{..}) = unwo
renderPackageSetupException :: FilePath -> PackageSetupException -> (NormalizedFilePath, ShowDiagnostic, Diagnostic)
renderPackageSetupException fp e =
ideErrorWithSource (Just "cradle") (Just DsError) (toNormalizedFilePath' fp) (T.pack $ showPackageSetupException e)

#endif

0 comments on commit 16a85ae

Please sign in to comment.