X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=libraries%2FifBuildable.hs;h=95bebaf8d360b67fc8efadd769a7aa2924aaadbb;hb=8fa821cd48cdf0a265df8915e4330d3b6fb9e6a3;hp=011ecb759146129a20fa0aff134edc5ebcd51fc0;hpb=6c796d2375238942c0b903e028181ea92727abc4;p=ghc-hetmet.git diff --git a/libraries/ifBuildable.hs b/libraries/ifBuildable.hs index 011ecb7..95bebaf 100644 --- a/libraries/ifBuildable.hs +++ b/libraries/ifBuildable.hs @@ -1,31 +1,35 @@ +-- Returns exitcode 0 if the given package is buildable or is a core package, +-- and 1 otherwise. module Main (main) where import Control.Monad -import System.Cmd import System.Directory import System.Environment import System.Exit +import System.IO main :: IO () main = do args <- getArgs case args of - [] -> - error "No package or command given" - [_] -> - error "No command given" - package : prog : progArgs -> - do setCurrentDirectory package - unbuildable <- doesFileExist "unbuildable" - if unbuildable - then do mustBeBuildables <- getMustBeBuildablePackages - when (package `elem` mustBeBuildables) - (error (package ++ " is unbuildable")) - else do ec <- rawSystem prog progArgs - exitWith ec + [package] -> + doit package + _ -> + error "Syntax: ifBuildable " + +doit :: String -> IO () +doit package + = do setCurrentDirectory package + unbuildable <- doesFileExist "unbuildable" + if not unbuildable + then exitWith ExitSuccess + else do mustBeBuildables <- getMustBeBuildablePackages + if package `elem` mustBeBuildables + then exitWith ExitSuccess + else do hPutStrLn stderr "Warning: Package is unbuildable" + exitWith (ExitFailure 1) getMustBeBuildablePackages :: IO [String] getMustBeBuildablePackages = do xs <- readFile "../core-packages" return $ filter ("readline" /=) $ lines xs -