Copy.hs 1.04 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module Rules.Copy (installTargets, copyRules) where

import Base
import Expression
import GHC
import Rules.Generate
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
        ffiHPaths <- getDirectoryFiles "" ["libffi/build/inst/lib/*/include/ffi.h"]
        when (length ffiHPaths /= 1) $
            putError "copyRules: cannot determine location of ffi.h"
        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