Commit 341f7117 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Add matchPackageNames to match packages and package names.

parent a66be352
{-# LANGUAGE DeriveGeneric #-}
module Package (
Package (..), PackageName, pkgCabalFile, setPath, topLevel, library, utility
Package (..), PackageName, pkgCabalFile, setPath, topLevel, library, utility,
matchPackageNames
) where
import Base
......@@ -45,6 +46,11 @@ instance Eq Package where
instance Ord Package where
compare = compare `on` pkgName
-- Given a sorted list of packages and a sorted list of package names, returns
-- packages whose names appear in the list of names
matchPackageNames :: [Package] -> [PackageName] -> [Package]
matchPackageNames = intersectOrd (\pkg name -> compare (pkgName pkg) name)
-- Instances for storing in the Shake database
instance Binary Package
instance Hashable Package where
......
......@@ -31,8 +31,7 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
-- We configure packages in the order of their dependencies
deps <- packageDeps pkg
pkgs <- interpretPartial target getPackages
let cmp p name = compare (pkgName p) name
depPkgs = intersectOrd cmp (sort pkgs) deps
let depPkgs = matchPackageNames (sort pkgs) deps
need [ targetPath stage p -/- "package-data.mk" | p <- depPkgs ]
need [cabalFile]
......
......@@ -18,7 +18,7 @@ defaultPackages = mconcat
packagesStage0 :: Packages
packagesStage0 = mconcat
[ append [ ghcBoot, binary, cabal, compiler, ghc, ghcCabal, ghcPkg
[ append [ binary, cabal, compiler, ghc, ghcBoot, ghcCabal, ghcPkg
, hsc2hs, hoopl, hpc, templateHaskell, transformers ]
, stage0 ? append [deriveConstants, genapply, genprimopcode, hp2ps]
, notM windowsHost ? notM (anyHostOs ["ios"]) ? append [terminfo] ]
......@@ -41,9 +41,10 @@ packagesStage2 = mconcat
[ append [ghcTags]
, buildHaddock ? append [haddock] ]
-- TODO: switch to Set Package as the order of packages should not matter?
knownPackages :: [Package]
knownPackages = defaultKnownPackages ++ userKnownPackages
knownPackages = sort $ defaultKnownPackages ++ userKnownPackages
-- Note: this is slow but we keep it simple as there not too many packages (30)
-- Note: this is slow but we keep it simple as there are just ~50 packages
findKnownPackage :: PackageName -> Maybe Package
findKnownPackage name = find (\pkg -> pkgName pkg == name) knownPackages
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment