pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.6k stars 519 forks source link

support luau #1129

Open keszegh opened 2 years ago

keszegh commented 2 years ago

Gideros is considering moving from lua to luau. I hope to be able to continue using ZBS when/if this switch happens.

See luau info: https://luau-lang.org/

See discussion here and here: https://forum.giderosmobile.com/discussion/comment/66096#Comment_66096 https://forum.giderosmobile.com/discussion/8498/can-anyone-teach-me-how-to-debug-with-zerobrane-studio#latest

keszegh commented 2 years ago

perhaps this seems to be a bit early to worry about this switch, yet it would be reassuring to know if zbs can follow if needs be.

pkulchenko commented 2 years ago

@keszegh, thank you for the pointer to the discussions. I looked at luau when it was announced and don't see from the list of changes why it wouldn't work with mobdebug (assuming luasocket is available as well and can be loaded), but I haven't had a chance to actually test it yet. I'll update the ticket when I get a chance to get it running.

pkulchenko commented 2 years ago

Actually, it's going to be difficult, as I just compiled luau and it looks to be really locked down (which makes sense for Roblox), but maybe doesn't make sense for other environments, as it doesn't allow loading dynamic libraries (or at least luasocket doesn't load for me), which makes debugging a non-starter. Also loadstring is not available either, which prevents any code evaluation (either in the remote console or as a watch eval). There is a discussion about compiling luasocket and loadstring, so there is still some hope to get it working.

keszegh commented 2 years ago

thanks, let me know if you have more info about it. good to know that there is some hope. feel free to join the discussion also here: https://forum.giderosmobile.com/discussion/8518/luau-discussion#latest

hgy29 commented 2 years ago

@pkulchenko, Gideros version of Luau will be a bit less restricted than standard Luau: it will have loadfile, loadstring, luasocket (as a plugin). But it seems luau also removed a few debug api calls, in particular hooks, which will be difficult to replace.

pkulchenko commented 2 years ago

Right; hooks would need to be brought back for the debugging to work. It's good to hear that the Gideros version of luau will have those additional elements restored.

keszegh commented 2 years ago

perhaps debugging features could be added without hooks etc?: https://luau-lang.org/performance "Luau does not support hooks at all, and relies on first-class support for breakpoints (using bytecode patching) and single-stepping (using a custom interpreter loop) to implement debugging."

pkulchenko commented 2 years ago

@keszegh, if you find details on how their client looks like and what protocol they use, I can look at that, but from what I've seen so far (assuming it's based on the breakpoint patch that was discussed on the maillist or is at least similar to it), the interaction with the debugger is going to be quite different.

keszegh commented 2 years ago

the luau based version of gideros is public.

keszegh commented 2 years ago

since the switch to luau, there are some things not working that i think they could: -when opening the gideros player from zbs and then closing it, then when trying to open it again then it closes itself right after. one has to manually kill gdrdaemon task so that zbs can start the player. -it would be nice to have live logging, now the printed messages only appear once the player is closed. thanks -long term of course recovering the debugging features would be very good, i miss them already

scrumit commented 2 years ago

+1 from me, I’m finding the enhanced syntax checking that luau provides to Gideros invaluable.

I’m sure it will be of benefit to ZBS. Do you realise Roblox has over 12 million games and 7 million game developers ? Stats

hgy29 commented 2 years ago

I managed to get debugging working back in Gideros Studio, but that's using native API. It comes to my mind that several interaction issues between ZBS and Gideros could be solved by implementing Gideros Player network protocol in ZBS. I can write a connector in lua (using luasocket) to expose its API, which includes:

hgy29 commented 2 years ago

Here is a connector module, if that can help. gideros_protocol.zip

pkulchenko commented 2 years ago

@hgy29, thank you for sharing! This looks very interesting and similar to the approach I took to integrate with Redis debugging where the module itself launches a proxy that the IDE debugger interacts with and the proxy actually issues commands that the Redis debugger understand (over TCP). I wonder if something similar is possible in this case.

The main debug loop starts here and shows a minimal set of commands that need to be handled. I don't see some of these commands in the gideros_protocol implementation (for example, how do I get stack information) and some details are not quite clear to me (how do I set breakpoins at a particular file/line)?

@hgy29, @keszegh, is it something you may be interested in trying to implement following the model in the redis plugin I referenced? You can implement it as a separate plugin and I'll find a way to merge it together with the current interpreter implementation (especially if there is a way to detect the version of Gideros that uses luau).

Just to add a couple more details on the redis plugin model that can work here. Basically the plugin itself is also a script that can be launched to be used as a proxy, so the plugin takes its configuration and when run/debug commands are executed, it launches the proxy script, which takes commands from the IDE and passes them on to the application it controls (Redis or Gideros), using whatever protocol is necessary in this case.

scrumit commented 2 years ago

Great stuff, I was going to look at the Redis plug-in for ZBS for my back end.

I notice that supports 2.0.5 and Redis on GitHub is 6.2.6.

keszegh commented 2 years ago

i'd be happy to give some practical help, but my expertise allows me only to test if there is something to test. i hope zbs+gideros will work soon though.

keszegh commented 2 years ago

any news? @hgy29 claims that the gideros_protocol.zip should be able to help make the connection work. sadly i'm still not knowledgeable about the details. minimally while debugging is not working, these two should be possible to be corrected i guess earlier: -when opening the gideros player from zbs and then closing it, then when trying to open it again then it closes itself right after. one has to manually kill gdrdaemon task so that zbs can start the player. -it would be nice to have live logging, now the printed messages only appear once the player is closed.

btw about the first issue my workaround is that i currently run the following bat file between two runs of the gideros player: C:\Windows\System32\taskkill.exe /f /IM gdrdeamon.exe

keszegh commented 1 year ago

this issue is still open, it's sad that zbs cannot debug anymore gideros projects. (alas a release version of zbs from time to time would be nice even if there is no major addition). let me again emphasize the two things that should minimally work: -when opening the gideros player from zbs and then closing it, then when trying to open it again then it closes itself right after. one has to manually kill gdrdaemon task so that zbs can start the player. -it would be nice to have live logging, now the printed messages only appear once the player is closed.

keszegh commented 11 months ago

a new release version is most welcome. sadly it does not address any of the most major issues concerning gideros (need to kill gdrdaemon manually, no live print logging).

pkulchenko commented 11 months ago

@keszegh, it does not. I don't have a ready to use solutions to integrate, but if you have some changes that you think may help with providing some of that functionality, I'll review and add them.

keszegh commented 11 months ago

i have no expertise at all, perhaps @hgy29 can help at least with these relatively simple issues? (let alone debugging itself)

hgy29 commented 11 months ago

I tried to work on this, but I have to admit that I failed to understand how to set up ZBS for use with Gideros, I mean which files I need to change/update. That's mostly because I am not a ZBS user at all I guess. And while @pkulchenko gave a few pointers about how this could be done for debugging, I think it doesn't cover launching the player, getting the logs and other stuff like that. I am ready to have a go at, but I don't know where to start.

keszegh commented 11 months ago

i can still just mediate, in any case it would probably be easiest to discuss this on the gideros forum where you are welcome @pkulchenko. i made a new thread for this issue: https://forum.giderosmobile.com/discussion/8701/update-zerobranestudio-to-support-luau-based-gideros-versions#latest

hgy29 commented 7 months ago

@pkulchenko, we made some progress on Gideros side, adding back needed debug api for mobdebug. See thread here: https://forum.gideros.rocks/discussion/comment/68692/#Comment_68692.