mirror of
https://github.com/commercialhaskell/stackage.git
synced 2026-02-05 19:10:26 +01:00
Look up build tools packages based on executables (fixes #30)
This commit is contained in:
parent
024e873af2
commit
df836f406e
@ -7,10 +7,12 @@ module Stackage.Build
|
|||||||
import Control.Exception (assert)
|
import Control.Exception (assert)
|
||||||
import Control.Monad (unless, when)
|
import Control.Monad (unless, when)
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
|
import Data.Maybe (mapMaybe)
|
||||||
import Data.Set (empty)
|
import Data.Set (empty)
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
import Distribution.Text (simpleParse)
|
import Distribution.Text (simpleParse)
|
||||||
import Distribution.Version (withinRange)
|
import Distribution.Version (withinRange)
|
||||||
|
import Prelude hiding (pi)
|
||||||
import Stackage.CheckPlan
|
import Stackage.CheckPlan
|
||||||
import Stackage.Config
|
import Stackage.Config
|
||||||
import Stackage.InstallInfo
|
import Stackage.InstallInfo
|
||||||
@ -142,7 +144,7 @@ iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } =
|
|||||||
-- tools themselves, and install them in the correct order.
|
-- tools themselves, and install them in the correct order.
|
||||||
map unPackageName
|
map unPackageName
|
||||||
$ filter (flip Set.notMember coreTools)
|
$ filter (flip Set.notMember coreTools)
|
||||||
$ filter (flip Map.member m)
|
$ mapMaybe (flip Map.lookup buildToolMap)
|
||||||
$ Set.toList
|
$ Set.toList
|
||||||
$ Set.unions
|
$ Set.unions
|
||||||
$ map piBuildTools
|
$ map piBuildTools
|
||||||
@ -156,3 +158,11 @@ iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } =
|
|||||||
-- Build tools shipped with GHC which we should not attempt to build
|
-- Build tools shipped with GHC which we should not attempt to build
|
||||||
-- ourselves.
|
-- ourselves.
|
||||||
coreTools = Set.fromList $ map PackageName $ words "hsc2hs"
|
coreTools = Set.fromList $ map PackageName $ words "hsc2hs"
|
||||||
|
|
||||||
|
-- The map from build tool name to the package it comes from.
|
||||||
|
buildToolMap = Map.unions $ map toBuildToolMap $ Map.toList m
|
||||||
|
toBuildToolMap :: (PackageName, PackageInfo) -> Map Executable PackageName
|
||||||
|
toBuildToolMap (pn, pi) = Map.unions
|
||||||
|
$ map (flip Map.singleton pn)
|
||||||
|
$ Set.toList
|
||||||
|
$ piExecs pi
|
||||||
|
|||||||
@ -71,13 +71,14 @@ loadPackageDB settings core deps = do
|
|||||||
_ ->
|
_ ->
|
||||||
case Tar.entryContent e of
|
case Tar.entryContent e of
|
||||||
Tar.NormalFile bs _ -> do
|
Tar.NormalFile bs _ -> do
|
||||||
let (deps', hasTests, buildTools', mgpd) = parseDeps bs
|
let (deps', hasTests, buildTools', mgpd, execs) = parseDeps bs
|
||||||
return $ mappend pdb $ PackageDB $ Map.singleton p PackageInfo
|
return $ mappend pdb $ PackageDB $ Map.singleton p PackageInfo
|
||||||
{ piVersion = v
|
{ piVersion = v
|
||||||
, piDeps = deps'
|
, piDeps = deps'
|
||||||
, piHasTests = hasTests
|
, piHasTests = hasTests
|
||||||
, piBuildTools = buildTools'
|
, piBuildTools = buildTools'
|
||||||
, piGPD = mgpd
|
, piGPD = mgpd
|
||||||
|
, piExecs = execs
|
||||||
}
|
}
|
||||||
_ -> return pdb
|
_ -> return pdb
|
||||||
|
|
||||||
@ -89,8 +90,11 @@ loadPackageDB settings core deps = do
|
|||||||
, mconcat $ map (go gpd . snd) $ condTestSuites gpd
|
, mconcat $ map (go gpd . snd) $ condTestSuites gpd
|
||||||
, mconcat $ map (go gpd . snd) $ condBenchmarks gpd
|
, mconcat $ map (go gpd . snd) $ condBenchmarks gpd
|
||||||
], not $ null $ condTestSuites gpd
|
], not $ null $ condTestSuites gpd
|
||||||
, Set.fromList $ map depName $ allBuildInfo gpd, Just gpd)
|
, Set.fromList $ map depName $ allBuildInfo gpd
|
||||||
_ -> (mempty, defaultHasTestSuites, Set.empty, Nothing)
|
, Just gpd
|
||||||
|
, Set.fromList $ map (Executable . fst) $ condExecutables gpd
|
||||||
|
)
|
||||||
|
_ -> (mempty, defaultHasTestSuites, Set.empty, Nothing, Set.empty)
|
||||||
where
|
where
|
||||||
allBuildInfo gpd = concat
|
allBuildInfo gpd = concat
|
||||||
[ maybe mempty (goBI libBuildInfo) $ condLibrary gpd
|
[ maybe mempty (goBI libBuildInfo) $ condLibrary gpd
|
||||||
@ -100,7 +104,7 @@ loadPackageDB settings core deps = do
|
|||||||
]
|
]
|
||||||
where
|
where
|
||||||
goBI f x = buildTools $ f $ condTreeData x
|
goBI f x = buildTools $ f $ condTreeData x
|
||||||
depName (Dependency p _) = p
|
depName (Dependency (PackageName p) _) = Executable p
|
||||||
go gpd tree
|
go gpd tree
|
||||||
= Map.unionsWith unionVersionRanges
|
= Map.unionsWith unionVersionRanges
|
||||||
$ Map.fromList (map (\(Dependency p vr) -> (p, vr)) $ condTreeConstraints tree)
|
$ Map.fromList (map (\(Dependency p vr) -> (p, vr)) $ condTreeConstraints tree)
|
||||||
|
|||||||
@ -30,11 +30,15 @@ data PackageInfo = PackageInfo
|
|||||||
{ piVersion :: Version
|
{ piVersion :: Version
|
||||||
, piDeps :: Map PackageName VersionRange
|
, piDeps :: Map PackageName VersionRange
|
||||||
, piHasTests :: Bool
|
, piHasTests :: Bool
|
||||||
, piBuildTools :: Set PackageName
|
, piBuildTools :: Set Executable
|
||||||
, piGPD :: Maybe GenericPackageDescription
|
, piGPD :: Maybe GenericPackageDescription
|
||||||
|
, piExecs :: Set Executable
|
||||||
}
|
}
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
|
|
||||||
|
newtype Executable = Executable String
|
||||||
|
deriving (Show, Eq, Ord)
|
||||||
|
|
||||||
-- | Information on a package we're going to build.
|
-- | Information on a package we're going to build.
|
||||||
data BuildInfo = BuildInfo
|
data BuildInfo = BuildInfo
|
||||||
{ biVersion :: Version
|
{ biVersion :: Version
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user