delete guileslop and add haskellslop
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
module Main where
|
||||
|
||||
import Foreign (Int32)
|
||||
|
||||
|
||||
foreign export ccall "hello" hello :: IO Int32
|
||||
|
||||
hello :: IO Int32
|
||||
hello = do
|
||||
putStrLn "hello from Haskell!!!"
|
||||
pure 0
|
||||
|
||||
main :: IO ()
|
||||
main = error "defining main shouldn't be necessary since we set -no-hs-main, \
|
||||
\but HLS is yelling at me and i just want to calm her down."
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,9 @@
|
||||
#include <HsFFI.h>
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
extern HsInt32 hello(void);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import Development.Shake
|
||||
import Development.Shake.Command
|
||||
import Development.Shake.FilePath
|
||||
import Development.Shake.Util
|
||||
import Data.Char (toUpper)
|
||||
|
||||
capitalise (x:xs) = toUpper x : xs
|
||||
|
||||
ghcflags =
|
||||
[ "-no-hs-main"
|
||||
, "-optl-mexec-model=reactor"
|
||||
, "-optl-Wl,--export=hello,--export=hs_init"
|
||||
]
|
||||
|
||||
main = shakeArgs shakeOptions $ do
|
||||
want ["call-hello.wasm","hello.wasm"]
|
||||
"call-hello.wasm" %> \out -> do
|
||||
need ["call-hello.wat"]
|
||||
cmd_ "wasm-tools parse call-hello.wat" "-o" [out]
|
||||
"hello.wasm" %> \out -> do
|
||||
need ["Hello.hs"]
|
||||
cmd_
|
||||
"wasm32-wasi-ghc"
|
||||
"Hello.hs" ghcflags
|
||||
"-o" [out]
|
||||
phony "run" $ do
|
||||
need ["call-hello.wasm","hello.wasm"]
|
||||
cmd_ "wasmtime run"
|
||||
"--preload" "env=hello.wasm"
|
||||
"--invoke" "call-hello"
|
||||
"call-hello.wasm"
|
||||
phony "clean" $ do
|
||||
removeFilesAfter ".shake" ["//*"]
|
||||
liftIO $ removeFiles "."
|
||||
[ "*.wasm"
|
||||
, "*.o"
|
||||
, "*_stub.h"
|
||||
, "*.hi"
|
||||
]
|
||||
@@ -0,0 +1,6 @@
|
||||
(module
|
||||
(import "env" "hello" (func $hello (result i32)))
|
||||
(import "env" "hs_init" (func $hs-init (param i32 i32)))
|
||||
(func (export "call-hello") (result i32)
|
||||
(call $hs-init (i32.const 0) (i32.const 0))
|
||||
(call $hello)))
|
||||
Reference in New Issue
Block a user