Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed luasocket, add mobdebug and --debugger command line option #1020

Merged
merged 12 commits into from
Apr 7, 2018
Merged

Embed luasocket, add mobdebug and --debugger command line option #1020

merged 12 commits into from
Apr 7, 2018

Conversation

redorav
Copy link
Collaborator

@redorav redorav commented Mar 17, 2018

Embed luasocket as a static library
Add mobdebug lua script to allow debugging premake with ZeroBrane Studio
Add --debugger command line option to enable debugging

redorav added 4 commits March 17, 2018 14:47
Add mobdebug lua script to allow debugging premake with ZeroBrane Studio
Add --debugger command line option to enable debugging
…defined as __attribute__((visibility(\"default\"))) on all platforms except Windows
Copy link
Member

@starkos starkos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your commit titles could be a little more succinct, but that's nitpicking, and it otherwise looks good to me. @samsinsane, what do you think? Any objection to merging another library?

@redorav
Copy link
Collaborator Author

redorav commented Mar 20, 2018

There's just one thing I wasn't sure of which is putting mobdebug.lua at the root of the premake folder. I couldn't get it to work any other way, but that's just my inexperience with lua I guess. I can spend a bit more time trying to figure it out. How does updating branches work? If I update the luasocket branch does the PR 'reset' waiting for approval again?

Regarding the commit messages I can try summarizing a bit more :)

Copy link
Member

@samsinsane samsinsane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, as I mentioned in another PR, I'm more in favour of pushing contribs to submodules. Given the complexities of doing so (GitHub Releases don't produce source archives with submodule source) I think this is fine. There's just so much noise in the PR, commit tree, contribution statistics and what not, but it's not the end of the world more of a mild inconvenience of software development. (GitLab sometimes has nice graphs for some statistics, but GitHub doesn't have them - probably because they provide absolutely no value and just look nice lol)

I've approved it, but the rename is a little confusing and I'd prefer it wasn't done if it's not required. Kind of nitpicky though, so happy to merge as-is.

"src/wsocket.*",
}

defines { "LUASOCKET_API=__attribute__((visibility(\"default\")))" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, files should end with an empty line - specifically an empty line, not a blank line with indentation. That's what this two red emojis are all about here. Apparently some tools in the "*nix" world assume text files end with an empty line, and searching for LUASOCKET_API would not flag this file due to that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'll fix this up with a newline then

@@ -9,7 +9,7 @@
#include "premake.h"
#include "buffered_io.h"

void buffer_init(Buffer* b)
void buffer_initialize(Buffer* b)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this was renamed?

Copy link
Collaborator Author

@redorav redorav Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

luasocket has a function with the same name, and C doesn't allow function aliases as I figured out (I'm used to C++ so that took me by surprise) so in the interest of minimal changes I renamed it.

@starkos
Copy link
Member

starkos commented Mar 23, 2018

There's just one thing I wasn't sure of which is putting mobdebug.lua at the root of the premake folder.

I figured that was an issue with the debugger itself. I don't have any objection to this myself, and it can always be moved later if there is a need/way.

@tvandijck
Copy link
Contributor

This might be a bit more complicated, and extra work at this point, but I did create the "lua shim" for this purpose, so that LuaRocks can easily be ported for the premake lua interpreter.

Quite honestly, I would prefer it if the "lua socket" library was compiled as a "binary module", you'll find an example of that here:

it would make loading the .dll more optional, and not impact the premake5.exe with the added embedded code, and you wouldn't have to rename those buffer methods either.

Anyway, since I'm a little out of the loop, I'm not going to request changes here, but I figured I'd at least give you all my preferred approach.... and it's always something that can be changed later on as well.

@starkos
Copy link
Member

starkos commented Mar 26, 2018

What do you think of @tvandijck's suggestions, @redorav? Could you take a crack at splitting it out into a module?

@redorav
Copy link
Collaborator Author

redorav commented Mar 26, 2018

@starkos @tvandijck Sorry for not replying earlier, it's being a busy week and weekend, I can take a look at the suggested solution of adding it as binary module, I'll first have to understand what they are and how they work. I thought defining it out would be optional enough for people who don't want to add the library, but I can certainly understand wanting to integrate it differently.

@redorav
Copy link
Collaborator Author

redorav commented Mar 30, 2018

@tvandijck I've managed to build luasocket as a dll and exported the main function called luaopen_socket_core, but when it comes to calling require(), I can't figure out how to do the equivalent of

luaL_requiref(L, "socket", luaopen_socket_core, 1)

that I used when building as a static library. It seems like it will look for a dll of the same name and tries to match the function somehow but all variations of the name always return an error. I have been able to call require('example') with the example.dll in the same directory, so I must be almost there.

EDIT: Ah, never mind, I just realized I have to load the luashim before loading any libs, which means creating my own luaopen_luasocket function instead of using luaopen_socket_core directly from the luasocket code. It's all working now :)

@redorav
Copy link
Collaborator Author

redorav commented Apr 2, 2018

@starkos Feel free to review this when you have a bit of time. I managed to get it working and didn't spend too much time on it. The solution ends up being pretty much the same except with a dll instead of a binary, which is fine. I'll have to update the wiki steps I've written to make it clear but should be ok.

One thing I didn't manage was outputting a good error message when luasocket isn't found. When calling require("luasocket") if the call fails I can't retrieve the return value to output something with it. Is there any multiplatform functionality in premake I can use to determine whether a given dynamic library exists alongside premake?

@tvandijck
Copy link
Contributor

I like it this way for sure... thank you for taking the time to make this change.

@tvandijck tvandijck merged commit 2ac3153 into premake:master Apr 7, 2018
@redorav redorav deleted the luasocket branch April 17, 2018 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants