shake-ext 2.7.0.5 → 2.8.0.0
raw patch · 10 files changed
+59/−26 lines, 10 files
Files
- shake-ext.cabal +1/−1
- src/Development/Shake/C.hs +9/−7
- src/Development/Shake/CCJS.hs +3/−1
- src/Development/Shake/Check.hs +2/−2
- src/Development/Shake/Clean.hs +6/−2
- src/Development/Shake/Elm.hs +3/−2
- src/Development/Shake/FileDetect.hs +4/−0
- src/Development/Shake/Linters.hs +7/−1
- src/Development/Shake/Man.hs +20/−5
- src/Development/Shake/TH.hs +4/−5
shake-ext.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: shake-ext-version: 2.7.0.5+version: 2.8.0.0 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2018 Vanessa McHale
src/Development/Shake/C.hs view
@@ -31,8 +31,9 @@ import System.Directory (removeFile) import System.Info --- | Given C source code, return a list of included files. This makes a call to--- either @clang@ or @gcc@, so it should be used sparingly.+-- | Given C source code, return a list of included files. This writes to a file+-- and then makes a call to either @clang@ or @gcc@, so it should be used+-- sparingly. getCDepends :: CCompiler -- ^ Should be either @gcc@ or @clang@. -> String -- ^ C source code -> Action [FilePath]@@ -62,7 +63,7 @@ pattern GHCStd :: CCompiler pattern GHCStd = GHC Nothing Nothing --- | Get the executable name associated with a 'CCompiler'+-- | Get the executable name for a 'CCompiler' ccToString :: CCompiler -> String ccToString Clang = "clang" ccToString (Other s) = s@@ -122,8 +123,8 @@ where objRules = objectFileR cc cfg <$> g sources <*> pure lib g = fmap (-<.> "o") --- | Rules for generating a binary from C source files. At most one can have the--- @main@ function.+-- | Rules for generating a binary from C source files. Can have at most have+-- one @main@ function. cBin :: CCompiler -> [FilePath] -- ^ C source files -> FilePattern -- ^ Binary file output@@ -131,17 +132,18 @@ -> Rules () cBin cc sources bin cfg = bin %> \out -> binaryA cc sources out cfg --- | This action builds a binary.+-- | This action builds an executable. binaryA :: CmdResult r => CCompiler -> [FilePath] -- ^ Source files- -> FilePath -- ^ Binary file output+ -> FilePath -- ^ Executable output -> CConfig -> Action r binaryA cc sources out cfg = need sources >> (command [EchoStderr False] (ccToString cc) . (("-o" : out : sources) <>) . cconfigToArgs) cfg +-- | Generate compiler flags for a given configuration. cconfigToArgs :: CConfig -> [String] cconfigToArgs (CConfig is ls ds es sl) = join [ mapFlags "-I" is, mapFlags "-l" (g sl <$> ls), mapFlags "-L" ds, es ] where g :: Bool -> (String -> String)
src/Development/Shake/CCJS.hs view
@@ -5,7 +5,9 @@ import Development.Shake.FilePath import System.Directory (createDirectoryIfMissing) -ccjs :: [FilePath] -> FilePattern -> Rules ()+ccjs :: [FilePath] -- ^ JavaScript source files+ -> FilePattern -- ^ File pattern for build output+ -> Rules () ccjs sources fp = fp %> \out -> do need sources
src/Development/Shake/Check.hs view
@@ -14,10 +14,10 @@ , MBool ) where -import Control.Monad.IO.Class import Development.Shake.TH $(mkExecChecks ["compleat", "pandoc", "autoconf", "cabal", "ghc", "madlang"]) -patsFilter :: (MonadIO m) => m Bool+-- | Check for presence of @pats-filter@.+patsFilter :: MBool patsFilter = checkExecutable "pats-filter"
src/Development/Shake/Clean.hs view
@@ -5,8 +5,12 @@ import Development.Shake +-- | Clean @elm-stuff@ directory and file extensions typically associated w/ Elm+-- builds. cleanElm :: Action ()-cleanElm = removeFilesAfter "elm-stuff" ["//*"]+cleanElm =+ removeFilesAfter "elm-stuff" ["//*"] >>+ removeFilesAfter "." ["//*.elmi"] -- | Clean generic products (@.o@, @.so@, @.a@). cleanProducts :: Action ()@@ -19,4 +23,4 @@ mapM_ (\p -> removeFilesAfter p ["//*"]) [ "dist", "dist-newstyle", ".stack-work", ".cabal-sandbox" ] >> removeFilesAfter "."- ["//*.o", "//*.ghc.*", "//*_stub.h", "//*.hi", "//*.dyn_o", "//*.p_o", "//*.dyn_hi", "//*.p_hi", "//*.hc", "cabal.sandbox.config"]+ ["//*.o", "//*.ghc.*", "//*_stub.h", "//*.hi", "//*.dyn_o", "//*.p_o", "//*.dyn_hi", "//*.p_hi", "//*.hc", "//*.haddock", "cabal.sandbox.config"]
src/Development/Shake/Elm.hs view
@@ -3,8 +3,9 @@ import Development.Shake -elmMake :: [FilePath] -- ^ Source files- -> [FilePath] -- ^ Extra source files+-- | Rules for calling @elm-make@.+elmMake :: [FilePath] -- ^ Elm source files+ -> [FilePath] -- ^ Extra source files to be tracked -> FilePattern -- ^ Build output -> Rules () elmMake sources extras fp =
src/Development/Shake/FileDetect.hs view
@@ -1,3 +1,5 @@+-- | The functions in this module get all files in the current directory with+-- some extension. module Development.Shake.FileDetect ( getAts , getSats@@ -18,6 +20,7 @@ import Data.Semigroup ((<>)) import Development.Shake +-- | Get all files ending with @.mad@. getMadlang :: Action [FilePath] getMadlang = getAll ["mad"] @@ -33,6 +36,7 @@ getToml :: Action [FilePath] getToml = getAll ["toml"] +-- | Get all haskell source files, including module signatures. getHs :: [FilePath] -> Action [FilePath] getHs files = join <$> mapM (`getAllDir` ["hs", "hs-boot", "hsig", "lhs"]) files
src/Development/Shake/Linters.hs view
@@ -11,6 +11,7 @@ , clangFormat , atsfmt , stylishHaskell+ -- * File detection , module Development.Shake.FileDetect ) where @@ -19,6 +20,7 @@ import Development.Shake import Development.Shake.FileDetect +-- | Check all @.dhall@ files. dhall :: Action () dhall = mapM_ checkDhall =<< getDhall @@ -27,7 +29,6 @@ contents <- liftIO $ readFile dh command [Stdin contents] "dhall" [] --- join fmap f = f . f trim :: String -> String trim = join fmap f where f = reverse . dropWhile isSpace@@ -39,18 +40,22 @@ (Stdout out) <- cmd (s ++ " " ++ p) if trim contents == trim out then pure () else error "formatter is not fully applied!" +-- | Check that given files are formatted according to @stylish-haskell@ stylishHaskell :: [FilePath] -> Action () stylishHaskell = mapM_ (checkIdempotent "stylish-haskell") +-- | Check that given files are formatted according to @atsfmt@ atsfmt :: [FilePath] -> Action () atsfmt = mapM_ (checkIdempotent "atsfmt") +-- | Check that given files are formatted according to @clang-format@ clangFormat :: [FilePath] -> Action () clangFormat = mapM_ (checkIdempotent "clang-format") checkFiles :: String -> [FilePath] -> Action () checkFiles str = mapM_ (cmd_ . ((str ++ " ") ++)) +-- | Check all @.mad@ files. madlang :: [FilePath] -> Action () madlang = checkFiles "madlang check" @@ -59,6 +64,7 @@ shellcheck :: [FilePath] -> Action () shellcheck = checkFiles "shellcheck" +-- | Check Haskell files using @ghc@. ghc :: [FilePath] -> Action () ghc dirs = checkFiles "ghc -Wall -Werror -Wincomplete-uni-patterns -Wincomplete-record-updates -fno-code" =<< getHs dirs
src/Development/Shake/Man.hs view
@@ -1,12 +1,27 @@-module Development.Shake.Man ( manpages+module Development.Shake.Man ( manpagesA+ , manpagesR+ , manpages ) where import Development.Shake import Development.Shake.FilePath +manpagesA :: FilePath -- ^ Source file. Can be any format accepted by [pandoc](http://hackage.haskell.org/package/pandoc).+ -> FilePath -- ^ Output file.+ -> Action ()+manpagesA source out =+ need [ source ] >>+ cmd ["pandoc", source, "-s", "-t", "man", "-o", out]++manpagesR :: FilePath -- ^ Source file+ -> FilePattern -- ^ Output file pattern+ -> Rules ()+manpagesR source pat =+ pat %> \out -> manpagesA source out++-- | Rules for converting markdown source to manpages. manpages :: Rules () manpages =- "//*.1" %> \out -> do- let source = out -<.> "md"- need [ source ]- cmd ["pandoc", source, "-s", "-t", "man", "-o", out]+ "//*.1" %> \out ->+ let source = out -<.> "md" in+ manpagesA source out
src/Development/Shake/TH.hs view
@@ -6,7 +6,6 @@ , mkExecChecks , commonVersion , MBool- , AVersion ) where import Control.Monad.IO.Class@@ -17,15 +16,15 @@ type MBool = forall m. MonadIO m => m Bool -type AVersion = Action String--commonVersion :: String -> Action String+-- | Attempt to get version information from a given exectuable.+commonVersion :: String -- ^ Executable name+ -> Action String commonVersion prog = do ~(Stdout out) <- command mempty prog ["--version"] pure . last . words . head . lines $ out mkSigVersion :: String -> Dec-mkSigVersion s = SigD (mkName $ s ++ "Version") (ConT ''AVersion)+mkSigVersion s = SigD (mkName $ s ++ "Version") (ConT ''Action `AppT` ConT ''String) mkVersion :: String -> Dec mkVersion s = FunD (mkName $ s ++ "Version") [Clause mempty (NormalB expr) mempty]