Skip to content

Commit 5578b8f

Browse files
authored
Expose shake options used (#1209)
* Expose shake options * Prepare for release v0.7.2.0 * respect default values for shakeOptions
1 parent 416ca36 commit 5578b8f

File tree

6 files changed

+31
-26
lines changed

6 files changed

+31
-26
lines changed

Diff for: ghcide/CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
### 0.7.1 (2020-01-13)
1+
### 0.7.2 (2020-01-14)
2+
* Expose shakeOptions used - (Pepe Iborra)
23

4+
### 0.7.1 (2020-01-13)
35
* Fix sticky diagnostics bug (#1188) - (Pepe Iborra)
46
* Use completionSnippetsOn flag (#1195) - (Yuya Kono)
57
* Update tested-with GHC in cabal config - (jneira)
@@ -13,7 +15,6 @@
1315
* fix suggestAddTypeAnnotation regex (#760) - (Kostas Dermentzis)
1416

1517
### 0.7.0 (2020-01-03)
16-
1718
* Ghcide now loads HLS plugins internally - (Pepe Iborra)
1819
* Retry a failed cradle if the cradle descriptor changes (#762) - (Pepe Iborra)
1920
* Fix extend imports regression (#769) - (Pepe Iborra)

Diff for: ghcide/exe/Main.hs

+7-4
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))
3334
import qualified Language.Haskell.LSP.Core as LSP
3435
import Language.Haskell.LSP.Messages
3536
import Language.Haskell.LSP.Types
@@ -114,15 +115,16 @@ main = do
114115
hPutStrLn stderr $ "Started LSP server in " ++ showDuration t
115116
sessionLoader <- loadSession $ fromMaybe dir rootPath
116117
config <- fromMaybe def <$> getConfig
117-
let options = (defaultIdeOptions sessionLoader)
118+
let options = defOptions
118119
{ optReportProgress = clientSupportsProgress caps
119120
, optShakeProfiling = argsShakeProfiling
120121
, optOTMemoryProfiling = IdeOTMemoryProfiling argsOTMemoryProfiling
121122
, optTesting = IdeTesting argsTesting
122-
, optThreads = argsThreads
123+
, optShakeOptions = (optShakeOptions defOptions){shakeThreads = argsThreads}
123124
, optCheckParents = checkParents config
124125
, optCheckProject = checkProject config
125126
}
127+
defOptions = defaultIdeOptions sessionLoader
126128
logLevel = if argsVerbose then minBound else Info
127129
debouncer <- newAsyncDebouncer
128130
let rules = do
@@ -160,14 +162,15 @@ main = do
160162
debouncer <- newAsyncDebouncer
161163
let dummyWithProg _ _ f = f (const (pure ()))
162164
sessionLoader <- loadSession dir
163-
let options = (defaultIdeOptions sessionLoader)
165+
let options = defOptions
164166
{ optShakeProfiling = argsShakeProfiling
165167
-- , optOTMemoryProfiling = IdeOTMemoryProfiling argsOTMemoryProfiling
166168
, optTesting = IdeTesting argsTesting
167-
, optThreads = argsThreads
169+
, optShakeOptions = (optShakeOptions defOptions){shakeThreads = argsThreads}
168170
, optCheckParents = NeverCheck
169171
, optCheckProject = False
170172
}
173+
defOptions = defaultIdeOptions sessionLoader
171174
logLevel = if argsVerbose then minBound else Info
172175
ide <- initialise def mainRule (pure $ IdInt 0) (showEvent lock) dummyWithProg (const (const id)) (logger logLevel) debouncer options vfs
173176

Diff for: ghcide/ghcide.cabal

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cabal-version: 1.20
22
build-type: Simple
33
category: Development
44
name: ghcide
5-
version: 0.7.1.0
5+
version: 0.7.2.0
66
license: Apache-2.0
77
license-file: LICENSE
88
author: Digital Asset and Ghcide contributors
@@ -277,6 +277,7 @@ executable ghcide
277277
ghcide,
278278
lens,
279279
optparse-applicative,
280+
shake,
280281
text,
281282
unordered-containers
282283
other-modules:

Diff for: ghcide/src/Development/IDE/Core/Service.hs

+2-5
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

Diff for: ghcide/src/Development/IDE/Types/Options.hs

+13-9
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

Diff for: src/Ide/Main.hs

+4-5
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 (shakeThreads), action)
5959

6060
ghcIdePlugins :: T.Text -> IdePlugins IdeState -> (Plugin Config, [T.Text])
6161
ghcIdePlugins pid ps = (asGhcIdePlugin ps, allLspCmdIds' pid ps)
@@ -131,14 +131,13 @@ runLspMode lspArgs@LspArguments{..} idePlugins = do
131131
hPutStrLn stderr $ "Started LSP server in " ++ showDuration t
132132
sessionLoader <- loadSession dir
133133
-- config <- fromMaybe defaultLspConfig <$> getConfig
134-
let options = (defaultIdeOptions sessionLoader)
134+
let options = defOptions
135135
{ optReportProgress = clientSupportsProgress caps
136136
, optShakeProfiling = argsShakeProfiling
137137
, optTesting = IdeTesting argsTesting
138-
, optThreads = argsThreads
139-
-- , optCheckParents = checkParents config
140-
-- , optCheckProject = checkProject config
138+
, optShakeOptions = (optShakeOptions defOptions){shakeThreads = argsThreads}
141139
}
140+
defOptions = defaultIdeOptions sessionLoader
142141
debouncer <- newAsyncDebouncer
143142
initialise caps (mainRule >> pluginRules plugins >> action kick)
144143
getLspId event wProg wIndefProg hlsLogger debouncer options vfs

0 commit comments

Comments
 (0)