Copy.hs 1.15 KB
Newer Older
1
2
3
4
5
6
module Rules.Copy (installTargets, copyRules) where

import Base
import Expression
import GHC
import Rules.Generate
Andrey Mokhov's avatar
Andrey Mokhov committed
7
import Rules.Libffi
8
9
10
11
12
13
14
15
16
17
import Settings.TargetDirectory

installTargets :: [FilePath]
installTargets = [ "inplace/lib/template-hsc.h"
                 , "inplace/lib/platformConstants"
                 , "inplace/lib/settings" ]

copyRules :: Rules ()
copyRules = do
    targetPath Stage1 rts -/- "build/ffi*.h" %> \ffih -> do
Andrey Mokhov's avatar
Andrey Mokhov committed
18
        need [libffiLibrary]
19
20
        ffiHPaths <- getDirectoryFiles "" ["libffi/build/inst/lib/*/include/ffi.h"]
        when (length ffiHPaths /= 1) $
Andrey Mokhov's avatar
Andrey Mokhov committed
21
22
            putError $ "copyRules: exactly one ffi.h header expected"
                     ++ "(found: " ++ show ffiHPaths ++ ")."
23
24
25
26
27
28
29
30
31
32
33
34
35
        let ffiHPath = takeDirectory $ head ffiHPaths
        copy ffih ffiHPath

    "inplace/lib/template-hsc.h"    <~ pkgPath hsc2hs
    "inplace/lib/platformConstants" <~ derivedConstantsPath
    "inplace/lib/settings"          <~ "."
  where
    file <~ dir = file %> \_ -> copy file dir

    copy file dir = do
        let source = dir -/- takeFileName file
        copyFileChanged source file
        putBuild $ "| Copy " ++ source ++ " -> " ++ file