Tencent / xLua

xLua is a lua programming solution for C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.
Other
9.4k stars 2.45k forks source link

发布webgl #386

Closed 724789975 closed 6 years ago

724789975 commented 6 years ago

xlua支持webgl吗 我发布webgl生成时报错

Failed running "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten_Win\python\2.7.5.3_64bit\python.exe" "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc" @"F:\FxLib\Client_Unity\Test\Assets..\Temp\emcc_arguments.resp"

stdout: stderr:WARNING:root:--separate-asm works best when compiling to HTML. otherwise, you must yourself load the '.asm.js' file that is emitted separately, and must do so before loading the main '.js` file In file included from F:\FxLib\Client_Unity\Test\Assets\Plugins\WebGL\xlua_webgl.cpp:36: F:\FxLib\Client_Unity\Test\Assets\Plugins\WebGL/../../../WebGLPlugins/perflib.c:172:57: warning: comparison of array 'ar.short_src' not equal to a null pointer is always true [-Wtautological-pointer-compare] snprintf(used_in, sizeof(used_in) - 1, "%s:%d~%d", ar.short_src != NULL ? ar.short_src : "", ar.linedefined, ar.lastlinedefined);


1 warning generated.
warning: unexpected return type void in call to 'lua_rawget', should be i32
warning: unexpected return type void in call to 'lua_setmetatable', should be i32
warning: unexpected number of arguments 4 in call to '_ZN6il2cpp6icalls8mscorlib6System6String22RedirectToCreateStringEv', should be 0
warning: unexpected number of arguments 4 in call to '_ZN6il2cpp6icalls8mscorlib6System6String22RedirectToCreateStringEv', should be 0
warning: unexpected number of arguments 2 in call to '_ZN6il2cpp6icalls8mscorlib6System6String22RedirectToCreateStringEv', should be 0
warning: unexpected number of arguments 3 in call to '_ZN6il2cpp6icalls8mscorlib6System6String22RedirectToCreateStringEv', should be 0
warning: unexpected return type void in call to 'lua_atpanic', should be i32 (%struct.lua_State*)*
error: unresolved symbol: luaopen_socket_coreAborting compilation due to previous errors | undefinedTraceback (most recent call last):
  File "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc", line 13, in <module>
    emcc.run()
  File "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc.py", line 1670, in run
    final = shared.Building.emscripten(final, append_ext=False, extra_args=extra_args)
  File "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\tools\shared.py", line 1745, in emscripten
    call_emscripten(cmdline)
  File "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 1842, in _main
    temp_files.run_and_clean(lambda: main(
  File "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\tools\tempfiles.py", line 78, in run_and_clean
    return func()
  File "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 1847, in <lambda>
    DEBUG=DEBUG,
  File "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 1748, in main
    temp_files=temp_files, DEBUG=DEBUG)
  File "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 93, in emscript
    glue, forwarded_data = compiler_glue(metadata, settings, libraries, compiler_engine, temp_files, DEBUG)
  File "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 296, in compiler_glue
    cwd=path_from_root('src'), error_limit=300)
  File "C:\Program Files\Unity2017.3.f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\tools\jsrun.py", line 122, in run_js
    raise Exception('Expected the command ' + str(command) + ' to finish with return code ' + str(assert_returncode) + ', but it returned with code ' + str(proc.returncode) + ' instead! Output: ' + str(ret)[:error_limit])
Exception: Expected the command ['C:/Program Files/Unity2017.3.f1/Editor/Data\\Tools\\nodejs\\node.exe', '--stack_size=8192', '--max-old-space-size=4096', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\Emscripten\\src\\compiler.js', 'F:\\FxLib\\Client_Unity\\Test\\Temp\\EmscriptenTemp\\tmptzceiz.txt', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Audio.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Cursor.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Eval.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\FileSystem.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Logging.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Profiler.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\SystemInfo.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\UnetWebSocket.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Video.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\WebCam.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\WebGL.js', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\WebRequest.js', 'F:\\FxLib\\Client_Unity\\Test\\Assets\\Plugins\\WebSocket.jslib', 'F:\\FxLib\\Client_Unity\\Test\\Assets\\Plugins\\H5.jslib', 'C:\\Program Files\\Unity2017.3.f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\Emscripten\\src\\library_pthread_stub.js'] to finish with return code 0, but it returned with code 1 instead! Output: // The Module object: Our interface to the outside world. We import
// and export values on it, and do the work to get that through
// closure compiler if necessary. There are various ways Module can be used:
// 1. Not defined. We create it here
// 2. A function parameter, function(Module) { ..gener
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
724789975 commented 6 years ago

附 WebSocket.jslib var LibraryWebSockets = { $webSocketInstances: [],

SocketCreate: function(url) { var str = Pointer_stringify(url); var socket = { socket: new WebSocket(str), buffer: new Uint8Array(0), error: null, messages: [] }

socket.socket.binaryType = 'arraybuffer';

socket.socket.onmessage = function (e) {
    // Todo: handle other data types?
    if (e.data instanceof Blob)
    {
        var reader = new FileReader();
        reader.addEventListener("loadend", function() {
            var array = new Uint8Array(reader.result);
            socket.messages.push(array);
        });
        reader.readAsArrayBuffer(e.data);
    }
    else if (e.data instanceof ArrayBuffer)
    {
        var array = new Uint8Array(e.data);
        socket.messages.push(array);
    }
    else if (typeof e.data === "string")
    {
        var reader = new FileReader();
        reader.addEventListener("loadend", function(){
        var array = new Uint8Array(reader.result);
        socket.messages.push(array);
        });
        var blob = new Blob([e.data]);
        reader.readAsArrayBuffer(blob);
    }
};

socket.socket.onclose = function (e) {
    if (e.code != 1000)
    {
        if (e.reason != null && e.reason.length > 0)
            socket.error = e.reason;
        else
        {
            switch (e.code)
            {
                case 1001: 
                    socket.error = "Endpoint going away.";
                    break;
                case 1002: 
                    socket.error = "Protocol error.";
                    break;
                case 1003: 
                    socket.error = "Unsupported message.";
                    break;
                case 1005: 
                    socket.error = "No status.";
                    break;
                case 1006: 
                    socket.error = "Abnormal disconnection.";
                    break;
                case 1009: 
                    socket.error = "Data frame too large.";
                    break;
                default:
                    socket.error = "Error "+e.code;
            }
        }
    }
}
var instance = webSocketInstances.push(socket) - 1;
return instance;

},

SocketState: function (socketInstance) { var socket = webSocketInstances[socketInstance]; return socket.socket.readyState; },

SocketError: function (socketInstance, ptr, bufsize) { var socket = webSocketInstances[socketInstance]; if (socket.error == null) return 0; var str = socket.error.slice(0, Math.max(0, bufsize - 1)); stringToUTF8(str, ptr, Math.max(0, bufsize - 1)); // writeStringToMemory(str, ptr, false); return 1; },

SocketSend: function (socketInstance, ptr, length) { var socket = webSocketInstances[socketInstance]; socket.socket.send (HEAPU8.buffer.slice(ptr, ptr+length)); },

SocketRecvLength: function(socketInstance) { var socket = webSocketInstances[socketInstance]; if (socket.messages.length == 0) return 0; return socket.messages[0].length; },

SocketRecv: function (socketInstance, ptr, length) { var socket = webSocketInstances[socketInstance]; if (socket.messages.length == 0) return 0; if (socket.messages[0].length > length) return 0; HEAPU8.set(socket.messages[0], ptr); socket.messages = socket.messages.slice(1); },

SocketClose: function (socketInstance) { var socket = webSocketInstances[socketInstance]; socket.socket.close(); } };

autoAddDeps(LibraryWebSockets, '$webSocketInstances'); mergeInto(LibraryManager.library, LibraryWebSockets);

H5.jslib mergeInto(LibraryManager.library, { GetUrl: function () { var url = window.document.location.href; var bufferSize = lengthBytesUTF8(url) + 1; var buffer = _malloc(bufferSize); stringToUTF8(url, buffer, bufferSize); return buffer; }, LogStr: function(str) { console.log(Pointer_stringify(str)); }, AlertString: function(str) { window.alert(Pointer_stringify(str)); }, });

chexiongsheng commented 6 years ago

没有每个版本都试,但至少这个版本当时是发布过webgl应用的:https://github.com/Tencent/xLua/releases/tag/v2.1.10

724789975 commented 6 years ago

我试了一下 在development build模式下 生成失败 关闭development build生成成功 我使用的版本是2.1.11 另 之前有个警告 WebGLPlugins/perflib.c:172:57: warning: comparison of array 'ar.short_src' not equal to a null pointer is always true [-Wtautological-pointer-compare] snprintf(used_in, sizeof(used_in) - 1, "%s:%d~%d", ar.short_src != NULL ? ar.short_src : "", ar.linedefined, ar.lastlinedefined);

suntabu commented 4 years ago

我也遇到了在development build模式下 生成失败,需要用development来使用Profiler