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)))
|
||||
Generated
+72
-1
@@ -1,6 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"ghc-wasm": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"host": "gitlab.haskell.org",
|
||||
"lastModified": 1784272731,
|
||||
"narHash": "sha256-VcoIdIlUXz7fxu7gXbwih9Wy0m+i2wq6yYsSiFMuDs0=",
|
||||
"owner": "haskell-wasm",
|
||||
"repo": "ghc-wasm-meta",
|
||||
"rev": "ec050b490a8499a1d1d1a3c093b8e760a20d4ebf",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
"host": "gitlab.haskell.org",
|
||||
"owner": "haskell-wasm",
|
||||
"repo": "ghc-wasm-meta",
|
||||
"type": "gitlab"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1784182977,
|
||||
"narHash": "sha256-Hy8zg2HEcsk4WqowQK3UKRXz1fdQM7Z2un3nSyLbJaQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "29c22b7761070f37c4c2b0dd6a8777f0bd43e268",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-26.05-darwin",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1781607440,
|
||||
"narHash": "sha256-rxO+uc/KFbSJp+pgyXRuAX6QlG9hJdnt0BXpEQRXY+U=",
|
||||
@@ -18,7 +73,23 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
"ghc-wasm": "ghc-wasm",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
ghc-wasm.url = "gitlab:haskell-wasm/ghc-wasm-meta?host=gitlab.haskell.org";
|
||||
};
|
||||
|
||||
outputs = inputs:
|
||||
@@ -19,7 +20,7 @@
|
||||
pkgs.wasmtime
|
||||
pkgs.wasm-tools
|
||||
pkgs.wac-cli
|
||||
pkgs.guile
|
||||
inputs.ghc-wasm.packages.${system}.all_9_14
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
*.cps
|
||||
*.go
|
||||
@@ -1,21 +0,0 @@
|
||||
import Development.Shake
|
||||
import Development.Shake.Command
|
||||
import Development.Shake.FilePath
|
||||
import Development.Shake.Util
|
||||
|
||||
main = shakeArgs shakeOptions $ do
|
||||
action $ do
|
||||
sourceFiles <- getDirectoryFiles "" ["//*.scm"]
|
||||
need $ (-<.> "cps") <$> sourceFiles
|
||||
"*.cps" %> \out -> do
|
||||
withTempFile $ \temp_cps -> do
|
||||
let scm = out -<.> "scm"
|
||||
need [scm]
|
||||
cmd_
|
||||
"guild compile -O0 -Ocps -t cps -o" [temp_cps]
|
||||
[scm]
|
||||
cmd_ (FileStdout out)
|
||||
(Stdin ";; -*- mode:scheme -*-\n") "cat -" [temp_cps]
|
||||
phony "clean" $ do
|
||||
removeFilesAfter ".shake" ["//*"]
|
||||
liftIO $ removeFiles "." ["*.cps","*.go"]
|
||||
@@ -1,3 +0,0 @@
|
||||
(display "the numberr is ... ")
|
||||
(display (+ 5 (* 3 4)))
|
||||
(newline)
|
||||
Reference in New Issue
Block a user