X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=libraries%2Fcabal-bin.hs;h=664480f5a2d5a088ce599294dcd48db26f27c5df;hb=b20e2bee6b0a734563f456dc346f91a3286d84b0;hp=ad93a37dcb05bb396f7198d451611a1b8a72b8de;hpb=a8d57b05e71ad859eb0024704b216fe1de9f362a;p=ghc-hetmet.git diff --git a/libraries/cabal-bin.hs b/libraries/cabal-bin.hs index ad93a37..664480f 100644 --- a/libraries/cabal-bin.hs +++ b/libraries/cabal-bin.hs @@ -1,6 +1,7 @@ -module Cabal (main) where +module Main (main) where +import Control.Monad import Data.Maybe import Distribution.PackageDescription import Distribution.PackageDescription.Parse @@ -19,9 +20,16 @@ setupProg = "./Setup" main :: IO () main = do + unprocessedArgs <- getArgs let verbosity = verbose + case unprocessedArgs of + ghc : packageConf : useCabalVersion : args -> + doit verbosity ghc packageConf useCabalVersion args + _ -> die "Bad args" + +doit :: Verbosity -> FilePath -> FilePath -> String -> [String] -> IO () +doit verbosity ghc packageConf useCabalVersion args = do exists <- doesFileExist setupProg - args <- getArgs if exists then rawSystemExit verbosity setupProg args else do gpdFile <- defaultPackageDesc verbosity @@ -34,5 +42,21 @@ main = do _ | packageName pd == PackageName "Cabal" -> -- Cabal is special...*sigh* Simple.defaultMainArgs args - | otherwise -> die "Don't know what to do!" + | otherwise -> + runSetup verbosity ghc packageConf useCabalVersion args + +runSetup :: Verbosity -> FilePath -> FilePath -> String -> [String] -> IO () +runSetup verbosity ghc packageConf useCabalVersion args = do + -- Don't bother building Setup if we are cleaning. If we need to + -- build Setup in order to build, and Setup isn't built already, + -- then there shouldn't be anything to clean anyway. + unless cleaning $ + rawSystemExit verbosity ghc ["-package-conf", packageConf, + "--make", "Setup", + "-package", "Cabal-" ++ useCabalVersion, + "-o", "Setup"] + rawSystemExit verbosity "./Setup" args + where cleaning = case args of + "clean" : _ -> True + _ -> False