diff options
| author | ruki <[email protected]> | 2021-09-18 00:53:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-18 00:53:16 +0800 |
| commit | eb826246511e2afca394302aecccdf18d02a297f (patch) | |
| tree | 93cf7403e809670a594225774a4a39f82b5de0c7 /core/src | |
| parent | 56393682b43020adcff47de00fe7a011ba5f1584 (diff) | |
fix compile for lua
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/demo/makefile | 10 | ||||
| -rw-r--r-- | core/src/lua-cjson/makefile | 10 | ||||
| -rw-r--r-- | core/src/xmake/engine.c | 2 | ||||
| -rw-r--r-- | core/src/xmake/sandbox/interactive.c | 5 |
4 files changed, 24 insertions, 3 deletions
diff --git a/core/src/demo/makefile b/core/src/demo/makefile index 1a2142db5..93525ddaf 100644 --- a/core/src/demo/makefile +++ b/core/src/demo/makefile @@ -20,10 +20,20 @@ demo_INC_DIRS += ../ ../tbox/tbox/src ../tbox/inc/$(PLAT) demo_LIB_DIRS += ../tbox # luajit +ifeq ($(BACKEND),luajit) luajit_LIBS := $(if $(findstring luajit,$(base_LIBNAMES)),,luajit$(DTYPE)) demo_LIBS += $(luajit_LIBS) demo_INC_DIRS += ../luajit/luajit/src demo_LIB_DIRS += ../luajit +endif + +# lua +ifeq ($(BACKEND),lua) +lua_LIBS := $(if $(findstring lua,$(base_LIBNAMES)),,lua$(DTYPE)) +demo_LIBS += $(lua_LIBS) +demo_INC_DIRS += ../lua/lua +demo_LIB_DIRS += ../lua +endif # sv sv_DTYPE := $(if $(findstring sv,$(base_LIBNAMES)),,$(DTYPE)) diff --git a/core/src/lua-cjson/makefile b/core/src/lua-cjson/makefile index 9e96851ae..e1d53ecf9 100644 --- a/core/src/lua-cjson/makefile +++ b/core/src/lua-cjson/makefile @@ -22,8 +22,14 @@ lua-cjson_C_FILES += \ lua-cjson_CFLAGS += -DNDEBUG -DUSE_INTERNAL_FPCONV # includes -lua-cjson_INC_DIRS += \ - ../luajit/luajit/src +ifeq ($(BACKEND),luajit) +lua-cjson_INC_DIRS += ../luajit/luajit/src +lua-cjson_CXFLAGS += -DUSE_LUAJIT +endif +ifeq ($(BACKEND),lua) +lua-cjson_INC_DIRS += ../lua/lua +lua-cjson_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 +endif # use given system library? lua-cjson_C_FILES := $(if $(findstring cjson,$(base_LIBNAMES)),,$(lua-cjson_C_FILES)) diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 6a401a486..53732e783 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -814,7 +814,7 @@ xm_engine_ref_t xm_engine_init(tb_char_t const* name, xm_engine_lni_initalizer_c tb_strlcpy(engine->name, name, sizeof(engine->name)); // init lua - engine->lua = lua_open(); + engine->lua = luaL_newstate(); tb_assert_and_check_break(engine->lua); // open lua libraries diff --git a/core/src/xmake/sandbox/interactive.c b/core/src/xmake/sandbox/interactive.c index 2519a58e8..29855aec6 100644 --- a/core/src/xmake/sandbox/interactive.c +++ b/core/src/xmake/sandbox/interactive.c @@ -314,6 +314,7 @@ tb_int_t xm_sandbox_interactive(lua_State* lua) // execute codes if (status == 0) { +#ifdef USE_LUAJIT /* bind sandbox * * stack: arg1(top) scriptfunc arg1(sandbox_scope) -> ... @@ -326,6 +327,10 @@ tb_int_t xm_sandbox_interactive(lua_State* lua) * stack: arg1(top) scriptfunc -> ... */ status = xm_sandbox_docall(lua, 0, 0); +#else + // TODO + (void)xm_sandbox_docall; +#endif } // report errors |
