diff options
| author | ruki <[email protected]> | 2022-12-18 17:24:55 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-12-18 17:24:55 +0800 |
| commit | 68425b26424dbe2aead586a0e28fc76b640a3d57 (patch) | |
| tree | f9e77acb0f55bfaeb62ca86826402449cd982391 /core | |
| parent | 4e4f010e7fd1123dcbc272549f3d45f5261bc8a9 (diff) | |
| parent | 6cebe3979a67dbbc778692571f8dbdeb33a8fecb (diff) | |
Merge pull request #3175 from xmake-io/xmake.sh
improve xmake.sh
Diffstat (limited to 'core')
| -rwxr-xr-x | core/src/lua-cjson/xmake.sh | 8 | ||||
| m--------- | core/src/tbox/tbox | 0 | ||||
| -rwxr-xr-x | core/src/tbox/xmake.sh | 1 | ||||
| -rwxr-xr-x | core/src/xmake/xmake.sh | 30 | ||||
| -rwxr-xr-x | core/xmake.sh | 130 |
5 files changed, 146 insertions, 23 deletions
diff --git a/core/src/lua-cjson/xmake.sh b/core/src/lua-cjson/xmake.sh index 7ee38cc10..134173051 100755 --- a/core/src/lua-cjson/xmake.sh +++ b/core/src/lua-cjson/xmake.sh @@ -4,7 +4,13 @@ target "lua_cjson" set_kind "static" set_default false set_warnings "all" - add_deps "lua" + if is_config "runtime" "luajit" && has_config "luajit"; then + add_options "luajit" "{public}" + elif 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/tbox/tbox b/core/src/tbox/tbox -Subproject 592d19f5efd42204a2bfcf9ac3fef05e9fe251c +Subproject 09f715aabf543981544112b929f105a77bc90f1 diff --git a/core/src/tbox/xmake.sh b/core/src/tbox/xmake.sh index ed5d59d2a..9bd760793 100755 --- a/core/src/tbox/xmake.sh +++ b/core/src/tbox/xmake.sh @@ -14,6 +14,7 @@ hide_options() { for name in $options; do option "${name}" set_showmenu false + option_end done } hide_options diff --git a/core/src/xmake/xmake.sh b/core/src/xmake/xmake.sh index 983dc95ea..f3fe92aa1 100755 --- a/core/src/xmake/xmake.sh +++ b/core/src/xmake/xmake.sh @@ -5,7 +5,24 @@ target "xmake" set_default false # add deps - add_deps "sv" "lua_cjson" "lua" "lz4" "tbox" + local libs="lua_cjson lz4 sv tbox" + for lib in $libs; do + if has_config "$lib"; then + add_options "$lib" "{public}" + else + add_deps "$lib" + fi + done + if is_config "runtime" "luajit" && has_config "luajit"; then + add_options "luajit" "{public}" + elif has_config "lua"; then + add_options "lua" "{public}" + else + add_deps "lua" + fi + + # add options + add_options "readline" "curses" "{public}" # add defines add_defines "__tb_prefix__=\"xmake\"" @@ -44,14 +61,3 @@ target "xmake" add_files "winos/*.c" fi - # enable readline - if has_config "readline"; then - add_defines "XM_CONFIG_API_HAVE_READLINE" "{public}" - add_links "readline" "{public}" - fi - - # enable curses - if has_config "curses"; then - add_defines "XM_CONFIG_API_HAVE_CURSES" "{public}" - add_links "curses" "{public}" - fi diff --git a/core/xmake.sh b/core/xmake.sh index 21c7db319..819525b9b 100755 --- a/core/xmake.sh +++ b/core/xmake.sh @@ -35,24 +35,134 @@ option "readline" add_links "readline" add_cincludes "readline/readline.h" add_cfuncs "readline" + add_defines "XM_CONFIG_API_HAVE_READLINE" +option_end # the curses option option "curses" add_links "curses" + add_cfuncs "initscr" add_cincludes "curses.h" + add_defines "XM_CONFIG_API_HAVE_CURSES" +option_end + +# the lua-cjson option +option "lua_cjson" + add_links "lua5.1-cjson" + add_csnippets " +int luaopen_cjson(void *l);\n +void test() {\n + luaopen_cjson(0);\n +} +" +option_end + +# the lua option +option "lua" + add_cfuncs "lua_pushstring" + add_cincludes "lua.h" "lualib.h" "lauxlib.h" + add_defines "LUA_COMPAT_5_1" "LUA_COMPAT_5_2" "LUA_COMPAT_5_3" + 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 +} + +# the luajit option +option "luajit" + add_cfuncs "lua_pushstring" + add_cincludes "lua.h" "lualib.h" "lauxlib.h" + add_defines "USE_LUAJIT" + before_check "option_find_luajit" +option_end + +option_find_luajit() { + option "luajit" + add_cflags `pkg-config --cflags luajit 2>/dev/null` + add_ldflags `pkg-config --libs luajit 2>/dev/null` + option_end +} + +# the lz4 option +option "lz4" + add_cfuncs "LZ4F_compressFrame" + add_cincludes "lz4.h" "lz4frame.h" + before_check "option_find_lz4" +option_end + +option_find_lz4() { + option "lz4" + add_cflags `pkg-config --cflags liblz4 2>/dev/null` + add_ldflags `pkg-config --libs liblz4 2>/dev/null` + option_end +} + +# the sv option +option "sv" + add_cfuncs "semver_tryn" + add_cincludes "semver.h" + add_links "sv" + before_check "option_find_sv" +option_end + +option_find_sv() { + option "sv" + local dirs="/usr/local /usr" + for dir in $dirs; do + if test -f "${dir}/lib/libsv.a"; then + add_linkdirs "${dir}/lib" + add_includedirs "${dir}/include/sv" + break + fi + done + option_end +} + +# the tbox option +option "tbox" + add_cfuncs "tb_exit" "tb_md5_init" "tb_charset_conv_data" + add_cincludes "tbox/tbox.h" + add_links "tbox" + before_check "option_find_tbox" option_end +option_find_tbox() { + option "tbox" + local dirs="/usr/local /usr" + for dir in $dirs; do + if test -f "${dir}/lib/libtbox.a"; then + add_linkdirs "${dir}/lib" + add_includedirs "${dir}/include" + break + fi + done + option_end +} + # add projects -includes "src/lua-cjson" -includes "src/sv" -includes "src/lz4" -includes "src/tbox" +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 +if ! has_config "lz4"; then + includes "src/lz4" +fi +if ! has_config "sv"; then + includes "src/sv" +fi +if ! has_config "tbox"; then + includes "src/tbox" +fi includes "src/xmake" includes "src/demo" -if is_config "runtime" "luajit"; then - includes "src/luajit" -else - includes "src/lua" -fi - |
