Improve repl and make output more consistent with raylib 3.0
Fix building issues. Check for duplicated entries.
This commit is contained in:
parent
1e911f4a05
commit
aa786270b5
@ -14,7 +14,7 @@
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
]]
|
||||
|
||||
print "[RAYLUA] Raylua boot script"
|
||||
print "RAYLUA: Raylua boot script"
|
||||
|
||||
local ffi = require "ffi"
|
||||
local C = ffi.C
|
||||
@ -822,15 +822,20 @@ do
|
||||
local i = ffi.new("size_t", 0)
|
||||
local NULL = ffi.new("void *", nil)
|
||||
|
||||
print "[RAYLUA] Loading FFI binding entries."
|
||||
print "RAYLUA: Loading FFI binding entries."
|
||||
|
||||
while entries[i].name ~= NULL do
|
||||
local name, proto = ffi.string(entries[i].name), ffi.string(entries[i].proto)
|
||||
|
||||
if rl[name] then
|
||||
print("RAYLUA: Warn: Duplicated FFI entry : " .. name)
|
||||
end
|
||||
|
||||
rl[name] = ffi.cast(proto, entries[i].ptr)
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
print("[RAYLUA] Loaded " .. tonumber(i) .. " FFI entries.")
|
||||
print("RAYLUA: Loaded " .. tonumber(i) .. " FFI entries.")
|
||||
end
|
||||
|
||||
-- colors
|
||||
|
10
src/raylua.c
10
src/raylua.c
@ -21,6 +21,16 @@
|
||||
#include <raylib.h>
|
||||
#include <rlgl.h>
|
||||
|
||||
#include <raymath.h>
|
||||
#include <easings.h>
|
||||
#include <camera.h>
|
||||
#include <gestures.h>
|
||||
|
||||
#define RAYGUI_SUPPORT_ICONS
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#define RAYGUI_STATIC
|
||||
#include <raygui.h>
|
||||
|
||||
#define PHYSAC_IMPLEMENTATION
|
||||
#define PHYSAC_NO_THREADS
|
||||
#include <physac.h>
|
||||
|
@ -17,12 +17,17 @@
|
||||
local load = loadstring
|
||||
|
||||
function raylua.repl()
|
||||
print ">> raylua WIP repl <<"
|
||||
print "> raylua v3.0a <"
|
||||
print "Type 'q' to quit."
|
||||
print ""
|
||||
|
||||
while true do
|
||||
io.write "> "
|
||||
local line = io.read "l"
|
||||
if line == "q" then
|
||||
break
|
||||
end
|
||||
|
||||
local f, err = loadstring(line)
|
||||
|
||||
if f then
|
||||
@ -57,7 +62,7 @@ if raylua.loadfile then
|
||||
return
|
||||
end
|
||||
|
||||
print "[RAYLUA] Load main.lua from payload."
|
||||
print "RAYLUA: Load main.lua from payload."
|
||||
require "main"
|
||||
|
||||
if not raylua.isrepl then
|
||||
@ -72,6 +77,6 @@ if arg[1] then
|
||||
end
|
||||
|
||||
if raylua.isrepl then
|
||||
print "[RAYLUA] Go to repl."
|
||||
print "RAYLUA: Go to repl."
|
||||
raylua.repl()
|
||||
end
|
||||
|
@ -126,7 +126,7 @@ static int raylua_builder_add(lua_State *L)
|
||||
|
||||
if (!mz_zip_writer_add_file(&builder->zip, dest, path, NULL, 0,
|
||||
MZ_BEST_COMPRESSION))
|
||||
printf("Unable to write %s (%s)\n", dest, path);
|
||||
printf("BUILDER: > Unable to write %s (%s)\n", dest, path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -48,10 +48,8 @@ local append_file_offset = ffi.cast("void (*)(FILE *, FILE *, FILE *)", append_f
|
||||
local self_path = arg[0]
|
||||
local input_path = arg[1]
|
||||
|
||||
print ">> Raylua builder <<"
|
||||
print "BUILDER: Initialized builder"
|
||||
if #arg == 0 then
|
||||
print "TODO: Improve builder usage."
|
||||
|
||||
print "Usage: raylua_e <input> [output]"
|
||||
return
|
||||
end
|
||||
@ -66,7 +64,7 @@ if ffi.os == "Windows" and self_path:sub("-4") ~= ".exe" then
|
||||
self_path = self_path .. ".exe"
|
||||
end
|
||||
|
||||
print("Self is " .. self_path)
|
||||
print("BUILDER: Self is " .. self_path)
|
||||
|
||||
if t == "directory" then
|
||||
local output = arg[2]
|
||||
@ -81,7 +79,7 @@ if t == "directory" then
|
||||
end
|
||||
end
|
||||
|
||||
print("Building " .. output)
|
||||
print("BUILDER: Building " .. output)
|
||||
|
||||
local builder = builder_new(self_path, output)
|
||||
assert(builder, "Can't initialize builder")
|
||||
@ -108,13 +106,13 @@ if t == "directory" then
|
||||
local t = get_type(full_file_path)
|
||||
|
||||
if t == "file" then
|
||||
print("Adding file " .. partial_file_path)
|
||||
print("BUILDER: +> " .. partial_file_path)
|
||||
builder_add(builder, full_file_path, partial_file_path)
|
||||
elseif t == "directory" then
|
||||
print("Adding directory " .. partial_file_path .. "/")
|
||||
print("BUILDER: /> " .. partial_file_path .. "/")
|
||||
add_dir(root, partial_file_path)
|
||||
else
|
||||
print("Unknown file type " .. partial_file_path)
|
||||
print("BUILDER: ?> " .. partial_file_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -123,7 +121,7 @@ if t == "directory" then
|
||||
add_dir(input_path, nil)
|
||||
|
||||
if not have_main then
|
||||
print("WARN: main.lua is missing, your executable may not run")
|
||||
print("BUILDER: WARN: main.lua is missing, your executable may not run")
|
||||
end
|
||||
|
||||
builder_close(builder)
|
||||
@ -139,10 +137,10 @@ elseif t == "file" then
|
||||
path = path .. ".elf"
|
||||
end
|
||||
|
||||
print("Building " .. path)
|
||||
print("BUILDER: Building " .. path)
|
||||
|
||||
if ext == ".zip" then
|
||||
print "Build from zip file."
|
||||
print "BUILDER: Building from zip file."
|
||||
|
||||
local dest = assert(io.open(path, "wb"), "Can't open destination file.")
|
||||
local source = assert(io.open(self_path, "rb"), "Can't open self file.")
|
||||
@ -154,7 +152,7 @@ elseif t == "file" then
|
||||
source:close()
|
||||
input:close()
|
||||
elseif ext == ".lua" then
|
||||
print "Build from lua file."
|
||||
print "BUILDER: Building from lua file."
|
||||
|
||||
local builder = builder_new(self_path, path)
|
||||
builder_add(builder, input_path, "main.lua")
|
||||
@ -162,4 +160,4 @@ elseif t == "file" then
|
||||
end
|
||||
end
|
||||
|
||||
print "Done"
|
||||
print "BUILDER: Done"
|
||||
|
@ -77,7 +77,7 @@ static bool raylua_init_payload(const char *path, bool direct)
|
||||
FILE *f = fopen(path, "rb");
|
||||
|
||||
if (f == NULL) {
|
||||
puts("[RAYLUA] Can't load self.");
|
||||
puts("RAYLUA: Can't load self.");
|
||||
return false;
|
||||
} else {
|
||||
/* Read offset at the end of the file */
|
||||
@ -101,7 +101,7 @@ int main(int argc, const char **argv)
|
||||
luaL_openlibs(L);
|
||||
|
||||
if (L == NULL)
|
||||
puts("[RAYLUA] Unable to initialize Lua.");
|
||||
puts("RAYLUA: Unable to initialize Lua.");
|
||||
|
||||
/* Populate arg. */
|
||||
lua_newtable(L);
|
||||
@ -126,16 +126,16 @@ int main(int argc, const char **argv)
|
||||
strcpy(new_path, path);
|
||||
strcpy(new_path + path_len, ".exe");
|
||||
|
||||
printf("[RAYLUA] Translated self executable name from %s to %s.\n", path, new_path);
|
||||
printf("RAYLUA: Translated self executable name from %s to %s.\n", path, new_path);
|
||||
path = new_path;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!raylua_init_payload(path, false)) {
|
||||
#ifdef RAYLUA_NO_BUILDER
|
||||
puts("[RAYLUA] No payload.");
|
||||
puts("RAYLUA: No payload.");
|
||||
#else
|
||||
puts("[RAYLUA] No payload, use internal builder.");
|
||||
puts("RAYLUA: No payload, use internal builder.");
|
||||
raylua_builder_boot(L);
|
||||
#endif
|
||||
} else {
|
||||
|
@ -30,7 +30,7 @@ int main(int argc, const char **argv)
|
||||
luaL_openlibs(L);
|
||||
|
||||
if (L == NULL)
|
||||
puts("[RAYLUA] Unable to initialize Lua.");
|
||||
puts("RAYLUA: Unable to initialize Lua.");
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user