mirror of
https://github.com/commercialhaskell/stackage.git
synced 2026-01-12 07:18:31 +01:00
Provide --exclude option (#7)
This commit is contained in:
parent
a549ecbdc2
commit
e453fed90c
@ -19,6 +19,7 @@ import System.Process (runProcess, waitForProcess, rawSystem, re
|
||||
import System.Directory (createDirectoryIfMissing, canonicalizePath, doesDirectoryExist)
|
||||
import Distribution.Version (thisVersion, withinRange)
|
||||
import Control.Exception (assert)
|
||||
import Data.Set (empty)
|
||||
|
||||
defaultBuildSettings :: BuildSettings
|
||||
defaultBuildSettings = BuildSettings
|
||||
@ -31,6 +32,7 @@ defaultBuildSettings = BuildSettings
|
||||
, haskellPlatformCabal = "haskell-platform/haskell-platform.cabal"
|
||||
, requireHaskellPlatform = True
|
||||
, cleanBeforeBuild = True
|
||||
, excludedPackages = empty
|
||||
}
|
||||
|
||||
build :: BuildSettings -> IO ()
|
||||
|
||||
@ -13,12 +13,19 @@ import Stackage.Types
|
||||
import Stackage.Util
|
||||
import Data.Version (showVersion)
|
||||
|
||||
dropExcluded :: BuildSettings
|
||||
-> Map PackageName (VersionRange, Maintainer)
|
||||
-> Map PackageName (VersionRange, Maintainer)
|
||||
dropExcluded bs m0 =
|
||||
Set.foldl' (flip Map.delete) m0 (excludedPackages bs)
|
||||
|
||||
getInstallInfo :: BuildSettings -> IO InstallInfo
|
||||
getInstallInfo settings = do
|
||||
hp <- loadHaskellPlatform settings
|
||||
let allPackages
|
||||
let allPackages'
|
||||
| requireHaskellPlatform settings = Map.union (stablePackages settings) $ identsToRanges (hplibs hp)
|
||||
| otherwise = stablePackages settings
|
||||
allPackages = dropExcluded settings allPackages'
|
||||
let totalCore = extraCore settings `Set.union` Set.map (\(PackageIdentifier p _) -> p) (hpcore hp)
|
||||
pdb <- loadPackageDB totalCore allPackages
|
||||
final <- narrowPackageDB pdb $ Set.fromList $ Map.toList $ Map.map snd $ allPackages
|
||||
|
||||
@ -64,4 +64,8 @@ data BuildSettings = BuildSettings
|
||||
, haskellPlatformCabal :: FilePath
|
||||
, requireHaskellPlatform :: Bool
|
||||
, cleanBeforeBuild :: Bool
|
||||
, excludedPackages :: Set PackageName
|
||||
-- ^ Packages which should be dropped from the list of stable packages,
|
||||
-- even if present via the Haskell Platform or @stablePackages@. If these
|
||||
-- packages are dependencies of others, they will still be included.
|
||||
}
|
||||
|
||||
@ -1,14 +1,34 @@
|
||||
import Stackage.Types (BuildSettings(..))
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
import Stackage.Types
|
||||
import Stackage.Build (build, defaultBuildSettings)
|
||||
import Stackage.Init (stackageInit)
|
||||
import System.Environment (getArgs, getProgName)
|
||||
import Data.Set (fromList)
|
||||
|
||||
data BuildArgs = BuildArgs
|
||||
{ noClean :: Bool
|
||||
, excluded :: [String]
|
||||
}
|
||||
|
||||
parseBuildArgs :: [String] -> IO BuildArgs
|
||||
parseBuildArgs =
|
||||
loop $ BuildArgs False []
|
||||
where
|
||||
loop x [] = return x
|
||||
loop x ("--no-clean":rest) = loop x { noClean = True } rest
|
||||
loop x ("--exclude":y:rest) = loop x { excluded = y : excluded x } rest
|
||||
loop _ (y:_) = error $ "Did not understand argument: " ++ y
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
args <- getArgs
|
||||
case args of
|
||||
["build"] -> build defaultBuildSettings
|
||||
["build", "--no-clean"] -> build (defaultBuildSettings { cleanBeforeBuild = False })
|
||||
"build":rest -> do
|
||||
BuildArgs {..} <- parseBuildArgs rest
|
||||
build defaultBuildSettings
|
||||
{ cleanBeforeBuild = not noClean
|
||||
, excludedPackages = fromList $ map PackageName excluded
|
||||
}
|
||||
["init"] -> stackageInit
|
||||
["update"] -> stackageInit >> error "FIXME update"
|
||||
_ -> do
|
||||
@ -17,4 +37,5 @@ main = do
|
||||
putStrLn "Available commands:"
|
||||
putStrLn " update Download updated Stackage databases. Automatically calls init."
|
||||
putStrLn " init Initialize your cabal file to use Stackage"
|
||||
putStrLn " build [--no-clean] Build the package databases (maintainers only)"
|
||||
putStrLn " build [--no-clean] [--exclude package...]"
|
||||
putStrLn " Build the package databases (maintainers only)"
|
||||
|
||||
@ -39,6 +39,7 @@ executable stackage
|
||||
main-is: stackage.hs
|
||||
build-depends: base
|
||||
, stackage
|
||||
, containers
|
||||
|
||||
source-repository head
|
||||
type: git
|
||||
|
||||
Loading…
Reference in New Issue
Block a user