luasocket now loading properly

I still haven't tried actually running it.
This commit is contained in:
Kartik K. Agaram 2021-11-20 23:34:29 -08:00
parent 02acfa7c9c
commit 548d59f918
6 changed files with 12 additions and 6 deletions

View File

@ -29,7 +29,7 @@ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
kilo.o
LIB_O= lauxlib.o lbaselib.o menu.o ldblib.o liolib.o lmathlib.o \
loslib.o ltablib.o lstrlib.o loadlib.o linit.o \
lcurses/curses.o luasocket/socket.a
lcurses/curses.o
LUA_T= teliva
LUA_O= lua.o
@ -50,11 +50,11 @@ o: $(ALL_O)
a: $(ALL_A)
$(LUA_A): $(CORE_O) $(LIB_O)
$(AR) $@ $(CORE_O) $(LIB_O) # DLL needs all object files
$(AR) $@ $(CORE_O) $(LIB_O)
$(RANLIB) $@
$(LUA_T): $(LUA_O) $(LUA_A)
$(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
$(LUA_T): $(LUA_O) $(LUA_A) luasocket/socket.a
$(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) luasocket/socket.a $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
@ -122,7 +122,7 @@ solaris:
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl"
# list targets that do not create files (but not all makes understand .PHONY)
.PHONY: all $(PLATS) default o a clean depend echo none
.PHONY: all $(PLATS) default o a clean depend echo none luasocket/socket.a
# DO NOT DELETE

View File

@ -23,6 +23,7 @@ static const luaL_Reg lualibs[] = {
{LUA_STRLIBNAME, luaopen_string},
{LUA_MATHLIBNAME, luaopen_math},
{LUA_CURSESLIBNAME, luaopen_curses},
{LUA_SOCKETCORELIBNAME, luaopen_socket_core},
{LUA_DBLIBNAME, luaopen_debug},
{NULL, NULL}
};

View File

@ -674,6 +674,8 @@ static int pmain (lua_State *L) {
luaL_openlibs(L); /* open libraries */
status = dorequire(L, "src/lcurses/curses.lua", "curses");
if (status != 0) return 0;
status = dorequire(L, "src/luasocket/socket.lua", "socket");
if (status != 0) return 0;
lua_gc(L, LUA_GCRESTART, 0);
s->status = handle_luainit(L);
if (s->status != 0) return 0;

View File

@ -36,6 +36,9 @@ LUALIB_API int (luaopen_math) (lua_State *L);
#define LUA_CURSESLIBNAME "curses"
LUALIB_API int (luaopen_curses) (lua_State *L);
#define LUA_SOCKETCORELIBNAME "socket"
LUALIB_API int (luaopen_socket_core) (lua_State *L);
#define LUA_DBLIBNAME "debug"
LUALIB_API int (luaopen_debug) (lua_State *L);

View File

@ -100,5 +100,6 @@ LUASOCKET_API int luaopen_socket_core(lua_State *L) {
int i;
base_open(L);
for (i = 0; mod[i].name; i++) mod[i].func(L);
lua_setglobal(L, "socket");
return 1;
}

View File

@ -9,7 +9,6 @@
local base = _G
local string = require("string")
local math = require("math")
local socket = require("socket.core")
local _M = socket