shake-ext 2.6.0.2 → 2.7.0.0
raw patch · 3 files changed
+52/−21 lines, 3 filesdep +composition-preludePVP ok
version bump matches the API change (PVP)
Dependencies added: composition-prelude
API changes (from Hackage documentation)
+ Development.Shake.Cabal: getCabalDepsA :: FilePath -> Action (Version, [FilePath])
+ Development.Shake.Cabal: platform :: String
+ Development.Shake.Cabal: shakeVerbosityToCabalVerbosity :: Verbosity -> Verbosity
+ Development.Shake.Cabal: showVersion :: Version -> String
- Development.Shake.C: GHC :: Maybe String -> CCompiler
+ Development.Shake.C: GHC :: Maybe String -> Maybe String -> CCompiler
- Development.Shake.Cabal: getCabalDeps :: FilePath -> IO [FilePath]
+ Development.Shake.Cabal: getCabalDeps :: FilePath -> IO (Version, [FilePath])
- Development.Shake.Cabal: getCabalDepsV :: Verbosity -> FilePath -> IO [FilePath]
+ Development.Shake.Cabal: getCabalDepsV :: Verbosity -> FilePath -> IO (Version, [FilePath])
Files
- shake-ext.cabal +2/−1
- src/Development/Shake/C.hs +16/−14
- src/Development/Shake/Cabal.hs +34/−6
shake-ext.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: shake-ext-version: 2.6.0.2+version: 2.7.0.0 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2018 Vanessa McHale@@ -45,6 +45,7 @@ base >=4.10 && <5, shake -any, mtl -any,+ composition-prelude, directory -any, text -any, Cabal >=2.0,
src/Development/Shake/C.hs view
@@ -23,7 +23,7 @@ ) where import Control.Monad-import Data.List (isSuffixOf)+import Data.List (isPrefixOf, isSuffixOf) #if __GLASGOW_HASKELL__ < 804 import Data.Semigroup #endif@@ -31,9 +31,10 @@ import Development.Shake.FilePath import System.Info -mkQualified :: Monoid a => Maybe a -> a -> a-mkQualified suff = h (g <$> [suff])+mkQualified :: Monoid a => Maybe a -> Maybe a -> a -> a+mkQualified pre suff = h [g suff, f pre] where g = maybe id mappend+ f = maybe id (flip mappend) h = foldr fmap id host :: String@@ -45,32 +46,33 @@ pattern GCCStd = GCC Nothing pattern GHCStd :: CCompiler-pattern GHCStd = GHC Nothing+pattern GHCStd = GHC Nothing Nothing ccToString :: CCompiler -> String-ccToString Clang = "clang"-ccToString (Other s) = s-ccToString (GCC pre) = mkQualified pre "gcc"-ccToString (GHC pre) = mkQualified pre "ghc"+ccToString Clang = "clang"+ccToString (Other s) = s+ccToString (GCC pre) = mkQualified pre Nothing "gcc"+ccToString (GHC pre suff) = mkQualified pre suff "ghc" arToString :: CCompiler -> String-arToString (GCC pre) = mkQualified pre "ar"-arToString (GHC pre) = mkQualified pre "ar"-arToString _ = "ar"+arToString (GCC pre) = mkQualified pre Nothing "ar"+arToString (GHC pre _) = mkQualified pre Nothing "ar"+arToString _ = "ar" ccFromString :: String -> CCompiler ccFromString "gcc" = GCC Nothing ccFromString "clang" = Clang-ccFromString "ghc" = GHC Nothing+ccFromString "ghc" = GHC Nothing Nothing ccFromString s | "gcc" `isSuffixOf` s = GCC (Just (reverse . drop 3 . reverse $ s))- | "ghc" `isSuffixOf` s = GHC (Just (reverse . drop 3 . reverse $ s))+ | "ghc" `isSuffixOf` s = GHC (Just (reverse . drop 3 . reverse $ s)) Nothing+ | "ghc" `isPrefixOf` s = GHC Nothing (Just (drop 3 s)) ccFromString _ = GCC Nothing data CCompiler = GCC { _prefix :: Maybe String } | Clang+ | GHC { _prefix :: Maybe String, _postfix :: Maybe String } | Other String- | GHC { _prefix :: Maybe String } deriving (Eq) mapFlags :: String -> ([String] -> [String])
src/Development/Shake/Cabal.hs view
@@ -2,21 +2,36 @@ module Development.Shake.Cabal ( getCabalDeps , getCabalDepsV+ , getCabalDepsA+ , shakeVerbosityToCabalVerbosity+ -- * Helper functions+ , platform+ -- * Reëxports from "Distribution.Version"+ , showVersion ) where import Control.Arrow+import Control.Composition import Control.Monad import Data.Foldable (toList) import Data.Maybe (catMaybes) #if __GLASGOW_HASKELL__ < 804 import Data.Semigroup #endif+import Development.Shake as Shake import Distribution.ModuleName import Distribution.PackageDescription import Distribution.PackageDescription.Parse import Distribution.Types.CondTree-import Distribution.Verbosity+import Distribution.Types.PackageId+import Distribution.Verbosity as Distribution+import Distribution.Version+import System.Info (arch, os) +-- | E.g. @x86_64-linux@+platform :: String+platform = arch ++ "-" ++ os+ libraryToFiles :: Library -> [FilePath] libraryToFiles lib = cs <> is <> ((<> ".hs") . toFilePath <$> explicitLibModules lib) where (cs, is) = (cSources &&& includes) $ libBuildInfo lib@@ -26,16 +41,29 @@ extract (CondNode d _ bs) = d : (g =<< bs) where g (CondBranch _ tb fb) = join $ catMaybes [Just $ extract tb, extract <$> fb] +shakeVerbosityToCabalVerbosity :: Shake.Verbosity -> Distribution.Verbosity+shakeVerbosityToCabalVerbosity Silent = silent+shakeVerbosityToCabalVerbosity Quiet = normal+shakeVerbosityToCabalVerbosity Normal = normal+shakeVerbosityToCabalVerbosity Loud = verbose+shakeVerbosityToCabalVerbosity Chatty = verbose+shakeVerbosityToCabalVerbosity Diagnostic = deafening++getCabalDepsA :: FilePath -> Action (Version, [FilePath])+getCabalDepsA = join . (g <$> fmap shakeVerbosityToCabalVerbosity getVerbosity <*>) . pure+ where g = liftIO .* getCabalDepsV+ -- | Get library dependencies from a @.cabal@ file. This will only work for -- @.hs@ files; module signatures are not supported.-getCabalDeps :: FilePath -> IO [FilePath]+getCabalDeps :: FilePath -> IO (Version, [FilePath]) getCabalDeps = getCabalDepsV normal --- | Same as above, but we set the 'Verbosity' to be used during parsing.-getCabalDepsV :: Verbosity -> FilePath -> IO [FilePath]+getCabalDepsV :: Distribution.Verbosity -> FilePath -> IO (Version, [FilePath]) getCabalDepsV v p = do pkg <- readGenericPackageDescription v p- let extraSrc = extraSrcFiles $ packageDescription pkg+ let descr = packageDescription pkg+ extraSrc = extraSrcFiles descr+ vers = pkgVersion (package descr) libs = toList (condLibrary pkg) normalSrc = (libraryToFiles <=< extract) =<< libs- pure (extraSrc <> normalSrc)+ pure (vers, extraSrc <> normalSrc)