Import hs-plugins cvs
This commit is contained in:
23
examples/make/o/prog/Main.hs
Normal file
23
examples/make/o/prog/Main.hs
Normal file
@ -0,0 +1,23 @@
|
||||
import Plugins
|
||||
import API
|
||||
|
||||
import System.Directory
|
||||
|
||||
-- note: the name of the original *source* module is used to find
|
||||
-- symbols in the *object* file. load works out what the source file
|
||||
-- name was by looking at the object file name, i.e. it assumes they
|
||||
-- have the same name. so, if you are going to store objects in a
|
||||
-- tmpdir, you should make a tmp directory, and store them inside that,
|
||||
-- rather than mkstemp'ing the name of the object file yourself.
|
||||
--
|
||||
-- this should go away once we can read .hi files.
|
||||
|
||||
main = do
|
||||
make "../Plugin.hs" [ "-i../api", "-o", "/tmp/Plugin.o" ]
|
||||
m_v <- load "/tmp/Plugin.o" ["../api"] [] "resource"
|
||||
v <- case m_v of
|
||||
LoadSuccess _ v -> return v
|
||||
_ -> error "load failed"
|
||||
putStrLn $ field v
|
||||
|
||||
mapM_ removeFile [ "/tmp/Plugin.o" , "/tmp/Plugin.hi" ]
|
Reference in New Issue
Block a user