Skip to content
This repository
Browse code

Experimental support for cabal-dev

  • Loading branch information...
commit f56bda87f015a5fc40c4475875dc29399e51f97c 1 parent 2551a97
Hamish Mackenzie hamishmack authored
5 src/IDE/Core/Types.hs
@@ -57,6 +57,7 @@ module IDE.Core.Types (
57 57 , KeyString
58 58
59 59 , Prefs(..)
  60 +, cabalCommand
60 61
61 62 , LogRefType(..)
62 63 , LogRef(..)
@@ -434,6 +435,7 @@ data Prefs = Prefs {
434 435 , completeRestricted :: Bool
435 436 , saveAllBeforeBuild :: Bool
436 437 , jumpToWarnings :: Bool
  438 + , useCabalDev :: Bool
437 439 , backgroundBuild :: Bool
438 440 , runUnitTests :: Bool
439 441 , makeMode :: Bool
@@ -453,6 +455,9 @@ data Prefs = Prefs {
453 455 , endWithLastConn :: Bool
454 456 } deriving(Eq,Show)
455 457
  458 +cabalCommand :: Prefs -> String
  459 +cabalCommand p = if useCabalDev p then "cabal-dev" else "cabal"
  460 +
456 461 data SearchHint = Forward | Backward | Insert | Delete | Initial
457 462 deriving (Eq)
458 463
32 src/IDE/Package.hs
@@ -163,12 +163,13 @@ packageConfig = do
163 163
164 164 packageConfig' :: IDEPackage -> (Bool -> IDEAction) -> IDEAction
165 165 packageConfig' package continuation = do
  166 + prefs <- readIDE prefs
166 167 let dir = dropFileName (ipdCabalFile package)
167 168 logLaunch <- getDefaultLogLaunch
168 169 showDefaultLogLaunch'
169 170
170 171 runExternalTool' "Configuring"
171   - "cabal"
  172 + (cabalCommand prefs)
172 173 (["configure"] ++ (ipdConfigFlags package))
173 174 (Just dir) $ do
174 175 (mbLastOutput, _) <- EL.zip E.last (logOutput logLaunch)
@@ -194,7 +195,7 @@ runCabalBuild backgroundBuild jumpToWarnings withoutLinking package shallConfigu
194 195 then ["--with-ld=false"]
195 196 else []
196 197 ++ ipdBuildFlags package)
197   - runExternalTool' "Building" "cabal" args (Just dir) $ do
  198 + runExternalTool' "Building" (cabalCommand prefs) args (Just dir) $ do
198 199 (mbLastOutput, isConfigErr, _) <- EL.zip3 E.last isConfigError $
199 200 logOutputForBuild package backgroundBuild jumpToWarnings
200 201 lift $ do
@@ -258,9 +259,10 @@ packageDoc = do
258 259
259 260 packageDoc' :: Bool -> Bool -> IDEPackage -> (Bool -> IDEAction) -> IDEAction
260 261 packageDoc' backgroundBuild jumpToWarnings package continuation = do
  262 + prefs <- readIDE prefs
261 263 catchIDE (do
262 264 let dir = dropFileName (ipdCabalFile package)
263   - runExternalTool' "Documenting" "cabal" (["haddock"]
  265 + runExternalTool' "Documenting" (cabalCommand prefs) (["haddock"]
264 266 ++ (ipdHaddockFlags package)) (Just dir) $ do
265 267 (mbLastOutput, _) <- EL.zip E.last $
266 268 logOutputForBuild package backgroundBuild jumpToWarnings
@@ -275,12 +277,13 @@ packageClean = do
275 277
276 278 packageClean' :: IDEPackage -> (Bool -> IDEAction) -> IDEAction
277 279 packageClean' package continuation = do
  280 + prefs <- readIDE prefs
278 281 logLaunch <- getDefaultLogLaunch
279 282 showDefaultLogLaunch'
280 283
281 284 let dir = dropFileName (ipdCabalFile package)
282 285 runExternalTool' "Cleaning"
283   - "cabal"
  286 + (cabalCommand prefs)
284 287 ["clean"]
285 288 (Just dir) $ do
286 289 (mbLastOutput, _) <- EL.zip E.last (logOutput logLaunch)
@@ -293,6 +296,7 @@ packageCopy = do
293 296 lift $ showDefaultLogLaunch'
294 297
295 298 lift $ catchIDE (do
  299 + prefs <- readIDE prefs
296 300 window <- getMainWindow
297 301 mbDir <- liftIO $ chooseDir window "Select the target directory" Nothing
298 302 case mbDir of
@@ -300,7 +304,7 @@ packageCopy = do
300 304 Just fp -> do
301 305 let dir = dropFileName (ipdCabalFile package)
302 306 runExternalTool' "Copying"
303   - "cabal"
  307 + (cabalCommand prefs)
304 308 (["copy"] ++ ["--destdir=" ++ fp])
305 309 (Just dir)
306 310 (logOutput logLaunch))
@@ -313,20 +317,25 @@ packageInstallDependencies = do
313 317 lift $ showDefaultLogLaunch'
314 318
315 319 lift $ catchIDE (do
  320 + prefs <- readIDE prefs
316 321 let dir = dropFileName (ipdCabalFile package)
317   - runExternalTool' "Installing" "cabal" (["install","--only-dependencies"]
  322 + runExternalTool' "Installing" (cabalCommand prefs) (
  323 + (if useCabalDev prefs
  324 + then ["install-deps"]
  325 + else ["install","--only-dependencies"])
318 326 ++ (ipdConfigFlags package)
319 327 ++ (ipdInstallFlags package)) (Just dir) (logOutput logLaunch))
320 328 (\(e :: SomeException) -> putStrLn (show e))
321 329
322 330 packageCopy' :: IDEPackage -> (Bool -> IDEAction) -> IDEAction
323 331 packageCopy' package continuation = do
  332 + prefs <- readIDE prefs
324 333 logLaunch <- getDefaultLogLaunch
325 334 showDefaultLogLaunch'
326 335
327 336 catchIDE (do
328 337 let dir = dropFileName (ipdCabalFile package)
329   - runExternalTool' "Copying" "cabal" (["copy"]
  338 + runExternalTool' "Copying" (cabalCommand prefs) (["copy"]
330 339 ++ (ipdInstallFlags package)) (Just dir) $ do
331 340 (mbLastOutput, _) <- EL.zip E.last (logOutput logLaunch)
332 341 lift $ continuation (mbLastOutput == Just (ToolExit ExitSuccess)))
@@ -383,8 +392,9 @@ packageRegister' package continuation =
383 392 logLaunch <- getDefaultLogLaunch
384 393 showDefaultLogLaunch'
385 394 catchIDE (do
  395 + prefs <- readIDE prefs
386 396 let dir = dropFileName (ipdCabalFile package)
387   - runExternalTool' "Registering" "cabal" (["register"]
  397 + runExternalTool' "Registering" (cabalCommand prefs) (["register"]
388 398 ++ (ipdRegisterFlags package)) (Just dir) $ do
389 399 (mbLastOutput, _) <- EL.zip E.last (logOutput logLaunch)
390 400 lift $ continuation (mbLastOutput == Just (ToolExit ExitSuccess)))
@@ -403,8 +413,9 @@ packageTest' package continuation =
403 413 logLaunch <- getDefaultLogLaunch
404 414 showDefaultLogLaunch'
405 415 catchIDE (do
  416 + prefs <- readIDE prefs
406 417 let dir = dropFileName (ipdCabalFile package)
407   - runExternalTool' "Testing" "cabal" (["test"]
  418 + runExternalTool' "Testing" (cabalCommand prefs) (["test"]
408 419 ++ (ipdTestFlags package)) (Just dir) $ do
409 420 (mbLastOutput, _) <- EL.zip E.last (logOutput logLaunch)
410 421 lift $ continuation (mbLastOutput == Just (ToolExit ExitSuccess)))
@@ -418,8 +429,9 @@ packageSdist = do
418 429 lift $ showDefaultLogLaunch'
419 430
420 431 lift $ catchIDE (do
  432 + prefs <- readIDE prefs
421 433 let dir = dropFileName (ipdCabalFile package)
422   - runExternalTool' "Source Dist" "cabal" (["sdist"]
  434 + runExternalTool' "Source Dist" (cabalCommand prefs) (["sdist"]
423 435 ++ (ipdSdistFlags package)) (Just dir) (logOutput logLaunch))
424 436 (\(e :: SomeException) -> putStrLn (show e))
425 437
9 src/IDE/Pane/Preferences.hs
@@ -644,6 +644,14 @@ prefsDescription configDir packages = NFDPP [
644 644 boolEditor
645 645 (\i -> return ())
646 646
  647 + , mkFieldPP
  648 + (paraName <<<- ParaName "Use cabal-dev" $ emptyParams)
  649 + (PP.text . show)
  650 + boolParser
  651 + useCabalDev
  652 + (\b a -> a{useCabalDev = b})
  653 + boolEditor
  654 + (\i -> return ())
647 655 ]),
648 656 ("Debug", VFDPP emptyParams [
649 657 mkFieldPP
@@ -761,6 +769,7 @@ defaultPrefs = Prefs {
761 769 , completeRestricted = False
762 770 , saveAllBeforeBuild = True
763 771 , jumpToWarnings = True
  772 + , useCabalDev = False
764 773 , backgroundBuild = True
765 774 , runUnitTests = False
766 775 , makeMode = True

0 comments on commit f56bda8

Please sign in to comment.
Something went wrong with that request. Please try again.