X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=libraries%2FifBuildable.hs;h=93118ab281b23e2c1c690ae0d9b6c52058918277;hb=4404f20e9b8c7488af11946a1677d332e3df6ebe;hp=3119aeefb74a21bcfd445f462c66a2124c99f047;hpb=245094404c787dabdec878c8ea4ce9fc4e9fb9e4;p=ghc-hetmet.git diff --git a/libraries/ifBuildable.hs b/libraries/ifBuildable.hs index 3119aee..93118ab 100644 --- a/libraries/ifBuildable.hs +++ b/libraries/ifBuildable.hs @@ -1,8 +1,9 @@ +-- Returns exitcode 0 if the given package is buildable or is a boot package, +-- and 1 otherwise. module Main (main) where import Control.Monad -import System.Cmd import System.Directory import System.Environment import System.Exit @@ -11,27 +12,24 @@ 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 -> - doit package prog progArgs + [package] -> + doit package + _ -> + error "Syntax: ifBuildable " -doit :: String -> String -> [String] -> IO () -doit package prog progArgs +doit :: String -> IO () +doit package = do setCurrentDirectory package unbuildable <- doesFileExist "unbuildable" - if unbuildable - then do mustBeBuildables <- getMustBeBuildablePackages + if not unbuildable + then exitWith ExitSuccess + else do mustBeBuildables <- getMustBeBuildablePackages if package `elem` mustBeBuildables - then error (package ++ " is unbuildable") - else hPutStrLn stderr "Warning: Package is unbuildable" - else do ec <- rawSystem prog progArgs - exitWith ec + 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 - + = do xs <- readFile "../boot-packages" + return $ filter ("editline" /=) $ lines xs