NLua / NLua

Bridge between Lua and the .NET.
http://nlua.org
MIT License
2.05k stars 309 forks source link

Request support for godot #451

Open wenbingzhang opened 2 years ago

wenbingzhang commented 2 years ago

When exporting Android, lua runtimes could not be exported correctly. There is no IOS test.

https://github.com/godotengine/godot

wenbingzhang commented 2 years ago

Similar to this question https://github.com/NLua/NLua/issues/407

wenbingzhang commented 2 years ago

csproj

    <PropertyGroup>
        <TargetFramework>net472</TargetFramework>
        <Configurations>Debug;ExportDebug;ExportRelease;Release</Configurations>
        <Platforms>AnyCPU</Platforms>
    </PropertyGroup>
viniciusjarina commented 2 years ago

I am not familiar with Godot toolchain. But the Android so is included in the KeraLua nuget package

wenbingzhang commented 2 years ago

I have feedback on Godot https://github.com/godotengine/godot/issues/60167

wenbingzhang commented 2 years ago

I am not familiar with Godot toolchain. But the Android so is included in the KeraLua nuget package

Android is working properly now.

macos Mono' cannot call lib in' xxx.app/Contents/Frameworks' . Custom support "LuaLibraryName" is required to work properly.

Godot features https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_features.html

wenbingzhang commented 2 years ago

@viniciusjarina
Can I add it here? https://github.com/NLua/KeraLua/blob/1b422ebd3451ccfa55331bb7b638d686de582b3b/src/NativeMethods.cs#L27 Godot define all start with "GODOT_xxxx"

See "define" in the detailed connection. https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_features.html

viniciusjarina commented 2 years ago

I don't understand, why do you have to build from source? Isn't mono embedding the latest version of Mono? It should work out of the box with the prebuilt NuGet don't ?

wenbingzhang commented 2 years ago

I don't understand, why do you have to build from source? Isn't mono embedding the latest version of Mono? It should work out of the box with the prebuilt NuGet don't ?

#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
        private const string LuaLibraryName = "@rpath/liblua54.framework/liblua54";
#elif __ANDROID__
        private const string LuaLibraryName = "liblua54.so";
#elif __MACOS__ 
        private const string LuaLibraryName = "liblua54.dylib";
#elif WINDOWS_UWP
        private const string LuaLibraryName = "lua54.dll";
#else
        private const string LuaLibraryName = "lua54";
#endif

Because godot can't add these conditional compilation parameters, The final value is the default value.

wenbingzhang commented 2 years ago

I don't understand, why do you have to build from source? Isn't mono embedding the latest version of Mono? It should work out of the box with the prebuilt NuGet don't ?

#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
        private const string LuaLibraryName = "@rpath/liblua54.framework/liblua54";
#elif __ANDROID__
        private const string LuaLibraryName = "liblua54.so";
#elif __MACOS__ 
        private const string LuaLibraryName = "liblua54.dylib";
#elif WINDOWS_UWP
        private const string LuaLibraryName = "lua54.dll";
#else
        private const string LuaLibraryName = "lua54";
#endif

Because godot can't add these conditional compilation parameters, The final value is the default value.

I misunderstood it.

viniciusjarina commented 2 years ago

😕 I still don't follow. I thought you could just do dotnet add package https://godotengine.org/qa/118789/can-i-install-nuget-packages-in-the-c%23-version-of-godot on godot.

Also, if you are building from the source why can't you define <DefineConstants>__IOS__</DefineConstants> ?

wenbingzhang commented 2 years ago

😕 I still don't follow. I thought you could just do dotnet add package https://godotengine.org/qa/118789/can-i-install-nuget-packages-in-the-c%23-version-of-godot on godot.

Also, if you are building from the source why can't you define <DefineConstants>__IOS__</DefineConstants> ?

This has no effect.

wenbingzhang commented 2 years ago
"/usr/local/bin/dotnet" msbuild "/Users/xxxx/Documents/Project/Godot/test/Test.sln" /restore /t:Build "/p:Configuration=Debug" /v:normal "/l:GodotTools.BuildLogger.GodotBuildLogger,/Applications/Godot_mono.app/Contents/Resources/GodotSharp/Tools/GodotTools.BuildLogger.dll;/Users/xxxx/Library/Application Support/Godot/mono/build_logs/4b80f109a1a1ece08b7c9fb849e34cde_Debug" /p:GodotTargetPlatform=osx

正在将文件从“/Users/xxxx/.nuget/packages/nlua/1.6.0/lib/net46/NLua.dll”复制到“/Users/xxxx/Documents/Project/Godot/test/.mono/temp/bin/Debug/NLua.dll”。 正在将文件从“/Users/xxxx/.nuget/packages/keralua/1.3.1/lib/net46/KeraLua.dll”复制到“/Users/xxxx/Documents/Project/Godot/test/.mono/temp/bin/Debug/KeraLua.dll”。

Copy the dll of net46.

wenbingzhang commented 2 years ago

Godot_mono needs to export mac osx to have problems.