From 19f8192150b7be4322e77e54f201c580d3e9869d Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 5 Dec 2017 00:28:30 +0800 Subject: register curses --- core/src/demo/makefile | 6 +++--- core/src/lcurses/lcurses.c | 5 ++++- core/src/lcurses/makefile | 7 +++++-- core/src/lcurses/xmake.lua | 5 +++-- core/src/xmake/config.h | 4 ++-- core/src/xmake/machine.c | 11 +++++++++++ core/src/xmake/makefile | 1 + core/src/xmake/xmake.lua | 8 ++++---- 8 files changed, 33 insertions(+), 14 deletions(-) (limited to 'core/src') diff --git a/core/src/demo/makefile b/core/src/demo/makefile index 6c573677b..5b79e8d4c 100644 --- a/core/src/demo/makefile +++ b/core/src/demo/makefile @@ -14,9 +14,9 @@ demo_C_FILES += xmake demo_PKGS-$(BASE) += base # others -demo_LIBS += xmake$(DTYPE) tbox$(DTYPE) luajit$(DTYPE) sv$(DTYPE) -demo_INC_DIRS += ../ ../tbox/src ../tbox/inc/$(PLAT) ../luajit/src ../sv/include -demo_LIB_DIRS += ../xmake ../tbox ../luajit ../sv +demo_LIBS += xmake$(DTYPE) lcurses$(DTYPE) tbox$(DTYPE) luajit$(DTYPE) sv$(DTYPE) +demo_INC_DIRS += ../ ../tbox/src ../tbox/inc/$(PLAT) ../luajit/src ../sv/include +demo_LIB_DIRS += ../xmake ../tbox ../luajit ../sv ../lcurses demo_CXFLAGS += -D__tb_prefix__=\"xmake\" # suffix diff --git a/core/src/lcurses/lcurses.c b/core/src/lcurses/lcurses.c index 8f791c18a..026d737e7 100644 --- a/core/src/lcurses/lcurses.c +++ b/core/src/lcurses/lcurses.c @@ -59,6 +59,8 @@ Notes: mostly for cui usage. ************************************************************************/ +#ifdef XM_CONFIG_API_HAVE_CURSES + #include #include #include @@ -2305,7 +2307,7 @@ static const luaL_reg curseslib[] = }; -int luaopen_cui_curses (lua_State *L) +int xm_curses_register (lua_State *L) { /* ** create new metatable for window objects @@ -2415,3 +2417,4 @@ static void init_ascii_map() ascii_map[252] = 110; ascii_map[253] = 50; ascii_map[254] = ACS_BULLET; ascii_map[255] = 32; } +#endif diff --git a/core/src/lcurses/makefile b/core/src/lcurses/makefile index a7be7933c..3fcd7e19e 100644 --- a/core/src/lcurses/makefile +++ b/core/src/lcurses/makefile @@ -10,9 +10,12 @@ lcurses_TYPE = LIB # config lcurses_CONFIG = n -# core files +# curses files lcurses_C_FILES += lcurses - + +# curses flags +lcurses_CXFLAGS += $(if $(findstring curses,$(base_LIBNAMES)),-DXM_CONFIG_API_HAVE_CURSES,) + # includes lcurses_INC_DIRS += ../luajit/src diff --git a/core/src/lcurses/xmake.lua b/core/src/lcurses/xmake.lua index a63f2aa7e..24dd528aa 100644 --- a/core/src/lcurses/xmake.lua +++ b/core/src/lcurses/xmake.lua @@ -15,5 +15,6 @@ target("lcurses") -- add the common source files add_files("*.c") - - + + -- add options + add_options("curses") diff --git a/core/src/xmake/config.h b/core/src/xmake/config.h index 978456b18..5150880e6 100644 --- a/core/src/xmake/config.h +++ b/core/src/xmake/config.h @@ -22,8 +22,8 @@ * @file config.h * */ -#ifndef XM_GBOX_CONFIG_H -#define XM_GBOX_CONFIG_H +#ifndef XM_CORE_CONFIG_H +#define XM_CORE_CONFIG_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index 6d26c445d..c98bf1be1 100644 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -132,6 +132,11 @@ tb_int_t xm_semver_parse(lua_State* lua); tb_int_t xm_semver_satisfies(lua_State* lua); tb_int_t xm_semver_select(lua_State* lua); +#ifdef XM_CONFIG_API_HAVE_CURSES +// register curses +tb_int_t xm_curses_register(lua_State* lua); +#endif + /* ////////////////////////////////////////////////////////////////////////////////////// * globals */ @@ -486,6 +491,12 @@ xm_machine_ref_t xm_machine_init() // bind semver functions luaL_register(impl->lua, "semver", g_semver_functions); +#ifdef XM_CONFIG_API_HAVE_CURSES + // bind curses + xm_curses_register(impl->lua); + lua_setglobal(impl->lua, "curses"); +#endif + // init host #if defined(TB_CONFIG_OS_WINDOWS) lua_pushstring(impl->lua, "windows"); diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index ee3062634..a8afcd30d 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -69,6 +69,7 @@ xmake_C_FILES += \ # flags xmake_CXFLAGS += -D__tb_prefix__=\"xmake\" xmake_CXFLAGS += $(if $(findstring readline,$(base_LIBNAMES)),-DXM_CONFIG_API_HAVE_READLINE,) +xmake_CXFLAGS += $(if $(findstring curses,$(base_LIBNAMES)),-DXM_CONFIG_API_HAVE_CURSES,) # includes xmake_INC_DIRS += \ diff --git a/core/src/xmake/xmake.lua b/core/src/xmake/xmake.lua index 176409194..bfe67e79d 100644 --- a/core/src/xmake/xmake.lua +++ b/core/src/xmake/xmake.lua @@ -5,7 +5,7 @@ target("xmake") set_kind("static") -- add deps - add_deps("sv", "luajit", "tbox") + add_deps("lcurses", "sv", "luajit", "tbox") -- add defines add_defines("__tb_prefix__=\"xmake\"") @@ -24,7 +24,7 @@ target("xmake") -- add the common source files add_files("**.c") - - -- add cfunc - add_cfunc("API", "readline", "readline", {"readline/readline.h"}, "readline") + + -- add options + add_options("curses", "readline") -- cgit v1.3.1