More Windows support, from <shelarcy capella.freemail.ne.jp>
This commit is contained in:
parent
98ea2802c9
commit
a1529d9003
@ -13,11 +13,16 @@ import System.Directory
|
|||||||
-- this should go away once we can read .hi files.
|
-- this should go away once we can read .hi files.
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
make "../Plugin.hs" [ "-i../api", "-o", "/tmp/Plugin.o" ]
|
#if __GLASGOW_HASKELL__ >= 604
|
||||||
m_v <- load "/tmp/Plugin.o" ["../api"] [] "resource"
|
tmpDir <- getTemporaryDirectory
|
||||||
|
#else
|
||||||
|
let tmpDir = "/tmp"
|
||||||
|
#endif
|
||||||
|
make "../Plugin.hs" [ "-i../api", "-o", (tmpDir ++ "/Plugin.o") ]
|
||||||
|
m_v <- load (tmpDir ++ "/Plugin.o") ["../api"] [] "resource"
|
||||||
v <- case m_v of
|
v <- case m_v of
|
||||||
LoadSuccess _ v -> return v
|
LoadSuccess _ v -> return v
|
||||||
_ -> error "load failed"
|
_ -> error "load failed"
|
||||||
putStrLn $ field v
|
putStrLn $ field v
|
||||||
|
|
||||||
mapM_ removeFile [ "/tmp/Plugin.o" , "/tmp/Plugin.hi" ]
|
mapM_ removeFile [ (tmpDir ++ "/Plugin.hi"), (tmpDir ++ "/Plugin.o") ]
|
||||||
|
@ -3,7 +3,12 @@ import API
|
|||||||
import System.Directory
|
import System.Directory
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
status <- make "../Plugin.hs" [ "-i../api", "-odir", "/tmp" ]
|
#if __GLASGOW_HASKELL__ >= 604
|
||||||
|
tmpDir <- getTemporaryDirectory
|
||||||
|
#else
|
||||||
|
let tmpDir = "/tmp"
|
||||||
|
#endif
|
||||||
|
status <- make "../Plugin.hs" [ "-i../api", "-odir", tmpDir ]
|
||||||
o <- case status of
|
o <- case status of
|
||||||
MakeSuccess _ o -> return o
|
MakeSuccess _ o -> return o
|
||||||
MakeFailure e -> mapM_ putStrLn e >> error "didn't compile"
|
MakeFailure e -> mapM_ putStrLn e >> error "didn't compile"
|
||||||
@ -12,5 +17,5 @@ main = do
|
|||||||
LoadSuccess _ v -> return v
|
LoadSuccess _ v -> return v
|
||||||
_ -> error "load failed"
|
_ -> error "load failed"
|
||||||
putStrLn $ field v
|
putStrLn $ field v
|
||||||
mapM_ removeFile ["/tmp/Plugin.hi", "/tmp/Plugin.o" ]
|
mapM_ removeFile [(tmpDir ++ "/Plugin.hi"), (tmpDir ++ "/Plugin.o") ]
|
||||||
|
|
||||||
|
@ -22,6 +22,13 @@ module Plugins.Consts where
|
|||||||
|
|
||||||
#include "../../../config.h"
|
#include "../../../config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if __GLASGOW_HASKELL__ >= 604
|
||||||
|
import System.Directory ( getTemporaryDirectory )
|
||||||
|
import System.IO.Unsafe ( unsafePerformIO )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
-- | path to *build* dir, used by eval() for testing the examples
|
-- | path to *build* dir, used by eval() for testing the examples
|
||||||
top = TOP
|
top = TOP
|
||||||
|
|
||||||
@ -40,7 +47,7 @@ sysPkgSuffix = ".o"
|
|||||||
objSuf = sysPkgSuffix
|
objSuf = sysPkgSuffix
|
||||||
hiSuf = ".hi"
|
hiSuf = ".hi"
|
||||||
hsSuf = ".hs"
|
hsSuf = ".hs"
|
||||||
#ifdef CYGWIN
|
#if defined(CYGWIN) || defined(__MINGW32__)
|
||||||
dllSuf = ".dll"
|
dllSuf = ".dll"
|
||||||
#else
|
#else
|
||||||
dllSuf = ".so"
|
dllSuf = ".so"
|
||||||
@ -59,9 +66,14 @@ prefixUnderscore = ""
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
-- | Define tmpDir to where tmp files should be created on your platform
|
-- | Define tmpDir to where tmp files should be created on your platform
|
||||||
|
|
||||||
|
#if __GLASGOW_HASKELL__ >= 604
|
||||||
|
tmpDir = unsafePerformIO getTemporaryDirectory
|
||||||
|
{-# NOINLINE tmpDir #-}
|
||||||
|
#else
|
||||||
#if !defined(__MINGW32__)
|
#if !defined(__MINGW32__)
|
||||||
tmpDir = "/tmp"
|
tmpDir = "/tmp"
|
||||||
#else
|
#else
|
||||||
tmpDir = error "tmpDir not defined for this platform. Try setting the TMPDIR env var"
|
tmpDir = error "tmpDir not defined for this platform. Try setting the TMPDIR env var"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
@ -243,7 +243,11 @@ unify obj incs args ty sym = do
|
|||||||
i = "-i" ++ dirname obj -- plugin
|
i = "-i" ++ dirname obj -- plugin
|
||||||
|
|
||||||
hWrite hdl src
|
hWrite hdl src
|
||||||
|
#if defined(CYGWIN) || defined(__MINGW32__)
|
||||||
|
e <- build tmpf "nul" (i:is++args++["-fno-code","-ohi nul"])
|
||||||
|
#else
|
||||||
e <- build tmpf "/dev/null" (i:is++args++["-fno-code","-ohi/dev/null"])
|
e <- build tmpf "/dev/null" (i:is++args++["-fno-code","-ohi/dev/null"])
|
||||||
|
#endif
|
||||||
removeFile tmpf
|
removeFile tmpf
|
||||||
return e
|
return e
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user