forked from ghcjs/ghcjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup.hs
45 lines (37 loc) · 1.98 KB
/
Setup.hs
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
33
34
35
36
37
38
39
40
41
42
43
44
import Distribution.Simple (defaultMainWithHooks, simpleUserHooks, hookedPrograms, UserHooks(..))
import Distribution.Simple.Program.Types (simpleProgram)
import Distribution.Simple.Setup (CopyDest(..), installVerbosity, copyVerbosity, fromFlag)
import Distribution.Simple.Utils (createDirectoryIfMissingVerbose, installOrdinaryFile)
import Distribution.Simple.LocalBuildInfo (buildDir, absoluteInstallDirs, InstallDirs(..), LocalBuildInfo(..))
import Distribution.PackageDescription (PackageDescription(..), BuildInfo(..), Executable(..))
import System.FilePath ((</>))
import System.Process (rawSystem)
import Control.Monad (when)
import Data.Maybe (maybe, listToMaybe)
main = defaultMainWithHooks simpleUserHooks
{ hookedPrograms = [simpleProgram "java"]
, instHook = ghcjsInstHook
, postInst = ghcjsPostInst
, copyHook = ghcjsCopyHook
}
ghcjsPostInst _ _ pkgDesc lbi = when doBoot (autoboot >> return ())
where
ghcjsexe = listToMaybe $ filter (\(Executable s _ _) -> s == "ghcjs")
(executables . localPkgDescr $ lbi)
doBoot = maybe False (any (==("x-boot", "True")).customFieldsBI.buildInfo) ghcjsexe
autoboot = rawSystem "ghcjs-boot" ["--auto"] -- fixme make sure that the one from the current install is being run
ghcjsInstHook pkg_descr lbi hooks flags = do
instHook simpleUserHooks pkg_descr lbi hooks flags
copyRts pkg_descr lbi $ fromFlag (installVerbosity flags)
ghcjsCopyHook pkg_descr lbi hooks flags = do
copyHook simpleUserHooks pkg_descr lbi hooks flags
copyRts pkg_descr lbi $ fromFlag (copyVerbosity flags)
copyRts pkg_descr lbi verbosity = do
let lib = libdir $absoluteInstallDirs pkg_descr lbi NoCopyDest
destination = lib </> "rts.jso"
copy n = installOrdinaryFile verbosity ("rts" </> n) (destination </> n)
createDirectoryIfMissingVerbose verbosity True destination
copy "rts-options.js"
copy "rts-common.js"
copy "rts-plain.js"
copy "rts-trampoline.js"