Rules.hs 1.18 KB
Newer Older
Andrey Mokhov's avatar
Andrey Mokhov committed
1
module Rules (generateTargets, packageRules) where
2

Ben Gamari's avatar
Ben Gamari committed
3
import Base
Andrey Mokhov's avatar
Andrey Mokhov committed
4
import Expression
5
import GHC
6
import Rules.Generate
7
import Rules.Package
8
import Rules.Resources
Andrey Mokhov's avatar
Andrey Mokhov committed
9
import Settings
10

11
12
-- TODO: not all program targets should be needed explicitly
-- | generateTargets needs top-level build targets
13
generateTargets :: Rules ()
14
15
generateTargets = action $ do
    targets <- fmap concat . forM [Stage0 ..] $ \stage -> do
16
        pkgs <- interpretWithStage stage getPackages
Andrey Mokhov's avatar
Andrey Mokhov committed
17
        let libPkgs = filter isLibrary pkgs \\ [rts, libffi]
18
        libTargets <- fmap concat . forM libPkgs $ \pkg -> do
19
            let target = PartialTarget stage pkg
20
            needHaddock <- interpretPartial target buildHaddock
Ben Gamari's avatar
Ben Gamari committed
21
22
            return [ pkgHaddockFile pkg | needHaddock && stage == Stage1 ]
        let programTargets = [ prog | Just prog <- programPath stage <$> pkgs ]
23
        return $ libTargets ++ programTargets
24

25
26
    rtsLib <- pkgLibraryFile Stage1 rts "rts" vanilla
    need $ targets ++ installTargets ++ [ rtsLib ]
27
28

packageRules :: Rules ()
29
30
packageRules = do
    resources <- resourceRules
31
    forM_ [Stage0 ..] $ \stage ->
32
33
        forM_ knownPackages $ \pkg ->
            buildPackage resources $ PartialTarget stage pkg