Files
scratch-wasm/examples/hello/Shakefile.hs
T
2026-06-22 03:48:04 -06:00

32 lines
926 B
Haskell

import Development.Shake
import Development.Shake.Command
import Development.Shake.FilePath
import Development.Shake.Util
main = shakeArgs shakeOptions $ do
-- action $ do
-- sourceFiles <- getDirectoryFiles "" ["//*.luasm"]
-- need $ (-<.> "luac") <$> sourceFiles
want ["hello.component.wasm"]
alternatives $ do
"*.component.wasm" %> \out -> do
let wasm = out `replaceExtensions` "wasm"
need [wasm]
cmd_
"wasm-tools component new"
[wasm]
"-o" [out]
"*.wasm" %> \out -> do
let wit = out -<.> "wit"
let wat = out -<.> "wat"
need [wit,wat]
cmd_
"wasm-tools component embed"
[wit] [wat] "-o" [out]
phony "run" $ do
need ["hello.component.wasm"]
cmd_ "wasmtime run --invoke hello() hello.component.wasm"
phony "clean" $ do
removeFilesAfter ".shake" ["//*"]
liftIO $ removeFiles "." ["*.wasm"]