summaryrefslogtreecommitdiff
path: root/utils/ghc-cabal
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2009-09-21 16:20:03 +0000
committerIan Lynagh <igloo@earth.li>2009-09-21 16:20:03 +0000
commitda8ca5158b9421c67df854f9e66ad8ae09b3ec66 (patch)
treee3f54ae1824df61c8bba3deba6c8063811a25594 /utils/ghc-cabal
parent423e325a3929a7545c2cab5d6d3aa2462ac86174 (diff)
downloadhaskell-da8ca5158b9421c67df854f9e66ad8ae09b3ec66.tar.gz
Add sdist to ghc-cabal's bag of tricks
Diffstat (limited to 'utils/ghc-cabal')
-rw-r--r--utils/ghc-cabal/ghc-cabal.hs42
1 files changed, 27 insertions, 15 deletions
diff --git a/utils/ghc-cabal/ghc-cabal.hs b/utils/ghc-cabal/ghc-cabal.hs
index b3769508e5..1b06cf4ba8 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