summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authortqfx <[email protected]>2024-05-24 22:39:12 +0800
committertqfx <[email protected]>2024-05-26 21:45:46 +0800
commit1d6f7c99f8c7992e2eb7cd99bb7eb6aa309bb314 (patch)
tree2fa78116390103b9b80e3b80adeab13b19eefd8f /core
parent4cdcaa4772957ab2672d2618ca11e1dcce0e71c2 (diff)
Fix building xmake using xmake on mingw
Diffstat (limited to 'core')
-rw-r--r--core/src/lua/xmake.lua2
-rwxr-xr-xcore/src/lua/xmake.sh5
-rw-r--r--core/src/xmake/curses/curses.c6
-rw-r--r--core/src/xmake/io/stdfile.c2
-rw-r--r--core/src/xmake/process/openv.c2
-rw-r--r--core/src/xmake/winos/ansi.c1
-rw-r--r--core/src/xmake/winos/logical_drives.c5
-rw-r--r--core/src/xmake/xmake.lua2
-rw-r--r--core/xmake.lua13
9 files changed, 22 insertions, 16 deletions
diff --git a/core/src/lua/xmake.lua b/core/src/lua/xmake.lua
index 8803dd2b3..006480397 100644
--- a/core/src/lua/xmake.lua
+++ b/core/src/lua/xmake.lua
@@ -21,7 +21,7 @@ target("lua")
-- add definitions
add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", "LUA_COMPAT_5_3", {public = true})
- if is_plat("windows") then
+ if is_plat("windows", "mingw") then
-- it has been defined in luaconf.h
--add_defines("LUA_USE_WINDOWS")
elseif is_plat("macosx", "iphoneos") then
diff --git a/core/src/lua/xmake.sh b/core/src/lua/xmake.sh
index 78e05bd21..59eff5dd3 100755
--- a/core/src/lua/xmake.sh
+++ b/core/src/lua/xmake.sh
@@ -44,8 +44,9 @@ target "lua"
# add definitions
add_defines "LUA_COMPAT_5_1" "LUA_COMPAT_5_2" "LUA_COMPAT_5_3" "{public}"
- if is_plat "mingw"; then
- add_defines "LUA_USE_WINDOWS"
+ if is_plat "mingw"; then true
+ # it has been defined in luaconf.h
+ #add_defines "LUA_USE_WINDOWS"
elif is_plat "macosx"; then
add_defines "LUA_USE_MACOSX"
else
diff --git a/core/src/xmake/curses/curses.c b/core/src/xmake/curses/curses.c
index 29577658a..2ff4cb77e 100644
--- a/core/src/xmake/curses/curses.c
+++ b/core/src/xmake/curses/curses.c
@@ -36,7 +36,11 @@
# undef MOUSE_MOVED
#endif
#define NCURSES_MOUSE_VERSION 2
-#include <curses.h>
+#ifdef TB_COMPILER_IS_MINGW
+# include <ncursesw/curses.h>
+#else
+# include <curses.h>
+#endif
#if defined(NCURSES_VERSION)
# include <locale.h>
#endif
diff --git a/core/src/xmake/io/stdfile.c b/core/src/xmake/io/stdfile.c
index 13edbfc79..5f94126fa 100644
--- a/core/src/xmake/io/stdfile.c
+++ b/core/src/xmake/io/stdfile.c
@@ -56,7 +56,7 @@ static tb_size_t xm_io_stdfile_isatty(tb_size_t type)
tb_bool_t answer = tb_false;
#if defined(TB_CONFIG_OS_WINDOWS)
DWORD mode;
- HANDLE console_handle;
+ HANDLE console_handle = tb_null;
switch (type)
{
case XM_IO_FILE_TYPE_STDIN: console_handle = GetStdHandle(STD_INPUT_HANDLE); break;
diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c
index 21add6d55..5903dab27 100644
--- a/core/src/xmake/process/openv.c
+++ b/core/src/xmake/process/openv.c
@@ -30,7 +30,7 @@
*/
#include "prefix.h"
#include "../io/prefix.h"
-#if defined(TB_CONFIG_OS_MACOSX) || defined(TB_CONFIG_OS_LINUX) || defined(TB_CONFIG_OS_BSD) || defined(TB_CONFIG_OS_HAIKU)
+#if defined(TB_CONFIG_OS_MACOSX) || defined(TB_CONFIG_OS_LINUX) || defined(TB_CONFIG_OS_BSD) || defined(TB_CONFIG_OS_HAIKU) || defined(TB_COMPILER_IS_MINGW)
# include <signal.h>
#endif
diff --git a/core/src/xmake/winos/ansi.c b/core/src/xmake/winos/ansi.c
index ee86d13ea..7caad7797 100644
--- a/core/src/xmake/winos/ansi.c
+++ b/core/src/xmake/winos/ansi.c
@@ -96,7 +96,6 @@ tb_int_t xm_winos_cp_info(lua_State* lua)
// check
tb_assert_and_check_return_val(lua, 0);
- tb_int_t n = lua_gettop(lua);
lua_Integer cp = luaL_checkinteger(lua, 1);
luaL_argcheck(lua, cp >= 0 && cp < 65536, 1, "invalid code page");
CPINFOEX cp_info;
diff --git a/core/src/xmake/winos/logical_drives.c b/core/src/xmake/winos/logical_drives.c
index fe62edd04..14fa72fac 100644
--- a/core/src/xmake/winos/logical_drives.c
+++ b/core/src/xmake/winos/logical_drives.c
@@ -41,7 +41,6 @@ tb_int_t xm_winos_logical_drives(lua_State* lua)
lua_newtable(lua);
// get logical drives
- tb_bool_t ok = tb_false;
tb_char_t* data = tb_null;
do
{
@@ -70,10 +69,6 @@ tb_int_t xm_winos_logical_drives(lua_State* lua)
// next drive
p += tb_strlen(p) + 1;
}
-
- // ok
- ok = tb_true;
-
} while (0);
// exit data
diff --git a/core/src/xmake/xmake.lua b/core/src/xmake/xmake.lua
index 15702c808..af0bfd877 100644
--- a/core/src/xmake/xmake.lua
+++ b/core/src/xmake/xmake.lua
@@ -38,7 +38,7 @@ target("xmake")
-- add the common source files
add_files("**.c|winos/*.c")
- if is_plat("windows", "msys", "cygwin") then
+ if is_plat("windows", "msys", "mingw", "cygwin") then
add_files("winos/*.c")
end
diff --git a/core/xmake.lua b/core/xmake.lua
index e14961d08..b64953ad7 100644
--- a/core/xmake.lua
+++ b/core/xmake.lua
@@ -65,7 +65,7 @@ option_end()
option("readline")
set_description("Enable or disable readline library")
add_links("readline")
- add_cincludes("readline/readline.h")
+ add_cincludes("stdio.h", "readline/readline.h")
add_cfuncs("readline")
add_defines("XM_CONFIG_API_HAVE_READLINE")
option_end()
@@ -73,8 +73,15 @@ option_end()
-- the curses option
option("curses")
set_description("Enable or disable curses library")
- add_links("curses")
- add_cincludes("curses.h")
+ before_check(function (option)
+ if is_plat("mingw") then
+ option:add("cincludes", "ncursesw/curses.h")
+ option:add("links", "ncursesw")
+ else
+ option:add("cincludes", "curses.h")
+ option:add("links", "curses")
+ end
+ end)
add_defines("XM_CONFIG_API_HAVE_CURSES")
option_end()