cdeps 0.1.1.8 → 0.1.2.2
raw patch · 3 files changed
+28/−11 lines, 3 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Language.C.Dependency: getIncludesText :: Text -> Either String [FilePath]
Files
- CHANGELOG.md +10/−0
- cdeps.cabal +6/−2
- src/Language/C/Dependency.x +12/−9
CHANGELOG.md view
@@ -1,5 +1,15 @@ # cdeps +## 0.1.2.1++ * Improve backwards compatibility+ * Minor performance improvements++## 0.1.2.0++ * Minor performance improvements+ * Add `getIncludesText`+ ## 0.1.1.8 * Fix build for GHC 8.2.2, 8.0.2 again.
cdeps.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: cdeps-version: 0.1.1.8+version: 0.1.2.2 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2018 Vanessa McHale@@ -62,9 +62,13 @@ default-language: Haskell2010 ghc-options: -Wall build-depends:- base >=4.9 && <5,+ base >=4.8 && <5, cdeps -any, optparse-applicative -any+ + if !impl(ghc >=8.0)+ build-depends:+ semigroups -any if (flag(development) && impl(ghc <8.4)) ghc-options: -Werror
src/Language/C/Dependency.x view
@@ -1,22 +1,22 @@ { {-# OPTIONS_GHC -fno-warn-unused-imports #-} module Language.C.Dependency ( getIncludes+ , getIncludesText , getCDepends , getAll ) where +import Control.Monad (filterM)+import qualified Data.ByteString.Lazy as BSL import Data.Foldable (fold) import Data.List (groupBy, group, sort) import Data.Maybe (fromMaybe)+import qualified Data.Text.Lazy as TL+import Data.Text.Lazy.Encoding (decodeUtf8, encodeUtf8) import Control.Monad.IO.Class import System.Directory (doesFileExist)-import Data.Bool (bool)-import qualified Data.Text.Lazy as TL-import Data.Text.Lazy.Encoding (decodeUtf8)-import qualified Data.ByteString.Lazy as BSL import System.FilePath ((</>), takeDirectory) import System.Environment (lookupEnv)-import Control.Monad } @@ -60,6 +60,9 @@ getIncludes :: BSL.ByteString -> Either String [FilePath] getIncludes = fmap extractDeps . lexC +getIncludesText :: TL.Text -> Either String [FilePath]+getIncludesText = getIncludes . encodeUtf8+ -- TODO file name?? nested_comment :: Alex Token nested_comment = go 1 =<< alexGetInput@@ -82,7 +85,7 @@ Just (c',input_) -> go (addLevel c' $ n) input_ _ -> go n input' - addLevel c' = bool id (+1) (c'==42)+ addLevel c' = if c' == 42 then (+1) else id err (pos,_,_,_) = let (AlexPn _ line col) = pos in@@ -122,10 +125,10 @@ -> m [FilePath] getCDepends incls src = liftIO $ do contents <- BSL.readFile src- envPath <- fromMaybe "" <$> lookupEnv "C_INCLUDE_PATH"+ envPath <- lookupEnv "C_INCLUDE_PATH" let incl = includes' contents dir = takeDirectory src- allDirs = dir : incls ++ split envPath+ allDirs = dir : incls ++ fromMaybe [] (split <$> envPath) filterM doesFileExist ((</>) <$> allDirs <*> incl) -- | Get transitive dependencies of a C source file.@@ -138,6 +141,6 @@ level <- traverse (getAll incls) deps let rmdups = fmap head . group . sort next = rmdups (fold (deps : level))- pure $ bool next deps (null level)+ pure $ if null level then deps else next }