1
0
mirror of https://github.com/lxsang/antd-lua-plugin synced 2025-02-13 15:02:48 +01:00

fix ld conflict

This commit is contained in:
lxsang 2020-01-01 21:17:46 +01:00
parent f7599cd935
commit 2f026c3273
5 changed files with 27 additions and 9 deletions

View File

@ -1,7 +1,7 @@
EXTRA_DIST = lua-5.3.4/*.c lua-5.3.4/*.h lua-5.3.4/Makefile EXTRA_DIST = lua-5.3.4/*.c lua-5.3.4/*.h lua-5.3.4/Makefile
all: all:
cd lua-5.3.4 && make linux cd $(top_srcdir)/3rd/lua-5.3.4 && make linux
clean-local: clean-local:
cd lua-5.3.4 && make clean cd $(top_srcdir)/3rd/lua-5.3.4 && make clean

View File

@ -27,7 +27,7 @@ MYOBJS=
# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE =======
PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
LUA_SO = core.so
LUA_A= liblua.a LUA_A= liblua.a
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \ CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \ lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
@ -43,8 +43,8 @@ LUAC_T= luac
LUAC_O= luac.o LUAC_O= luac.o
ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
ALL_A= $(LUA_A) ALL_A= $(LUA_A) $(LUA_SO)
# Targets start here. # Targets start here.
default: $(PLAT) default: $(PLAT)
@ -59,6 +59,9 @@ $(LUA_A): $(BASE_O)
$(AR) $@ $(BASE_O) $(AR) $@ $(BASE_O)
$(RANLIB) $@ $(RANLIB) $@
$(LUA_SO): $(BASE_O)
gcc -shared $(BASE_O) -o $@
$(LUA_T): $(LUA_O) $(LUA_A) $(LUA_T): $(LUA_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)

View File

@ -21,7 +21,6 @@ lua_la_SOURCES = plugin-wrapper.c\
array-wrapper.c \ array-wrapper.c \
json-wrapper.c \ json-wrapper.c \
lua-api.c lua-api.c
lua_la_LIBADD = $(srcdir)/3rd/lua-5.3.4/liblua.a
# lua libraris & modules # lua libraris & modules
SUBDIRS = 3rd . lib SUBDIRS = 3rd . lib
@ -34,4 +33,5 @@ EXTRA_DIST = README.md 3rd/jsmn/jsmn.h APIs lua-api.h
install-data-local: install-data-local:
mkdir -p $(prefix)/lib/lua mkdir -p $(prefix)/lib/lua
cp -v APIs/* $(prefix)/lib/lua cp -v APIs/* $(prefix)/lib/lua
cp -v 3rd/lua-5.3.4/core.so $(prefix)/lib/lua

BIN
dist/lua-0.5.2b.tar.gz vendored

Binary file not shown.

View File

@ -1,6 +1,9 @@
#define PLUGIN_IMPLEMENT 1 #define PLUGIN_IMPLEMENT 1
#include <dlfcn.h>
#include "lua-api.h" #include "lua-api.h"
static void* core_handle = NULL;
static const struct luaL_Reg modules [] = { static const struct luaL_Reg modules [] = {
#ifdef USE_DB #ifdef USE_DB
{"sqlite", luaopen_sqlite}, {"sqlite", luaopen_sqlite},
@ -14,7 +17,17 @@ static const struct luaL_Reg modules [] = {
void init() void init()
{ {
LOG("%s \n","INIT LUA HANDLER"); char* path = __s("%s/lua/core.so", __plugin__.pdir);
core_handle = dlopen(path, RTLD_NOW| RTLD_GLOBAL);
if(!core_handle)
{
ERROR("Cannot load Lua core; %s", dlerror());
}
else
{
LOG("Lua core loaded");
}
free(path);
} }
/** /**
@ -111,5 +124,7 @@ void* handle(void* data)
} }
void destroy() void destroy()
{ {
LOG("%s \n","Exit LUA Handle"); if(core_handle)
dlclose(core_handle);
LOG("Exit LUA Handle");
} }