module Distribution.Simple.Program.Ar (
createArLibArchive,
multiStageProgramInvocation,
) where
import Distribution.Simple.Program.Types
( ConfiguredProgram(..) )
import Distribution.Simple.Program.Run
( programInvocation, multiStageProgramInvocation
, runProgramInvocation )
import Distribution.System
( OS(..), buildOS )
import Distribution.Verbosity
( Verbosity, deafening, verbose )
createArLibArchive :: Verbosity -> ConfiguredProgram
-> FilePath -> [FilePath] -> IO ()
createArLibArchive verbosity ar target files =
let simpleArgs = case buildOS :: OSbuildOS of
OSX -> ["-r", "-s"]
_ -> ["-r"]
initialArgs = ["-q"]
finalArgs = case buildOS :: OSbuildOS of
OSX -> ["-q", "-s"]
_ -> ["-q"]
extraArgs = verbosityOpts :: Verbosity -> [[Char]]verbosityOpts verbosity :: Verbosityverbosity (++) :: [a] -> [a] -> [a]++ [target :: FilePathtarget]
simple = programInvocation ::
ConfiguredProgram -> [String] -> ProgramInvocationprogramInvocation ar :: ConfiguredProgramar (simpleArgs :: [[Char]]simpleArgs (++) :: [a] -> [a] -> [a]++ extraArgs :: [[Char]]extraArgs)
initial = programInvocation ::
ConfiguredProgram -> [String] -> ProgramInvocationprogramInvocation ar :: ConfiguredProgramar (initialArgs :: [[Char]]initialArgs (++) :: [a] -> [a] -> [a]++ extraArgs :: [[Char]]extraArgs)
middle = initial :: ProgramInvocationinitial
final = programInvocation ::
ConfiguredProgram -> [String] -> ProgramInvocationprogramInvocation ar :: ConfiguredProgramar (finalArgs :: [[Char]]finalArgs (++) :: [a] -> [a] -> [a]++ extraArgs :: [[Char]]extraArgs)
in sequence_ :: Monad m => [m a] -> m ()sequence_
[ runProgramInvocation :: Verbosity -> ProgramInvocation -> IO ()runProgramInvocation verbosity :: Verbosityverbosity inv :: ProgramInvocationinv
| inv <- multiStageProgramInvocation ::
ProgramInvocation
-> (ProgramInvocation, ProgramInvocation, ProgramInvocation)
-> [String]
-> [ProgramInvocation]multiStageProgramInvocation
simple :: ProgramInvocationsimple (initial :: ProgramInvocationinitial, middle :: ProgramInvocationmiddle, final :: ProgramInvocationfinal) files :: [FilePath]files ]
where
verbosityOpts v | v :: Verbosityv (>=) :: Ord a => a -> a -> Bool>= deafening :: Verbositydeafening = ["-v"]
| v :: Verbosityv (>=) :: Ord a => a -> a -> Bool>= verbose :: Verbosityverbose = [] :: [a][]
| otherwise :: Boolotherwise = ["-c"]