diff options
| author | ruki <[email protected]> | 2023-01-19 23:36:22 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-01-19 23:36:22 +0800 |
| commit | b653884db6a9403f3ec8306f49420c5c4f1c660c (patch) | |
| tree | adac630dc10897ec60bc90ed28dc6c58570b3052 | |
| parent | 685000fcb6d6eed642e3b56b345dc25caec999c4 (diff) | |
improve lua-cjson option
| -rw-r--r-- | core/src/xmake/xmake.lua | 5 | ||||
| -rwxr-xr-x | core/src/xmake/xmake.sh | 11 | ||||
| -rw-r--r-- | core/xmake.lua | 16 | ||||
| -rwxr-xr-x | core/xmake.sh | 31 |
4 files changed, 22 insertions, 41 deletions
diff --git a/core/src/xmake/xmake.lua b/core/src/xmake/xmake.lua index d770c129f..d4e11040e 100644 --- a/core/src/xmake/xmake.lua +++ b/core/src/xmake/xmake.lua @@ -2,12 +2,15 @@ target("xmake") set_kind("static") -- add deps - add_deps("sv", "lua-cjson", "lz4", "tbox") + add_deps("sv", "lz4", "tbox") if is_config("runtime", "luajit") then add_deps("luajit") else add_deps("lua") end + if has_config("lua_cjson") then + add_deps("lua-cjson") + end if is_plat("windows") and has_config("pdcurses") then add_deps("pdcurses") end diff --git a/core/src/xmake/xmake.sh b/core/src/xmake/xmake.sh index 709ff525b..06170e5bc 100755 --- a/core/src/xmake/xmake.sh +++ b/core/src/xmake/xmake.sh @@ -13,21 +13,16 @@ target "xmake" add_deps "$lib" fi done + if has_config "lua_cjson" && ! has_config "external"; then + add_deps "lua_cjson" + fi if is_config "runtime" "luajit"; then - if has_config "lua_cjson"; then - add_options "lua_cjson" "{public}" - elif ! has_config "external"; then - add_deps "lua_cjson" - fi if has_config "luajit"; then add_options "luajit" "{public}" elif ! has_config "external"; then add_deps "luajit" fi else - if ! has_config "external"; then - add_deps "lua_cjson" - fi if has_config "lua"; then add_options "lua" "{public}" elif ! has_config "external"; then diff --git a/core/xmake.lua b/core/xmake.lua index af92e54ea..b3c8bbed6 100644 --- a/core/xmake.lua +++ b/core/xmake.lua @@ -50,15 +50,19 @@ end -- the runtime option option("runtime") - set_showmenu(true) set_default("lua") set_description("Use luajit or lua runtime") set_values("luajit", "lua") option_end() +-- the lua-cjson option +option("lua_cjson") + set_default(true) + set_description("Use lua-cjson as json parser") +option_end() + -- the readline option option("readline") - set_showmenu(true) set_description("Enable or disable readline library") add_links("readline") add_cincludes("readline/readline.h") @@ -68,7 +72,6 @@ option_end() -- the curses option option("curses") - set_showmenu(true) set_description("Enable or disable curses library") add_links("curses") add_cincludes("curses.h") @@ -78,7 +81,6 @@ option_end() -- the pdcurses option option("pdcurses") set_default(true) - set_showmenu(true) set_description("Enable or disable pdcurses library") add_defines("PDCURSES") add_defines("XM_CONFIG_API_HAVE_CURSES") @@ -87,7 +89,6 @@ option_end() -- only build xmake libraries for development? option("onlylib") set_default(false) - set_showmenu(true) set_description("Only build xmake libraries for development") option_end() @@ -98,7 +99,10 @@ if is_plat("windows") then end -- add projects -includes("src/lua-cjson", "src/sv", "src/lz4", "src/tbox", "src/xmake", "src/demo") +includes("src/sv", "src/lz4", "src/tbox", "src/xmake", "src/demo") +if has_config("lua_cjson") then + includes("src/lua-cjson") +end if is_config("runtime", "luajit") then includes("src/luajit") else diff --git a/core/xmake.sh b/core/xmake.sh index d464b2862..af43f2ec1 100755 --- a/core/xmake.sh +++ b/core/xmake.sh @@ -38,6 +38,9 @@ option "runtime" "Use luajit or lua runtime" "lua" # always use external dependencies option "external" "Always use external dependencies" false +# use lua-cjson? +option "lua_cjson" "Use lua-cjson as json parser" true + # the readline option option "readline" add_links "readline" @@ -78,29 +81,6 @@ void test() {\n }" option_end -# the lua-cjson option, only for luajit/lua5.1 -option "lua_cjson" - add_defines "XM_CONFIG_API_HAVE_LUA_CJSON" - before_check "option_find_lua_cjson" - add_csnippets " -int luaopen_cjson(void *l);\n -void test() {\n - luaopen_cjson(0);\n -} -" -option_end - -option_find_lua_cjson() { - local ldflags="" - option "lua_cjson" - ldflags=`pkg-config --libs luajit 2>/dev/null` - if test_nz "${ldflags}"; then - ldflags="-llua5.1-cjson ${ldflags}" - fi - add_ldflags "${ldflags}" - option_end -} - # the lua option option "lua" add_cfuncs "lua_pushstring" @@ -213,13 +193,12 @@ if ! has_config "external"; then if ! has_config "luajit"; then includes "src/luajit" fi - if ! has_config "lua_cjson"; then - includes "src/lua-cjson" - fi else if ! has_config "lua"; then includes "src/lua" fi + fi + if has_config "lua_cjson"; then includes "src/lua-cjson" fi if ! has_config "lz4"; then |
