Removes dependency on Cabal to reduce build time

master
Abhinav Sarkar 2017-11-17 09:37:51 +05:30
parent 0960d01f8d
commit b3b85c4583
3 changed files with 6 additions and 48 deletions

View File

@ -16,8 +16,7 @@ cabal-version: >=1.18
executable ringo
hs-source-dirs: src
other-modules: Ringo.ArgParser,
Ringo.InputParser,
Distribution.CurrentPackageDescription
Ringo.InputParser
main-is: Main.hs
build-depends: base >=4.7 && <5,
text >=1.2 && <1.3,
@ -30,8 +29,6 @@ executable ringo
directory >=1.2 && <1.4,
filepath >=1.3 && <1.5,
aeson >=0.8 && <1.3,
Cabal >=1.18 && <2.1,
template-haskell >=2.9 && <2.13,
ringo-core
ghc-options: -Wall -fwarn-incomplete-uni-patterns -fno-warn-unused-do-bind
-fno-warn-orphans -funbox-strict-fields -O2

View File

@ -1,35 +0,0 @@
{-# 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

View File

@ -1,14 +1,9 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
module Ringo.ArgParser (ProgArgs(..), parseArgs) where
import qualified Data.Text as Text
import qualified Distribution.Package as P
import qualified Distribution.PackageDescription as P
import qualified Distribution.CurrentPackageDescription as P
import qualified Distribution.Text as DText
import Data.List (intercalate)
import Data.Monoid ((<>))
@ -109,9 +104,10 @@ progArgsParser =
versionParser :: String -> Parser (a -> a)
versionParser progName = infoOption (progName ++ " " ++ version)
(long "version"
<> short 'v'
<> help "Print version information")
where
version = $(P.getField (DText.display . P.pkgVersion . P.package))
version = "0.1.0"
parseArgs :: IO ProgArgs
parseArgs = do
@ -119,6 +115,6 @@ parseArgs = do
execParser $
info (helper <*> versionParser progName <*> progArgsParser)
(fullDesc
<> progDesc $(P.getField P.description)
<> header (progName ++ " - " ++ $(P.getField P.synopsis))
<> footer ("© " ++ $(P.getField P.copyright) ++ ". " ++ $(P.getField P.homepage)))
<> progDesc "Tool to transform Postgres OLTP schemas to OLAP star schemas automatically"
<> header (progName ++ " - OLTP to OLAP schema transformer for Postgres")
<> footer "© 2015-2017 Quintype Inc, Nilenso Software LLP, Abhinav Sarkar. http://github.com/abhin4v/ringo")