-
-
Notifications
You must be signed in to change notification settings - Fork 619
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
Show error messages from broken includes #2264
Show error messages from broken includes #2264
Conversation
- Display the error message returned from loadfile(), which includes the file and line information (necessary for nested includes!), as well as the specific error that was encountered.
Integrated PR feedback: - It can be assumed that err is not nil if compiled_chunk is nil (confirmed with the lua docs) - Check if the file was located before trying to load it, so we can display a descriptive error message with the alternate names that were searched - Improved the error messages by addubg the file/line information where the include originated, similar to the output of a compiler. The `res` is not output to the error message as in every case it was already part of the error message that was returned and that resulted in very long, repetitive errors
Depending on the specific error, sometimes code will load but be unable to execute, throwing an error. This now catches (pcall, "protected call") it and displays an appropriate error message, including the file that was included and where the include originated from.
@samsinsane:
Embed scripts seems problematic (when not called from repository) local res = os.locate(fname, with_ext, p5, p4)
- res = res or fname Not sure if issue was in |
@Jarod42 I'm having trouble reproducing this error, do you have a minimal repro script? |
I got it for any script on my side :-/ (outside of premake-core repo) Try to move binary outside of repository, so |
@Jarod42 sorry, I hadn't rerun the |
@Jarod42 @samsinsane : hrm, I'm not sure how I haven't hit that in my testing & usage?! As you can see from my earlier comment on this PR, I did test with internal scripts (
@Jarod42 : I'm not sure how you're hitting this and I'm not, but could you perhaps make a PR for a unit test that repos it, so I can work on a proper fix? I'm wondering if this is a Linux-only issue, as your CI was running on Linux, but I'm testing on Windows. |
@Jarod42 : wait... how... wha... ok. Your CI is building premake with -DPREMAKE_NO_BUILTIN_SCRIPTS, so nothing's being embedded, and you'll never have a const buildin_mapping* premake_find_embedded_script(const char* filename)
{
#if !defined(PREMAKE_NO_BUILTIN_SCRIPTS)
int i;
for (i = 0; builtin_scripts[i].name != NULL; ++i) {
if (strcmp(builtin_scripts[i].name, filename) == 0) {
return builtin_scripts + i;
}
}
#endif
return NULL;
} I'm trying to understand the differences between |
@richard-sim I've merged the fix. premake-core/src/host/lua_auxlib.c Lines 48 to 72 in 910c1c5
The change I suggested in this PR prevents |
@samsinsane : ah, thanks for clearing that up - appreciated! It might be good to add a comment to both that I'm still confused how @Jarod42 is hitting this though, as he's building premake with no embedded scripts ( |
That's just how the Premake Lines 109 to 113 in 910c1c5
Once it builds the bootstrap binary, it builds the proper Premake5 binary with everything enabled. |
No, it happens on all platforms Ubuntu/Windows/MacOS
In fact, my whole premake integrating testing repo fails, and also premake modules (as premake-ninja)
I use the Bootstrap.mak, which seems to be the official way to release version. |
What does this PR do?
Displays the error message returned from loadfile(), which includes the file and line information (necessary for nested includes!), as well as the specific error that was encountered.
How does this PR change Premake's behavior?
Rather than the generic "Cannot find..." message, if there's error information available it's now displayed:
Before:
Error: ** Error: Cannot find either foobar/L0a or foobar/L0a.lua or foobar/L0a/premake5.lua or foobar/L0a/premake4.lua
After:
Error: ** Error: Cannot load foobar/L0a: D:/dev/build-sys-eval/foobar/src/foobar/L0a/premake5.lua:7: '(' expected near '['
Anything else we should know?
Nope, it's a simple one but really, REALLY helps!
Did you check all the boxes?
closes #XXXX
in comment to auto-close issue when PR is merged)