This commit is contained in:
2024-07-21 22:35:38 -04:00
parent b7b31abc0e
commit 455b329c58
17 changed files with 491 additions and 0 deletions

13
lua/Makefile Normal file
View File

@@ -0,0 +1,13 @@
include ../config.mk
all:
@echo "Run 'make test' to generate a test binary."
@echo "Run 'make clean' to remove the generated binary."
test:
$(CC) -I/usr/include/lua5.2 \
-Wall -llua \
lua.c -o lua.test
clean:
rm lua.test

37
lua/lua.c Normal file
View File

@@ -0,0 +1,37 @@
#include <color.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
const wchar_t check = 0x2713;
int
main(int argc, char **argv)
{
printf(COL_BLUE "[i] " COL_RESET "Initializing Lua state...\n");
lua_State *L = luaL_newstate();
luaL_openlibs(L);
printf(COL_BLUE "[i] " COL_RESET "Loading test package...\n");
if (luaL_loadfile(L, "testpkg.lua")) {
fprintf(stderr, COL_RED "[x] " COL_RESET "Failed to load test package file.\n");
lua_close(L);
exit(1);
}
printf(COL_BLUE "[i] " COL_RESET "Executing test package...\n");
if (lua_pcall(L, 0, 0, 0)) {
fprintf(stderr, COL_RED "[x] " COL_RESET "Failed to execute test package file.\n");
lua_close(L);
exit(1);
}
lua_close(L);
printf("Closed lua libraries\n");
return 0;
}

BIN
lua/lua.test Executable file

Binary file not shown.

3
lua/testpkg.lua Normal file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/lua
print("Executed lua file")