Add cabal-helper for decoding Cabal-1.22 setup-configs
.. without having to worry about Cabal version conflicts
This commit is contained in:
parent
471a3ec358
commit
405b814726
@ -186,6 +186,21 @@ Executable ghc-modi
|
|||||||
, ghc
|
, ghc
|
||||||
, ghc-mod
|
, 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
|
Test-Suite doctest
|
||||||
Type: exitcode-stdio-1.0
|
Type: exitcode-stdio-1.0
|
||||||
Default-Language: Haskell2010
|
Default-Language: Haskell2010
|
||||||
|
28
src/GHCModCabal.hs
Normal file
28
src/GHCModCabal.hs
Normal 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"
|
Loading…
Reference in New Issue
Block a user