Dependencies.hs 1.19 KB
Newer Older
1
{-# LANGUAGE NoImplicitPrelude #-}
Andrey Mokhov's avatar
Andrey Mokhov committed
2
module Package.Dependencies (buildPackageDependencies) where
3
4
5
6

import Package.Base

buildPackageDependencies :: Package -> TodoItem -> Rules ()
Andrey Mokhov's avatar
Andrey Mokhov committed
7
buildPackageDependencies (Package name path _) (stage, dist, settings) =
8
    let buildDir = toStandard $ path </> dist </> "build"
Andrey Mokhov's avatar
Andrey Mokhov committed
9
        pkgData  = path </> dist </> "package-data.mk"
10
    in
11
    (buildDir </> takeBaseName name <.> "m") %> \out -> do
12
        need ["shake/src/Package/Dependencies.hs"]
13
        terseRun (Ghc stage) $ arg "-M"
Andrey Mokhov's avatar
Andrey Mokhov committed
14
            <> packageArgs stage pkgData
15
            <> includeArgs path dist
16
            <> concatArgs ["-optP"] (CppOpts pkgData)
17
18
            <> productArgs ["-odir", "-stubdir", "-hidir"] buildDir
            <> arg ["-dep-makefile", toStandard $ out <.> "new"]
19
            <> productArgs "-dep-suffix" (map wayPrefix <$> ways settings)
Andrey Mokhov's avatar
Andrey Mokhov committed
20
            <> arg (HsOpts pkgData)
21
            <> arg (pkgHsSources path dist)
22
        -- Avoid rebuilding dependecies of out if it hasn't changed:
23
24
25
        -- Note: cannot use copyFileChanged as it depends on the source file
        deps <- liftIO $ readFile $ out <.> "new"
        writeFileChanged out deps
26
        removeFilesAfter "." [out <.> "new"]