Skip to content

Commit e0928ab

Browse files
committed
Expose shake options
1 parent 416ca36 commit e0928ab

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

ghcide/exe/Main.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import Development.IDE.Types.Logger
3030
import Development.IDE.Plugin
3131
import Development.IDE.Plugin.Test as Test
3232
import Development.IDE.Session (loadSession)
33+
import Development.Shake (ShakeOptions (shakeThreads), shakeOptions)
3334
import qualified Language.Haskell.LSP.Core as LSP
3435
import Language.Haskell.LSP.Messages
3536
import Language.Haskell.LSP.Types
@@ -119,7 +120,7 @@ main = do
119120
, optShakeProfiling = argsShakeProfiling
120121
, optOTMemoryProfiling = IdeOTMemoryProfiling argsOTMemoryProfiling
121122
, optTesting = IdeTesting argsTesting
122-
, optThreads = argsThreads
123+
, optShakeOptions = shakeOptions{shakeThreads = argsThreads}
123124
, optCheckParents = checkParents config
124125
, optCheckProject = checkProject config
125126
}
@@ -164,7 +165,7 @@ main = do
164165
{ optShakeProfiling = argsShakeProfiling
165166
-- , optOTMemoryProfiling = IdeOTMemoryProfiling argsOTMemoryProfiling
166167
, optTesting = IdeTesting argsTesting
167-
, optThreads = argsThreads
168+
, optShakeOptions = shakeOptions{shakeThreads = argsThreads}
168169
, optCheckParents = NeverCheck
169170
, optCheckProject = False
170171
}

ghcide/ghcide.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ executable ghcide
277277
ghcide,
278278
lens,
279279
optparse-applicative,
280+
shake,
280281
text,
281282
unordered-containers
282283
other-modules:

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module Development.IDE.Core.Service(
1818
updatePositionMapping,
1919
) where
2020

21-
import Data.Maybe
2221
import Development.IDE.Types.Options (IdeOptions(..))
2322
import Development.IDE.Core.Debouncer
2423
import Development.IDE.Core.FileStore (VFSHandle, fileStoreRules)
@@ -62,10 +61,8 @@ initialise caps mainRule getLspId toDiags wProg wIndefProg logger debouncer opti
6261
(optShakeProfiling options)
6362
(optReportProgress options)
6463
(optTesting options)
65-
shakeOptions
66-
{ shakeThreads = optThreads options
67-
, shakeFiles = fromMaybe "/dev/null" (optShakeFiles options)
68-
} $ do
64+
(optShakeOptions options)
65+
$ do
6966
addIdeGlobal $ GlobalIdeOptions options
7067
fileStoreRules vfs
7168
ofInterestRules

ghcide/src/Development/IDE/Types/Options.hs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Development.IDE.Types.Options
1515
, IdeResult
1616
, IdeGhcSession(..)
1717
, OptHaddockParse(..)
18-
) where
18+
,optShakeFiles) where
1919

2020
import Data.Default
2121
import Development.Shake
@@ -50,12 +50,6 @@ data IdeOptions = IdeOptions
5050
-- ^ How to locate source and @.hie@ files given a module name.
5151
, optExtensions :: [String]
5252
-- ^ File extensions to search for code, defaults to Haskell sources (including @.hs@)
53-
54-
, optThreads :: Int
55-
-- ^ Number of threads to use. Use 0 for number of threads on the machine.
56-
, optShakeFiles :: Maybe FilePath
57-
-- ^ Directory where the shake database should be stored. For ghcide this is always set to `Nothing` for now
58-
-- meaning we keep everything in memory but the daml CLI compiler uses this for incremental builds.
5953
, optShakeProfiling :: Maybe FilePath
6054
-- ^ Set to 'Just' to create a directory of profiling reports.
6155
, optOTMemoryProfiling :: IdeOTMemoryProfiling
@@ -90,8 +84,16 @@ data IdeOptions = IdeOptions
9084
, optCustomDynFlags :: DynFlags -> DynFlags
9185
-- ^ Will be called right after setting up a new cradle,
9286
-- allowing to customize the Ghc options used
87+
, optShakeOptions :: ShakeOptions
9388
}
9489

90+
optShakeFiles :: IdeOptions -> Maybe FilePath
91+
optShakeFiles opts
92+
| value == defValue = Nothing
93+
| otherwise = Just value
94+
where
95+
value = shakeFiles (optShakeOptions opts)
96+
defValue = shakeFiles (optShakeOptions $ defaultIdeOptions undefined)
9597
data OptHaddockParse = HaddockParse | NoHaddockParse
9698
deriving (Eq,Ord,Show,Enum)
9799

@@ -119,8 +121,10 @@ defaultIdeOptions session = IdeOptions
119121
,optGhcSession = session
120122
,optExtensions = ["hs", "lhs"]
121123
,optPkgLocationOpts = defaultIdePkgLocationOptions
122-
,optThreads = 0
123-
,optShakeFiles = Nothing
124+
,optShakeOptions = shakeOptions
125+
{shakeThreads = 0
126+
,shakeFiles = "/dev/null"
127+
}
124128
,optShakeProfiling = Nothing
125129
,optOTMemoryProfiling = IdeOTMemoryProfiling False
126130
,optReportProgress = IdeReportProgress False

src/Ide/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import System.FilePath
5555
import System.IO
5656
import qualified System.Log.Logger as L
5757
import System.Time.Extra
58-
import Development.Shake (action)
58+
import Development.Shake (shakeOptions, ShakeOptions (shakeThreads), action)
5959

6060
ghcIdePlugins :: T.Text -> IdePlugins IdeState -> (Plugin Config, [T.Text])
6161
ghcIdePlugins pid ps = (asGhcIdePlugin ps, allLspCmdIds' pid ps)
@@ -135,7 +135,7 @@ runLspMode lspArgs@LspArguments{..} idePlugins = do
135135
{ optReportProgress = clientSupportsProgress caps
136136
, optShakeProfiling = argsShakeProfiling
137137
, optTesting = IdeTesting argsTesting
138-
, optThreads = argsThreads
138+
, optShakeOptions = shakeOptions{shakeThreads = argsThreads}
139139
-- , optCheckParents = checkParents config
140140
-- , optCheckProject = checkProject config
141141
}

0 commit comments

Comments
 (0)