diff options
| author | ruki <[email protected]> | 2022-12-17 20:27:08 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-12-17 20:27:52 +0800 |
| commit | 5d7efff981b2bb2c8806eb57354a73dac7ccd2f1 (patch) | |
| tree | 4f52d578a8d2e31f116a73da6ff0acfb527326ee /core | |
| parent | 6bea48d5f42e1baf8cc2a6080ca5cf62aaac9766 (diff) | |
find lua
Diffstat (limited to 'core')
| -rwxr-xr-x | core/src/lua-cjson/xmake.sh | 6 | ||||
| -rwxr-xr-x | core/src/xmake/xmake.sh | 11 | ||||
| -rwxr-xr-x | core/xmake.sh | 32 |
3 files changed, 34 insertions, 15 deletions
diff --git a/core/src/lua-cjson/xmake.sh b/core/src/lua-cjson/xmake.sh index 7ee38cc10..42e767218 100755 --- a/core/src/lua-cjson/xmake.sh +++ b/core/src/lua-cjson/xmake.sh @@ -4,7 +4,11 @@ target "lua_cjson" set_kind "static" set_default false set_warnings "all" - add_deps "lua" + if has_config "lua"; then + add_options "lua" "{public}" + else + add_deps "lua" + fi add_files "lua-cjson/dtoa.c" add_files "lua-cjson/lua_cjson.c" add_files "lua-cjson/strbuf.c" diff --git a/core/src/xmake/xmake.sh b/core/src/xmake/xmake.sh index 46cb36ca1..2fc04b8e4 100755 --- a/core/src/xmake/xmake.sh +++ b/core/src/xmake/xmake.sh @@ -5,8 +5,15 @@ target "xmake" set_default false # add deps - add_deps "sv" "lua" "lz4" "tbox" - add_lua_cjson + add_deps "sv" "lz4" "tbox" + local libs="lua_cjson lua" + for lib in $libs; do + if has_config "$lib"; then + add_options "$lib" "{public}" + else + add_deps "$lib" + fi + done # add defines add_defines "__tb_prefix__=\"xmake\"" diff --git a/core/xmake.sh b/core/xmake.sh index 56d511bf9..1528d3400 100755 --- a/core/xmake.sh +++ b/core/xmake.sh @@ -52,15 +52,29 @@ void test() {\n } " option_end -add_lua_cjson() { - if has_config "lua_cjson"; then - add_links "lua5.1-cjson" "{public}" - else - add_deps "lua_cjson" - fi + +# the lua option +option "lua" + add_cfuncs "lua_pushstring" + add_cincludes "lua.h" "lualib.h" "lauxlib.h" + before_check "option_find_lua" +option_end + +option_find_lua() { + option "lua" + add_cflags `pkg-config --cflags lua5.4 2>/dev/null` + add_ldflags `pkg-config --libs lua5.4 2>/dev/null` + option_end } # add projects +if ! has_config "lua"; then + if is_config "runtime" "luajit"; then + includes "src/luajit" + else + includes "src/lua" + fi +fi if ! has_config "lua_cjson"; then includes "src/lua-cjson" fi @@ -69,10 +83,4 @@ includes "src/lz4" includes "src/tbox" includes "src/xmake" includes "src/demo" -if is_config "runtime" "luajit"; then - includes "src/luajit" -else - includes "src/lua" -fi - |
