ialex32x / unity-jsb

It brings Javascript runtime capability to Unity3D by integrating QuickJS.
MIT License
337 stars 43 forks source link

Build on Linux Support #44

Open asalvo opened 3 years ago

asalvo commented 3 years ago

I'm using GitHub Actions (Linux agent) and the Game-CI docker image (Linux based) to build a Unity app that has Unity JSB. I am targeting Stand Alone Windows x64 and Stand Alone OSX during the build.

During the build, I am getting the following exception for the windows target

QuickJS.Native.JSApi..cctor () (at Assets/jsb/Source/Native/JSApi.cs:877)
Rethrow as TypeInitializationException: The type initializer for 'QuickJS.Native.JSApi' threw an exception.
QuickJS.Unity.JSScriptableObject.ReleaseJSValues () (at Assets/jsb/Source/Unity/JSScriptableObject.cs:71)
QuickJS.Unity.JSScriptableObject.OnDisable () (at Assets/jsb/Source/Unity/JSScriptableObject.cs:395)
UnityEditor.EditorApplication:Exit(Int32)
UnityBuilderAction.Reporting.StdOutReporter:ExitWithResult(BuildResult) (at Assets/Editor/Editor/UnityBuilderAction/Reporting/StdOutReporter.cs:31)
UnityBuilderAction.Builder:BuildProject() (at Assets/Editor/Editor/UnityBuilderAction/Builder.cs:77)

exception when the target is OSX

DllNotFoundException: quickjs
  at (wrapper managed-to-native) QuickJS.Native.JSApi.JSB_ATOM_Proxy()
  at QuickJS.Native.JSApi..cctor () [0x00059] in /github/workspace/projects/ProjectName/Assets/jsb/Source/Native/JSApi.cs:877 
Rethrow as TypeInitializationException: The type initializer for 'QuickJS.Native.JSApi' threw an exception.
  at QuickJS.Unity.JSScriptableObject.ReleaseJSValues () [0x00010] in /github/workspace/projects/ProjectName/Assets/jsb/Source/Unity/JSScriptableObject.cs:71 
  at QuickJS.Unity.JSScriptableObject.OnDisable () [0x00007] in /github/workspace/projects/ProjectName/Assets/jsb/Source/Unity/JSScriptableObject.cs:395 
UnityEditor.EditorApplication:Exit(Int32)
UnityBuilderAction.Reporting.StdOutReporter:ExitWithResult(BuildResult) (at Assets/Editor/Editor/UnityBuilderAction/Reporting/StdOutReporter.cs:31)
UnityBuilderAction.Builder:BuildProject() (at Assets/Editor/Editor/UnityBuilderAction/Builder.cs:77)

I'm assuming that this is because there is no QuickJS native dependency for Linux. Would it be possible for you to build and include a Linux version of Quick JS?

ialex32x commented 3 years ago

OK, I'll build and check it later this weekend.

ialex32x commented 3 years ago

Hi asalo, I'd tried to run dotnetcore sample in Ubuntu 20.04 LTS with no exception. So the linux build of quickjs library is OK. I think it's a bug of the building process in Unity, I'll keep trying to fix it.

ialex32x commented 3 years ago

Is it possible that this error is caused by the different glibc version of linux os? It seems that glibc 2.29+ is required for the current build of quickjs.

ialex32x commented 3 years ago

I think this issue is caused by the different version of glibc, because I used the ubuntu-latest to build quickjs in Github Actions. I've rebuilt it by ubuntu 18.04 LTS (which contains glibc 2.27 by default).

asalvo commented 3 years ago

If glibc 2.29 or later is required then that would explain the problem. While the Github Action runner I am using is running Unbuntu 20.04 LTS and has glibc 2.29, the Game-CI provided docker image is based on Unbuntu 18.04 and only has glibc 2.27. It appears that the recommended solution for getting glibc 2.29 on Unbutu 18.04 is to upgrade to 20.04 ;)