This commit is contained in:
2026-08-24 07:03:24 -06:00
parent 540a44e148
commit f2c5d2f3ee
10 changed files with 134 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
import Development.Shake
import Development.Shake.Command
import Development.Shake.FilePath
import Development.Shake.Util
worldFor "program.wasm" = "gyehoek-program"
worldFor "runtime.wasm" = "gyehoek-runtime"
main = shakeArgs shakeOptions $ do
want ["gyehoek.wasm"]
alternatives $ do
"gyehoek.wasm" %> \out -> do
need ["runtime.component.wasm","program.component.wasm"]
cmd_
"wac plug --plug"
"runtime.component.wasm" "program.component.wasm"
"-o" "gyehoek.wasm"
"*.component.wasm" %> \out -> do
let wasm = out `replaceExtensions` "wasm"
need [wasm]
cmd_
"wasm-tools component new"
[wasm]
"-o" [out]
"*.wasm" %> \out -> do
let wit = "gyehoek.wit"
let wat = out -<.> "wat"
need [wit,wat]
cmd_
"wasm-tools component embed"
"-w" [worldFor out]
[wit] [wat] "-o" [out]
phony "run" $ do
need ["complete.component.wasm"]
cmd_ "wasmtime run --invoke add(1) complete.component.wasm"
phony "clean" $ do
removeFilesAfter ".shake" ["//*"]
liftIO $ removeFiles "." ["*.wasm"]
+20
View File
@@ -0,0 +1,20 @@
package gyehoek:gyehoek@0.1.0;
interface runtime {
resource scm {
make-small-int: static func(n: s32) -> scm;
}
}
interface program {
run: func() -> s32;
}
world gyehoek-runtime {
export runtime;
}
world gyehoek-program {
import runtime;
export program;
}
+8
View File
@@ -0,0 +1,8 @@
(module
(import "gyehoek:gyehoek/runtime@0.1.0"
"[static]scm.make-small-int"
(func $make-small-int (param i32) (result i32)))
(func $run (result i32)
(call $make-small-int (i32.const 123)))
(export "gyehoek:gyehoek/program@0.1.0#run"
(func $run)))
+5
View File
@@ -0,0 +1,5 @@
(module
(func $make-small-int (param $n i32) (result i32)
(i32.mul (local.get $n) (i32.const 2)))
(export "gyehoek:gyehoek/runtime@0.1.0#[static]scm.make-small-int"
(func $make-small-int)))
+4
View File
@@ -0,0 +1,4 @@
(component
(core module $main
(func (export "square") (param $n i32) (result i32)
(i32.mul (local.get $n) (local.get $n)))))