on master help sign in
Merge branch 'master' of https://github.com/skogsbaer/stackage
commitd5f456ef021b5d2fa114bf46bb52533de280d273 authorMichael Snoyman <michael@snoyman.com> dateMon 3 Dec 2012, 07:08 (14 years ago) parent08bb109f9391c0
4 files changed+32−17
Stackage/Build.hs+23−14 Stackage/Config.hs+3 Stackage/Types.hs+1 app/stackage.hs+5−3
Stackage/Build.hs+23−14
@@ -5,7 +5,7 @@ module Stackage.Build
55 ) where
66
77import Distribution.Text (simpleParse)
8−import Control.Monad (unless)
8+import Control.Monad (unless, when)
99import Stackage.Types
1010import Stackage.CheckPlan
1111import Stackage.InstallInfo
@@ -14,9 +14,9 @@ import Stackage.Test
1414import Stackage.Util
1515import Stackage.Config
1616import System.Exit (ExitCode (ExitSuccess), exitWith)
17−import System.IO (IOMode (WriteMode), withBinaryFile)
17+import System.IO (IOMode (WriteMode), withBinaryFile, hPutStrLn)
1818import System.Process (runProcess, waitForProcess, rawSystem, readProcess)
19−import System.Directory (createDirectoryIfMissing, canonicalizePath)
19+import System.Directory (createDirectoryIfMissing, canonicalizePath, doesDirectoryExist)
2020import Distribution.Version (thisVersion, withinRange)
2121import Control.Exception (assert)
2222
@@ -30,6 +30,7 @@ defaultBuildSettings = BuildSettings
3030 , extraArgs = ["-fnetwork23"]
3131 , haskellPlatformCabal = "haskell-platform/haskell-platform.cabal"
3232 , requireHaskellPlatform = True
33+ , cleanBeforeBuild = True
3334 }
3435
3536build :: BuildSettings -> IO ()
@@ -37,21 +38,28 @@ build settings' = do
3738 putStrLn "Creating a build plan"
3839 ii <- getInstallInfo settings'
3940
40− putStrLn "Wiping out old sandbox folder"
4141 let root' = sandboxRoot settings'
42− rm_r root'
43− rm_r "logs"
42+ initPkgDb <- if cleanBeforeBuild settings'
43+ then do
44+ putStrLn "Wiping out old sandbox folder"
45+ rm_r root'
46+ rm_r "logs"
47+ return True
48+ else do
49+ b <- doesDirectoryExist root'
50+ when b (putStrLn "Re-using existing sandbox")
51+ return (not b)
4452 createDirectoryIfMissing True root'
4553 root <- canonicalizePath root'
4654 let settings = settings' { sandboxRoot = root }
4755
48− ec1 <- rawSystem "ghc-pkg" ["init", packageDir settings]
49− unless (ec1 == ExitSuccess) $ do
50− putStrLn "Unable to create package database via ghc-pkg init"
51− exitWith ec1
52−
53− checkPlan settings ii
54− putStrLn "No mismatches, starting the sandboxed build."
56+ when initPkgDb $ do
57+ ec1 <- rawSystem "ghc-pkg" ["init", packageDir settings]
58+ unless (ec1 == ExitSuccess) $ do
59+ putStrLn "Unable to create package database via ghc-pkg init"
60+ exitWith ec1
61+ checkPlan settings ii
62+ putStrLn "No mismatches, starting the sandboxed build."
5563
5664 versionString <- readProcess "cabal" ["--version"] ""
5765 libVersion <-
@@ -77,7 +85,8 @@ build settings' = do
7785 , extraArgs settings
7886 , iiPackageList ii
7987 ]
80− in runProcess "cabal" args Nothing Nothing Nothing (Just handle) (Just handle)
88+ in do hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
89+ runProcess "cabal" args Nothing Nothing Nothing (Just handle) (Just handle)
8190 ec <- waitForProcess ph
8291 unless (ec == ExitSuccess) $ do
8392 putStrLn "Build failed, please see build.log"
Stackage/Config.hs+3
@@ -68,6 +68,9 @@ defaultStablePackages = execWriter $ do
6868
6969 mapM_ (add "Antoine Latter") $ words
7070 "uuid byteorder"
71+
72+ mapM (add "Stefan Wehr <wehr@factisresearch.com>") $ words
73+ "HTF hscurses xmlgen stm-stats"
7174 where
7275 add maintainer package = addRange maintainer package "-any"
7376 addRange maintainer package range =
Stackage/Types.hs+1
@@ -63,4 +63,5 @@ data BuildSettings = BuildSettings
6363 , extraArgs :: [String]
6464 , haskellPlatformCabal :: FilePath
6565 , requireHaskellPlatform :: Bool
66+ , cleanBeforeBuild :: Bool
6667 }
app/stackage.hs+5−3
@@ -1,3 +1,4 @@
1+import Stackage.Types (BuildSettings(..))
12import Stackage.Build (build, defaultBuildSettings)
23import Stackage.Init (stackageInit)
34import System.Environment (getArgs, getProgName)
@@ -7,12 +8,13 @@ main = do
78 args <- getArgs
89 case args of
910 ["build"] -> build defaultBuildSettings
11+ ["build", "--no-clean"] -> build (defaultBuildSettings { cleanBeforeBuild = False })
1012 ["init"] -> stackageInit
1113 ["update"] -> stackageInit >> error "FIXME update"
1214 _ -> do
1315 pn <- getProgName
1416 putStrLn $ "Usage: " ++ pn ++ " <command>"
1517 putStrLn "Available commands:"
16− putStrLn " update Download updated Stackage databases. Automatically calls init."
17− putStrLn " init Initialize your cabal file to use Stackage"
18− putStrLn " build Build the package databases (maintainers only)"
18+ putStrLn " update Download updated Stackage databases. Automatically calls init."
19+ putStrLn " init Initialize your cabal file to use Stackage"
20+ putStrLn " build [--no-clean] Build the package databases (maintainers only)"