kawamuray / wasmtime-java

Java or JVM-language binding for Wasmtime
Apache License 2.0
128 stars 29 forks source link

Support Windows? #1

Closed SuperIceCN closed 3 years ago

SuperIceCN commented 3 years ago

I notice that wasmtime-java has not supported windows yet. I think run on Windows device will be great. By the way, Wasmtime has support windows yet.

kawamuray commented 3 years ago

Yeah it's great to have windows support indeed. The reason it doesn't have windows support now is that I don't have any windows environment. If someone can add and test windows support I'm happy to merge it :) It should be easy enough to extend the CI to include prebuilt binary by adding extra os here. Additionally some build configuration needs to be modified to stop assuming filesystems path uses slash as a delimiter.

SuperIceCN commented 3 years ago

Thanks! Maybe I can give it a try.

SuperIceCN commented 3 years ago

@kawamuray I successfuly build a universal jar with windows support. It works well and passes all tests. But I don't know how to use gradle so I built it manually (I have never used gradle before). It seems that build.gradle cannot run on my windows10 computer even if I changed all "/" to "\". The jar I built manually is here: https://github.com/Superice666/wasmtime-java/releases/tag/v0.1.0-windows

kawamuray commented 3 years ago

I successfuly build a universal jar with windows support.

cool :)

don't know how to use gradle so I built it manually (I have never used gradle before). It seems that build.gradle cannot run on my windows10 computer even if I changed all

can you share the diff and detail of the error you've faced while running gradlew.bat universalJar (I've never ran gradle on windows but assume this is the right command line to kick the build)?

SuperIceCN commented 3 years ago

It prints that:


Configure project : Evaluating root project 'wasmtime-java' using build file 'D:\nukkit\wasmtime-java\build.gradle'.

FAILURE: Build failed with an exception.

BUILD FAILED in 974ms


I have push the build.gradle file to my fork. Is there any mistake?

SuperIceCN commented 3 years ago

@kawamuray It seems that we cannot use java4h on Windows platform. Windows cannot identify java4h as a executable programme. image

kawamuray commented 3 years ago

Could not find method environment() for arguments

This happens because you've commented out type: Exec. In gradle (groovy), a closure has implicit default receiver for methods called inside of it, hence the statement environment x, y is actually an invocation of defaultReceiver(of type Exec).environment(). https://github.com/Superice666/wasmtime-java/commit/d49fa463aff33b8847bb17e865a394da40c85ab9#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7R89

Windows cannot identify java4h as a executable programme.

Ugh, right. javah4x's binary is actually an shell script that contains it's JAR binary inside of it. So it can't be executed on environment that doesn't support running /bin/bash. Possible solutions would be:

btw regarding this advice:

Additionally some build configuration needs to be modified to stop assuming filesystems path uses slash as a delimiter.

I turned out that java takes care of implicitly converting path into platform specific type for unix-style path that uses slash as the delimiter, so it seems not necessary fixing around all paths that is in unix style now to build on windows. ref: https://stackoverflow.com/questions/3548775/platform-independent-paths-in-java ref: https://www.sghill.net/how-do-i-make-cross-platform-file-paths-in-java.html

SuperIceCN commented 3 years ago

@kawamuray Thanks for your advice! I just managed to fix it build.gradle and push it to my fork. In addition, I added windows to github action CI by the way. You can see it here: https://github.com/Superice666/wasmtime-java/runs/1541057245?check_suite_focus=true I think it's ok to merge it now.

kawamuray commented 3 years ago

nice :) let me review your patch on #2 then.

kawamuray commented 3 years ago

Closed by #2