Unverified Commit 44368b61 authored by Andrey Mokhov's avatar Andrey Mokhov Committed by GitHub

Add checkPpr package and infrastructure for testsuite packages (#596)

See #593
parent 1ee62bf5
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
module GHC (
-- * GHC packages
array, base, binary, bytestring, cabal, compareSizes, compiler, containers,
deepseq, deriveConstants, directory, filepath, genapply, genprimopcode, ghc,
ghcBoot, ghcBootTh, ghcCabal, ghcCompact, ghci, ghcPkg, ghcPrim, ghcTags,
ghcSplit, haddock, haskeline, hsc2hs, hp2ps, hpc, hpcBin, integerGmp,
integerSimple, iservBin, libffi, mtl, parsec, parallel, pretty,
array, base, binary, bytestring, cabal, checkPpr, compareSizes, compiler,
containers, deepseq, deriveConstants, directory, filepath, genapply,
genprimopcode, ghc, ghcBoot, ghcBootTh, ghcCabal, ghcCompact, ghci, ghcPkg,
ghcPrim, ghcTags, ghcSplit, haddock, haskeline, hsc2hs, hp2ps, hpc, hpcBin,
integerGmp, integerSimple, iservBin, libffi, mtl, parsec, parallel, pretty,
primitive, process, rts, runGhc, stm, templateHaskell, terminfo, text, time,
touchy, transformers, unlit, unix, win32, xhtml, ghcPackages, isGhcPackage,
defaultPackages,
defaultPackages, testsuitePackages,
-- * Package information
programName, nonCabalContext, nonHsMainPackage, autogenPath, installStage,
......@@ -99,6 +99,10 @@ stage1Packages = do
stage2Packages :: Action [Package]
stage2Packages = return [haddock]
-- | Packages that are built only for the testsuite.
testsuitePackages :: Action [Package]
testsuitePackages = return [checkPpr]
-- | Given a 'Context', compute the name of the program that is built in it
-- assuming that the corresponding package's type is 'Program'. For example, GHC
-- built in 'Stage0' is called @ghc-stage1@. If the given package is a
......
......@@ -11,14 +11,13 @@ import Hadrian.Utilities
-- modify build default build conditions in "UserSettings".
ghcPackages :: [Package]
ghcPackages =
[ array, base, binary, bytestring, cabal, compareSizes, compiler, containers
, deepseq, deriveConstants, directory, filepath, genapply, genprimopcode
, ghc, ghcBoot, ghcBootTh, ghcCompact, ghci, ghcPkg, ghcPrim
[ array, base, binary, bytestring, cabal, checkPpr, compareSizes, compiler
, containers, deepseq, deriveConstants, directory, filepath, genapply
, genprimopcode, ghc, ghcBoot, ghcBootTh, ghcCompact, ghci, ghcPkg, ghcPrim
, ghcTags, haddock, haskeline, hsc2hs, hp2ps, hpc, hpcBin, integerGmp
, integerSimple, iservBin, libffi, mtl, parsec, parallel, pretty, primitive
, process, rts, runGhc, stm, templateHaskell, terminfo, text, time, touchy
, transformers, unlit, unix, win32, xhtml
]
, transformers, unlit, unix, win32, xhtml ]
-- TODO: Optimise by switching to sets of packages.
isGhcPackage :: Package -> Bool
......@@ -30,6 +29,7 @@ base = hsLib "base"
binary = hsLib "binary"
bytestring = hsLib "bytestring"
cabal = hsLib "Cabal" `setPath` "libraries/Cabal/Cabal"
checkPpr = hsUtil "check-ppr"
compareSizes = hsUtil "compareSizes" `setPath` "utils/compare_sizes"
compiler = hsTop "ghc" `setPath` "compiler"
containers = hsLib "containers"
......@@ -79,7 +79,6 @@ unix = hsLib "unix"
win32 = hsLib "Win32"
xhtml = hsLib "xhtml"
-- | Construct a Haskell library package, e.g. @array@.
hsLib :: PackageName -> Package
hsLib name = hsLibrary name ("libraries" -/- name)
......
......@@ -39,13 +39,11 @@ topLevelTargets = action $ do
when (verbosity >= Loud) $ do
putNormal "Building stage2"
putNormal . unlines $
[ "| Building Programs: " ++ intercalate ", " pgmNames
, "| Building Libraries: " ++ intercalate ", " libNames
]
[ "| Building Programs : " ++ intercalate ", " pgmNames
, "| Building Libraries: " ++ intercalate ", " libNames ]
targets <- mapM (f Stage1) =<< stagePackages Stage1
need targets
where
-- either the package database config file for libraries or
-- the programPath for programs. However this still does
......
......@@ -21,40 +21,40 @@ buildProgram rs = do
forM_ [Stage0 ..] $ \stage ->
[ root -/- stageString stage -/- "bin" -/- "*"
, root -/- stageString stage -/- "lib/bin" -/- "*" ] |%> \bin -> do
-- quite inefficient. But we can't access the programName from
-- Rules, as it's an Action, due to being backed by an Oracle.
activeProgramPackages <- filter isProgram <$> stagePackages stage
nameToCtxList <- forM activeProgramPackages $ \pkg -> do
-- This is quite inefficient, but we can't access 'programName' from
-- 'Rules', because it is an 'Action' depending on an oracle.
sPackages <- filter isProgram <$> stagePackages stage
tPackages <- testsuitePackages
-- TODO: Shall we use Stage2 for testsuite packages instead?
let allPackages = sPackages
++ if stage == Stage1 then tPackages else []
nameToCtxList <- forM allPackages $ \pkg -> do
let ctx = vanillaContext stage pkg
name <- programName ctx
return (name <.> exe, ctx)
case lookup (takeFileName bin) nameToCtxList of
Nothing -> fail "Unknown program"
Nothing -> error $ "Unknown program " ++ show bin
Just (Context {..}) -> do
-- Rules for programs built in 'buildRoot'
-- Custom dependencies: this should be modeled better in the cabal file somehow.
-- Custom dependencies: this should be modeled better in the
-- Cabal file somehow.
-- TODO: Is this still needed? See 'runtimeDependencies'.
when (package == hsc2hs) $ do
-- hsc2hs needs the template-hsc.h file
tmpl <- templateHscPath stage
need [tmpl]
-- 'Hsc2hs' needs the @template-hsc.h@ file.
template <- templateHscPath stage
need [template]
when (package == ghc) $ do
-- ghc depends on settings, platformConstants, llvm-targets
-- ghc-usage.txt, ghci-usage.txt
-- GHC depends on @settings@, @platformConstants@,
-- @llvm-targets@, @ghc-usage.txt@, @ghci-usage.txt@.
need =<< ghcDeps stage
cross <- crossCompiling
-- for cross compiler, copy the stage0/bin/<pgm>
-- into stage1/bin/
-- For cross compiler, copy @stage0/bin/<pgm>@ to @stage1/bin/@.
case (cross, stage) of
(True, s) | s > Stage0 -> do
srcDir <- buildRoot <&> (-/- (stageString Stage0 -/- "bin"))
copyFile (srcDir -/- takeFileName bin) bin
_ -> buildBinary rs bin =<< programContext stage package
-- Rules for the GHC package, which is built 'inplace'
buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action ()
buildBinary rs bin context@Context {..} = do
......
......@@ -2,7 +2,7 @@ module Rules.Test (testRules, runTestGhcFlags, timeoutProgPath) where
import Base
import Expression
import GHC.Packages
import GHC
import Oracles.Flag
import Oracles.Setting
import Target
......@@ -13,7 +13,6 @@ import System.Environment
-- TODO: clean up after testing
testRules :: Rules ()
testRules = do
root <- buildRootRules
root -/- timeoutPyPath ~> do
......@@ -72,7 +71,6 @@ needTestBuilders = do
needBuilder Hpc
needBuilder (Hsc2Hs Stage1)
-- | Extra flags to send to the Haskell compiler to run tests.
runTestGhcFlags :: Action String
runTestGhcFlags = do
......
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