Copy.hs 1.21 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
import Settings.Packages.Rts
10
11
12
13
14
15
16
17
18
19
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
20
        need [libffiLibrary]
21
22
        ffiHPaths <- getDirectoryFiles "" ["libffi/build/inst/lib/*/include/ffi.h"]
        when (length ffiHPaths /= 1) $
Andrey Mokhov's avatar
Andrey Mokhov committed
23
24
            putError $ "copyRules: exactly one ffi.h header expected"
                     ++ "(found: " ++ show ffiHPaths ++ ")."
Moritz Angermann's avatar
Moritz Angermann committed
25
        
26
        copyFile (takeDirectory (head ffiHPaths) -/- takeFileName ffih) ffih
27
28
        libffiName <- rtsLibffiLibraryName
        copyFile libffiLibrary (targetPath Stage1 rts -/- "build/lib" ++ libffiName <.> "a")
29
30
31
32
33

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