module Distribution.Simple.Program.Strip (stripLib, stripExe)
where
import Distribution.Simple.Program (ProgramConfiguration, lookupProgram
,rawSystemProgram, stripProgram)
import Distribution.Simple.Utils (warn)
import Distribution.System (Platform(..), OS (..), buildOS)
import Distribution.Verbosity (Verbosity)
import Control.Monad (unless)
import System.FilePath (takeBaseName)
runStrip :: Verbosity -> ProgramConfiguration -> FilePath -> [String] -> IO ()
runStrip verbosity progConf path args =
case lookupProgram stripProgram progConf of
Just strip -> rawSystemProgram verbosity strip (path:args)
Nothing -> unless (buildOS == Windows) $
warn verbosity $ "Unable to strip executable or library '"
++ (takeBaseName path)
++ "' (missing the 'strip' program)"
stripExe :: Verbosity -> Platform -> ProgramConfiguration -> FilePath -> IO ()
stripExe verbosity (Platform _arch os) conf path =
runStrip verbosity conf path args
where
args = case os of
OSX -> ["-x"]
_ -> []
stripLib :: Verbosity -> Platform -> ProgramConfiguration -> FilePath -> IO ()
stripLib verbosity (Platform _arch os) conf path = do
case os of
OSX ->
return ()
IOS -> return ()
Solaris -> return ()
Windows ->
return()
_ -> runStrip verbosity conf path args
where
args = ["--strip-unneeded"]