Refactor package-specific settings (#622)
[hadrian.git] / src / Settings / Builders / Make.hs
1 module Settings.Builders.Make (makeBuilderArgs, validateBuilderArgs) where
2
3 import GHC
4 import Oracles.Setting
5 import Rules.Gmp
6 import Settings.Builders.Common
7
8 makeBuilderArgs :: Args
9 makeBuilderArgs = do
10 threads <- shakeThreads <$> expr getShakeOptions
11 gmpPath <- expr gmpBuildPath
12 libffiPath <- expr libffiBuildPath
13 let t = show $ max 4 (threads - 2) -- Don't use all Shake's threads
14 mconcat
15 [ builder (Make gmpPath ) ? pure ["MAKEFLAGS=-j" ++ t]
16 , builder (Make libffiPath ) ? pure ["MAKEFLAGS=-j" ++ t, "install"]
17 ]
18
19 validateBuilderArgs :: Args
20 validateBuilderArgs = builder (Make "testsuite/tests") ? do
21 threads <- shakeThreads <$> expr getShakeOptions
22 top <- expr topDirectory
23 compiler <- expr $ fullpath ghc
24 checkPpr <- expr $ fullpath checkPpr
25 checkApiAnnotations <- expr $ fullpath checkApiAnnotations
26 return [ "fast"
27 , "THREADS=" ++ show threads
28 , "TEST_HC=" ++ (top -/- compiler)
29 , "CHECK_PPR=" ++ (top -/- checkPpr)
30 , "CHECK_API_ANNOTATIONS=" ++ (top -/- checkApiAnnotations)
31 ]
32 where
33 fullpath :: Package -> Action FilePath
34 fullpath pkg = programPath =<< programContext Stage1 pkg
35