Add cabal-helper for decoding Cabal-1.22 setup-configs

.. without having to worry about Cabal version conflicts
This commit is contained in:
Daniel Gröber 2015-02-07 23:43:56 +01:00
parent 471a3ec358
commit 405b814726
2 changed files with 43 additions and 0 deletions

View File

@ -186,6 +186,21 @@ Executable ghc-modi
, ghc
, ghc-mod
Executable cabal-helper
Default-Language: Haskell2010
Main-Is: GHCModCabal.hs
GHC-Options: -Wall
HS-Source-Dirs: src
X-Install-Target: $libexecdir
Build-Depends: base >= 4.0 && < 5
, bytestring
, binary
, directory
if flag(cabal-122)
Build-Depends: Cabal >= 1.22
else
Buildable: False
Test-Suite doctest
Type: exitcode-stdio-1.0
Default-Language: Haskell2010

28
src/GHCModCabal.hs Normal file
View File

@ -0,0 +1,28 @@
{-# LANGUAGE BangPatterns #-}
module Main where
import Control.Applicative
import Distribution.Simple.Utils (cabalVersion)
import Distribution.Simple.Configure
import Distribution.Text ( display )
import System.Environment
import System.Directory
main :: IO ()
main = do
args <- getArgs
case args of
"version":[] -> do
putStrLn $ "using version " ++ display cabalVersion ++ " of the Cabal library"
"print-setup-config":args' -> do
mfile <- findFile ["dist"] "setup-config"
let file = case mfile of
Just f -> f
Nothing -> let !(f:[]) = args' in f
putStrLn =<< show <$> getConfigStateFile file
cmd:_ -> error $ "Unknown command: " ++ cmd
[] -> error "No command given"