From da8ca5158b9421c67df854f9e66ad8ae09b3ec66 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Mon, 21 Sep 2009 16:20:03 +0000 Subject: [PATCH] Add sdist to ghc-cabal's bag of tricks --- utils/ghc-cabal/ghc-cabal.hs | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/utils/ghc-cabal/ghc-cabal.hs b/utils/ghc-cabal/ghc-cabal.hs index b376950..1b06cf4 100644 --- a/utils/ghc-cabal/ghc-cabal.hs +++ b/utils/ghc-cabal/ghc-cabal.hs @@ -42,6 +42,8 @@ main = do args <- getArgs (config_args, "--" : distdir : directories) -> mapM_ (generate config_args distdir) directories _ -> die syntax_error + "sdist" : dir : distDir : [] -> + doSdist dir distDir _ -> die syntax_error syntax_error :: [String] @@ -69,6 +71,30 @@ withCurrentDirectory directory io userHooks :: UserHooks userHooks = autoconfUserHooks +runDefaultMain :: IO () +runDefaultMain + = do let verbosity = normal + gpdFile <- defaultPackageDesc verbosity + gpd <- readPackageDescription verbosity gpdFile + case buildType (flattenPackageDescription gpd) of + Just Configure -> defaultMainWithHooks autoconfUserHooks + -- time has a "Custom" Setup.hs, but it's actually Configure + -- plus a "./Setup test" hook. However, Cabal is also + -- "Custom", but doesn't have a configure script. + Just Custom -> + do configureExists <- doesFileExist "configure" + if configureExists + then defaultMainWithHooks autoconfUserHooks + else defaultMain + -- not quite right, but good enough for us: + _ -> defaultMain + +doSdist :: FilePath -> FilePath -> IO () +doSdist directory distDir + = withCurrentDirectory directory + $ withArgs (["sdist", "--builddir", distDir]) + runDefaultMain + doCheck :: FilePath -> IO () doCheck directory = withCurrentDirectory directory @@ -215,25 +241,11 @@ generate :: [String] -> FilePath -> FilePath -> IO () generate config_args distdir directory = withCurrentDirectory directory $ do let verbosity = normal - gpdFile <- defaultPackageDesc verbosity - gpd <- readPackageDescription verbosity gpdFile - -- XXX We shouldn't just configure with the default flags -- XXX And this, and thus the "getPersistBuildConfig distdir" below, -- aren't going to work when the deps aren't built yet withArgs (["configure", "--distdir", distdir] ++ config_args) - (case buildType (flattenPackageDescription gpd) of - Just Configure -> defaultMainWithHooks autoconfUserHooks - -- time has a "Custom" Setup.hs, but it's actually Configure - -- plus a "./Setup test" hook. However, Cabal is also - -- "Custom", but doesn't have a configure script. - Just Custom -> - do configureExists <- doesFileExist "configure" - if configureExists - then defaultMainWithHooks autoconfUserHooks - else defaultMain - -- not quite right, but good enough for us: - _ -> defaultMain) + runDefaultMain lbi <- getPersistBuildConfig distdir let pd0 = localPkgDescr lbi -- 1.7.10.4