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

import Base
import Expression
import GHC
6
import Rules.Actions
7
import Rules.Generate
Andrey Mokhov's avatar
Andrey Mokhov committed
8
import Rules.Libffi
9
10
11
12
13
14
15
16
17
18
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
19
        need [libffiLibrary]
20
21
        ffiHPaths <- getDirectoryFiles "" ["libffi/build/inst/lib/*/include/ffi.h"]
        when (length ffiHPaths /= 1) $
Andrey Mokhov's avatar
Andrey Mokhov committed
22
23
            putError $ "copyRules: exactly one ffi.h header expected"
                     ++ "(found: " ++ show ffiHPaths ++ ")."
Moritz Angermann's avatar
Moritz Angermann committed
24
        
25
        copyFile (takeDirectory (head ffiHPaths) -/- takeFileName ffih) ffih
Moritz Angermann's avatar
Moritz Angermann committed
26
        copyFile libffiLibrary (targetPath Stage1 rts -/- "build" -/- "libCffi.a")
27
28
29
30
31

    "inplace/lib/template-hsc.h"    <~ pkgPath hsc2hs
    "inplace/lib/platformConstants" <~ derivedConstantsPath
    "inplace/lib/settings"          <~ "."
  where
Andrey Mokhov's avatar
Andrey Mokhov committed
32
    file <~ dir = file %> \_ -> copyFile (dir -/- takeFileName file) file