-
Notifications
You must be signed in to change notification settings - Fork 187
/
Hsc2Hs.hs
33 lines (26 loc) · 950 Bytes
/
Hsc2Hs.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
{-
hsc2hs program
as a temporary solution, this is a wrapper around an existing hsc2hs,
this should be replaced by a custom preprocessor to generate the
code for the JS architecture.
-}
import Data.Char
import Data.List
import System.Exit
import System.Process
import qualified System.Info as Info
import Compiler.Info (getFullArguments)
main :: IO ()
main = do
args <- getFullArguments
exitWith =<< rawSystem "hsc2hs" (filter (\x -> isELF Info.os || not (isELFArg x)) args)
{-
when Setup.hs is compiled to JS, we have a regular, non-dynamic-too GHCJS.
Cabal assumes that the ghcjs OS is ELF. this confuses the wrapped hsc2hs on non-ELF
platforms
-}
isELFArg :: String -> Bool
isELFArg xs = any (`isPrefixOf` xs) ["--lflags=-Wl,-R,", "--lflag=-Wl,-R,"]
isELF :: String -> Bool
isELF xs = map toLower xs `notElem`
["mingw32", "win32", "cygwin32", "darwin", "osx", "ghcjs"]