HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleshake-0.19.8Haskell2010

Development.Shake.Util

A module for useful utility functions for Shake build systems.

  • 6 values
  • Packageshake-0.19.8
  • Exports6
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceUtil.hs
valueparseMakefile :: String -> [(FilePath, [FilePath])]
#

Given the text of a Makefile, extract the list of targets and dependencies. Assumes a small subset of Makefile syntax, mostly that generated by gcc -MM.

parseMakefile "a: b c\nd : e" == [("a",["b","c"]),("d",["e"])]

Depend on the dependencies listed in a Makefile. Does not depend on the Makefile itself.

needMakefileDependencies file = need . concatMap snd . parseMakefile =<< liftIO (readFile file)

Depend on the dependencies listed in a Makefile. Does not depend on the Makefile itself. Use this function to indicate that you have already used the files in question.

neededMakefileDependencies file = needed . concatMap snd . parseMakefile =<< liftIO (readFile file)
valueshakeArgsAccumulate
  1. :: ShakeOptions
  2. -> [OptDescr (Either String (a -> a))]
  3. -> a
  4. -> a -> [String] -> IO (Maybe (Rules ()))
  5. -> IO ()
#

Like shakeArgsWith, but instead of accumulating a list of flags, apply functions to a default value. Usually used to populate a record structure. As an example of a build system that can use either gcc or distcc for compiling:

import System.Console.GetOpt

data Flags = Flags {distCC :: Bool} deriving Eq
flags = [Option "" ["distcc"] (NoArg $ Right $ \x -> x{distCC=True}) "Run distributed."]

main = shakeArgsAccumulate shakeOptions flags (Flags False) $ \flags targets -> pure $ Just $ do
    if null targets then want ["result.exe"] else want targets
    let compiler = if distCC flags then "distcc" else "gcc"
    "*.o" %> \out -> do
        need ...
        cmd compiler ...
    ...

Now you can pass --distcc to use the distcc compiler.

valueshakeArgsPrune :: ShakeOptions -> ([FilePath] -> IO ()) -> Rules () -> IO ()
#

Like shakeArgs but also takes a pruning function. If --prune is passed, then after the build has completed, the second argument is called with a list of the files that the build checked were up-to-date.