X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=libraries%2FifBuildable.hs;h=68b619751b63f6b659cda495e19bb26916f22a53;hb=b547f2e28b0f07b089aada1164c1dd834f894996;hp=95bebaf8d360b67fc8efadd769a7aa2924aaadbb;hpb=8fce302bbaf3d0696ffa5ce98013e47ba6ba6c6c;p=ghc-hetmet.git diff --git a/libraries/ifBuildable.hs b/libraries/ifBuildable.hs index 95bebaf..68b6197 100644 --- a/libraries/ifBuildable.hs +++ b/libraries/ifBuildable.hs @@ -1,4 +1,4 @@ --- Returns exitcode 0 if the given package is buildable or is a core package, +-- Returns exitcode 0 if the given package is buildable or is a boot package, -- and 1 otherwise. module Main (main) where @@ -12,24 +12,29 @@ import System.IO main :: IO () main = do args <- getArgs case args of - [package] -> - doit package + [packagesFile, package] -> + doit packagesFile package _ -> - error "Syntax: ifBuildable " + error "Syntax: ifBuildable " -doit :: String -> IO () -doit package +doit :: FilePath -> String -> IO () +doit packagesFile package = do setCurrentDirectory package unbuildable <- doesFileExist "unbuildable" if not unbuildable then exitWith ExitSuccess - else do mustBeBuildables <- getMustBeBuildablePackages + else do mustBeBuildables <- getMustBeBuildables packagesFile 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 +getMustBeBuildables :: FilePath -> IO [String] +getMustBeBuildables packagesFile + = do xs <- readFile packagesFile + let nonCommentLines = filter (("#" /=) . take 1) $ lines xs + requiredLines = filter ((3 == ) . length) $ map words nonCommentLines + requiredLibraries = [ x | 'l':'i':'b':'r':'a':'r':'i':'e':'s':'/':x + <- map head requiredLines ] + return $ filter ("editline" /=) requiredLibraries +