extism/js-pdk

Windows Support

Closed this issue · 2 comments

bhelx commented

I believe the tools we use support windows, so we just need to add windows to our CI and publish workflows:

But testing may yield some other issues.

Windows build incompatibilities

  • install-wasi-sdk.sh doesn't work because 1) it's a shell script, 2) windows doesn't have real CURL, it's mapped to Invoke-WebRequest. Should probably implement this as a .ps1 script for windows
  • the makefile uses the syntax cd -. The equivalents on Win are push-location and pop-location. I'm not sure if the cd - is used to fix the pwd to always be correct in case the previous cd commands failed or if it's just a shorthand way to undo a previous cd. If the latter, this incompatibility could be fixed by just updating to cd ../.. and not using this syntax.

I worked around these issues by

  • Changing all cd - to cd ../.. in the cli and core scripts
  • reproducing the install-wasi-sdk.sh script manually
    • downloading the 12.0 wasi sdk release for windows directly from github
    • placing it in a wasi-sdk folder
    • setting $env:QUICKJS_WASM_SYS_WASI_SDK_PATH = "C:/Code/js-pdk/wasi-sdk"
  • running make

Windows runtime incompatibilities

  • the install.sh script doesn't work because it's a shell script. need an equivalent .ps1 script or should be on Chocolatey
    binaryen needs to be installed manually
    • I installed binaryen by downloading the zip and placing it on the filesystem at C:\Tools\binaryen-version_117 and then - adding a PATH to the bin folder
  • extism-js is able to build .wasm output files but it has weird error output:
PS C:\Code\js-pdk\examples\simple_js> ..\..\target\release\extism-js.exe .\script.js -i .\script.d.ts
child not found in parent
UNREACHABLE executed at D:\a\binaryen\binaryen\src\passes\Precompute.cpp:838!

the built wasm file is callable, but that's the extent I've tested it.

..\..\extism.exe call .\index.wasm greet --input "Luke" --wasi 
Hello, Luke!

@lukevp that's really good progress! I will try to see if we can package your findings and make things smoother for Windows users next week