Tool to transform OLTP database schemas to OLAP database schemas automatically
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ringo/ringo/src/Distribution/CurrentPackageDescription.hs

35 lines
1.1 KiB

{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE CPP #-}
module Distribution.CurrentPackageDescription
( currentPackageDescription
, getField
) where
import Prelude.Compat
import Distribution.PackageDescription
import Distribution.PackageDescription.Parse
import Distribution.Verbosity
import Data.List (isSuffixOf)
import Language.Haskell.TH (stringE, runIO, Q, Exp)
import System.Directory (getCurrentDirectory, getDirectoryContents)
getField :: (PackageDescription -> String) -> Q Exp
getField f = runIO currentPackageDescription >>= stringE . f
currentPackageDescription :: IO PackageDescription
currentPackageDescription = fmap packageDescription $ do
dir <- getCurrentDirectory
cs <- cabalFiles dir
case cs of
#if MIN_VERSION_base(4,10,0)
(c:_) -> readGenericPackageDescription silent c
#else
(c:_) -> readPackageDescription silent c
#endif
[] -> error $ "Couldn't find a cabal file in the current working directory (" ++ dir ++ ")"
cabalFiles :: FilePath -> IO [FilePath]
cabalFiles dir = filter (".cabal" `isSuffixOf`) <$> getDirectoryContents dir