feat: add lua-compat-5.3 dependency#4
Conversation
|
In the PR it looks like the compat is just being compiled into the binary. Have you tried running any Lua scripts with the shell that have 5.1 and 5.2 specific features? I tried doing something like this and was noticing scripts still fail to execute so I wasn't sure if you have to manually develop some kind of shim using the compat library to enable particular globals. |
You know, you raise a good point lol Idk why I thought just compiling it with the binary was enough |
|
I noticed I also put the wrong compat repo on accident.....The newest (and more reliable) version is from lunarmodules I straight up spent an hour working through linker errors, running grep, cc, etc, religiously, only to find out, I was importing the wrong repo. |
|
No worries, if you need help with anything feel free to lmk. |
|
@BanceDev I've got it working. I ended up making a lisp script for diagnostics. And, after I finally got compat to work, I started running individual functions in a compat_test.lua script via the lisp script. I deduced a bug in the lush.c main block. Specifically, the non-interactive mode. It was reusing a complex shell command parser for a simple (non-interactive) task. Looking at the issue with running scripts non-interactively (e.g., The Problem: The Solution: Here's the code change I'm proposing for the // This is the corrected logic for running a script file non-interactively.
if (argc > 1) {
char *ext = strrchr(argv[1], '.');
if (ext && strcmp(ext, ".lua") == 0) {
const char *script_name = argv[1];
// The arguments for the script start at argv[2].
// We create a pointer to that part of the array.
char **script_args = (argc > 2) ? &argv[2] : NULL;
// Call the script loader directly with the script and its arguments.
if (lua_load_script(L, script_name, script_args) != 0) {
exit(1); // Exit if the script had an error
}
lua_close(L); // Clean up and exit
return 0;
}
}Lisp DiagnosticsHere you can see how it's supposed to look when I run the ros REPL and pass [arandre@Johnny lush]$ ros run
* (load "build-tracer.lisp")
T
* (build-tracer:run-full-suite)
;;; --- Starting Full Build & Test Suite ---
;;; [Stage: premake5] Running command: premake5 gmake ...
Building configurations...
Running action 'gmake'...
Done (42ms).
;;; [Stage: premake5] Succeeded.
;;; [Stage: make] Running command: make clean ...
Cleaning lush
;;; [Stage: make] Succeeded.
;;; [Stage: make] Running command: make ...
==== Building lush (debug) ====
Creating obj/Debug
builtins.c
compat-5.3.c
hashmap.c
history.c
lua_api.c
lush.c
Linking lush
;;; [Stage: make] Succeeded.
;;; Build Succeeded.
;;; --- Running Tests ---
;;; Running: (/home/arandre/projects/c-projects/lush/bin/Debug/lush/lush
compat_test.lua)
;;; Test Complete. Exit Code: 0
--- STDOUT ---
--- Running all compatibility tests ---
--- Running test: math.log with base ---
...SUCCESS!
--- Running test: string.rep with separator ---
...SUCCESS!
--- Running test: table.unpack ---
...SUCCESS!
--- All tests complete ---
--- STDERR ---
[C] Script not found: /home/arandre/.lush/init.lua
NIL
* (build-tracer:run-test "test_table_unpack")
;;; --- Running Tests ---
;;; Running: (/home/arandre/projects/c-projects/lush/bin/Debug/lush/lush
compat_test.lua test_table_unpack)
;;; Test Complete. Exit Code: 0
--- STDOUT ---
--- Running test: table.unpack ---
...SUCCESS!
--- STDERR ---
[C] Script not found: /home/arandre/.lush/init.lua
NIL
*While previously, before fixing the main block: [arandre@Johnny lush]$ ros run
* (load "build-tracer.lisp")
T
* (build-tracer:run-full-suite)
;;; --- Starting Full Build & Test Suite ---
;;; [Stage: premake5] Running command: premake5 gmake ...
Building configurations...
Running action 'gmake'...
Done (32ms).
;;; [Stage: premake5] Succeeded.
;;; [Stage: make] Running command: make clean ...
Cleaning lush
;;; [Stage: make] Succeeded.
;;; [Stage: make] Running command: make ...
==== Building lush (debug) ====
Creating obj/Debug
builtins.c
compat-5.3.c
hashmap.c
history.c
lua_api.c
lush.c
Linking lush
;;; [Stage: make] Succeeded.
;;; Build Succeeded.
;;; --- Running Tests ---
;;; Running: (/home/arandre/projects/c-projects/lush/bin/Debug/lush/lush
compat_test.lua)
;;; Test Complete. Exit Code: 0
--- STDOUT ---
--- Running all compatibility tests ---
--- Running test: math.log with base ---
...SUCCESS!
--- Running test: table.unpack ---
...SUCCESS!
--- Running test: string.rep with separator ---
...SUCCESS!
--- All tests complete ---
--- STDERR ---
[C] Script not found: /home/arandre/.lush/init.lua
NIL
* (build-tracer:run-test "test_table_unpack")
;;; --- Running Tests ---
;;; Running: (/home/arandre/projects/c-projects/lush/bin/Debug/lush/lush
compat_test.lua test_table_unpack)
;;; Test Complete. Exit Code: 0
--- STDOUT ---
--- Running all compatibility tests ---
--- Running test: string.rep with separator ---
...SUCCESS!
--- Running test: table.unpack ---
...SUCCESS!
--- Running test: math.log with base ---
...SUCCESS!
--- All tests complete ---
--- STDERR ---
[C] Script not found: /home/arandre/.lush/init.lua
NIL
*Notice how when I run I'll request a merge tomorrow. I have to commit/push what I have into my fork, and also I need to clean up my fork's branches, because rn its a mess. Once it's organized, I'll send a merge request, and then we can proceed however needed. Let me know what you think! EDIT: P.s: incase you didn't know, "ros" is short-form for "roswell". Just a lisp environment manager and REPL. |
|
This all looks really solid! Thanks for catching that bug as well. I'll review the merge request once you send it up and we can get this changes added. |



Hello! This pull request adds
lua-compat-5.3as a dependency.This should help improve compatibility for users on different Lua versions, as discussed in issue #3. The dependency is added as a submodule and integrated into the
premake5.luabuild script. I had tested it locally with:Additional Notes:
I might actually end up making more merge requests in the future, if you're fine with additional merges(?)
I don't have any particular ideas at the moment, but I'll probably attempt to exapand the API a little, if that's something you're comfortable with.