dynamic-cabal 0.3.3 → 0.3.4
raw patch · 6 files changed
+51/−27 lines, 6 filessetup-changedPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Distribution.Client.Dynamic.Query: instance [overlap ok] Typeable1 LeftoverTempDir
+ Distribution.Client.Dynamic.Query: instance [overlap ok] Typeable LeftoverTempDir
Files
- .travis.yml +14/−5
- LICENSE +1/−1
- Setup.hs +1/−1
- dynamic-cabal.cabal +11/−4
- src/Distribution/Client/Dynamic/Query.hs +6/−2
- tests/Main.hs +18/−14
.travis.yml view
@@ -1,18 +1,27 @@ env:- - GHCVER=7.4.2 CABALVER=1.16- - GHCVER=7.6.3 CABALVER=1.18- - GHCVER=7.8.3 CABALVER=1.20+ - GHCVER=7.4.2 CABALVER=1.16 CABALFLAGS=""+ - GHCVER=7.6.3 CABALVER=1.18 CABALFLAGS=""+ - GHCVER=7.8.3 CABALVER=1.20 CABALFLAGS="--enable-shared --enable-executable-dynamic"+ - GHCVER=7.8.4 CABALVER=1.22 CABALFLAGS="--enable-shared --enable-executable-dynamic" before_install: - sudo add-apt-repository -y ppa:hvr/ghc - sudo apt-get update - sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER hlint - cabal-$CABALVER update- - cabal-$CABALVER install happy -j - export PATH=/opt/ghc/$GHCVER/bin:~/.cabal/bin:$PATH + # The cabal-install packages from hvr's ppa are outdated for cabal 1.22+ - |+ if [ "$CABALVER" = "1.22" ]; then+ cabal-$CABALVER install cabal-install $CABALFLAGS --constraint "mtl < 2.2" --constraint="Cabal ==$CABALVER.*" --constraint="cabal-install ==$CABALVER.*"+ else+ export PATH=/opt/cabal/$CABALVER/bin:$PATH+ fi+ - cabal install happy $CABALFLAGS -j+ install:- - cabal-$CABALVER install --only-dependencies --enable-tests --enable-benchmarks -j+ - cabal install --only-dependencies --enable-tests $CABALFLAGS --enable-benchmarks -j script: - travis/script.sh
LICENSE view
@@ -1,4 +1,4 @@-Copyright 2013-2014 Benno Fünfstück+Copyright 2013-2015 Benno Fünfstück All rights reserved.
Setup.hs view
@@ -47,7 +47,7 @@ modifyIORef depsVar $ appendDL . singletonDL $ depsEntry (buildInfo exe) exelbi suitelbi deps <- fmap ($ []) $ readIORef depsVar - rewriteFile (dir </> (map fixchar $ "Build_" ++ testName suite ++ ".hs")) $ unlines + rewriteFile (dir </> (map fixchar $ "Build_" ++ testName suite ++ ".hs")) $ unlines [ "module Build_" ++ map fixchar (testName suite) ++ " where" , "getDistDir :: FilePath" , "getDistDir = " ++ show distDir
dynamic-cabal.cabal view
@@ -1,7 +1,7 @@ name: dynamic-cabal-version: 0.3.3+version: 0.3.4 license: BSD3-category: Distribution +category: Distribution cabal-version: >= 1.10 license-file: LICENSE author: Benno Fünfstück@@ -10,8 +10,13 @@ homepage: http://github.com/bennofs/dynamic-cabal/ bug-reports: http://github.com/bennofs/dynamic-cabal/issues copyright: Copyright (C) 2013 Benno Fünfstück-synopsis: dynamic-cabal-description: dynamic-cabal+synopsis: Access the functions from the Cabal library without depending on it+description:+ This library allows you to extract information from cabal files without depending on the Cabal library. Since+ GHC currently depends on Cabal, it's difficult to directly use Cabal if you also like to use the GHC API. This package+ solves that problem by using the GHC API itself to interface with Cabal, which means that it can use whatever Cabal version+ the user has installed, at run time (the version is not fixed at compile time). For a short tutorial, see+ <https://github.com/bennofs/dynamic-cabal>. build-type: Custom extra-source-files: .ghci@@ -45,6 +50,7 @@ Distribution.Client.Dynamic.Query Distribution.Client.Dynamic.LocalBuildInfo Distribution.Client.Dynamic.PackageDescription+ other-extensions: TemplateHaskell test-suite dynamic-cabal-tests type: exitcode-stdio-1.0@@ -52,6 +58,7 @@ hs-source-dirs: tests build-depends: base+ , ghc , dynamic-cabal , tasty , tasty-hunit
src/Distribution/Client/Dynamic/Query.hs view
@@ -147,12 +147,16 @@ setCurrentDirectory pwd res <$ removeDirectoryRecursive tmp +getConfigStateFile :: ExpG (FilePath -> IO LocalBuildInfo)+getConfigStateFile = useValue "Distribution.Simple.Configure" $ Ident "getConfigStateFile"+ generateSource :: Selector LocalBuildInfo o -> String -> FilePath -> Version -> IO String generateSource (Selector s) modName setupConfig version = return $ flip generateModule modName $ do getLBI <- addDecl (Ident "getLBI") $- applyE fmap' (read' <>. unlines' <>. applyE drop' 1 <>. lines' :: ExpG (String -> LocalBuildInfo))- <>$ applyE readFile' (expr setupConfig)+ if version < Version [1,21] []+ then applyE fmap' (read' <>. unlines' <>. applyE drop' 1 <>. lines' :: ExpG (String -> LocalBuildInfo)) <>$ applyE readFile' (expr setupConfig)+ else getConfigStateFile <>$ expr setupConfig result <- addDecl (Ident "result") $ applyE fmap' (s version) <>$ expr getLBI return $ Just [exportFun result]
tests/Main.hs view
@@ -6,6 +6,7 @@ import System.Directory import Test.Tasty.HUnit import Test.Tasty.TH+import qualified Config case_targets :: Assertion case_targets = do@@ -25,7 +26,7 @@ assertEqual "source directories" (sort $ map sourceDirs tgs) $ sort $ map return ["src", "tests", "tests"] assertBool "ghc options" $ all (elem "-Wall" . ghcOptions) tgs assertBool "no extensions (except TH)" $ all (not . any ("TemplateHaskell" /=) . extensions) tgs- assertBool "everything buildable" $ all buildable tgs+ assertBool "everything buildable" $ all buildable tgs assertBool "no cpp options" $ all (null . cppOptions) tgs case_packageDBs :: Assertion@@ -36,23 +37,25 @@ -- | test running raw query case_raw :: Assertion case_raw = do- s<-src- m::DM.Map String [String]<-runRawQuery s "dist/setup-config"- assertEqual "map size" 3 (DM.size m)- -- print m+ s <- src+ m :: DM.Map String [String] <- runRawQuery s "dist/setup-config"+ assertEqual "number of build targets" 3 (DM.size m) -- | the raw query source code src :: IO String-src=do- setupConfig' <- canonicalizePath "dist/setup-config"- cv <- getCabalVersion setupConfig'- let optStr = if cv >= Version [1,15,0] []- then " let opts=renderGhcOptions ((fst $ head $ readP_to_S parseVersion \"7.6.3\") :: Version) $ componentGhcOptions V.silent lbi b clbi \"dist/build\""- else " let opts=ghcOptions lbi b clbi \"dist/build\""+src = do+ distPrefix <- canonicalizePath "dist"+ cv <- getCabalVersion (distPrefix ++ "/setup-config")+ let optStr1 | cv >= Version [1,19,0] [] ="(compiler,_ ,_) <- configure V.silent Nothing Nothing defaultProgramDb"+ | otherwise =""+ let optStr | cv >= Version [1,19,0] [] ="renderGhcOptions compiler $ componentGhcOptions V.silent lbi b clbi " ++ show distPrefix+ | cv >= Version [1,15,0] [] ="renderGhcOptions ((fst $ head $ readP_to_S parseVersion " ++ show Config.cProjectVersion ++ ") :: Version) $ componentGhcOptions V.silent lbi b clbi \"dist/build\""+ | otherwise ="ghcOptions lbi b clbi \"dist/build\"" return $ unlines [ "module DynamicCabalQuery where" ,"import Distribution.PackageDescription" ,"import Distribution.Simple.LocalBuildInfo"+ ,"import Distribution.Simple.Configure (maybeGetPersistBuildConfig)" ,"import Data.IORef" ,"import qualified Data.Map as DM" ,"import qualified Distribution.Verbosity as V"@@ -60,23 +63,24 @@ ,"import Text.ParserCombinators.ReadP(readP_to_S)" ,if cv >= Version [1,15,0] [] then "import Distribution.Simple.Program.GHC" else "" ,"import Distribution.Simple.GHC"+ ,if cv >= Version [1,19,0] [] then "import Distribution.Simple.Program.Db(defaultProgramDb)" else "" ,"import Distribution.Version" ,"import Control.Monad" ,"" ,"result :: IO (DM.Map String [String])" ,"result=do"- ,"lbi<-liftM (read . Prelude.unlines . drop 1 . lines) $ Prelude.readFile \""++setupConfig' ++"\""+ ,"Just lbi<-maybeGetPersistBuildConfig \""++distPrefix ++"\"" ,"let pkg=localPkgDescr lbi" ,"r<-newIORef DM.empty"+ , optStr1 ,(if cv >= Version [1,18,0] [] then "withAllComponentsInBuildOrder" else "withComponentsLBI") ++ " pkg lbi (\\c clbi->do" ," let b=foldComponent libBuildInfo buildInfo testBuildInfo benchmarkBuildInfo c"- ,optStr+ ," let opts=" ++ optStr ++ "::[String]" ," let n=foldComponent (const \"\") exeName testName benchmarkName c" ," modifyIORef r (DM.insert n opts)" ," return ()" ," )" ,"readIORef r" ]- main :: IO ()