Skip to content

Commit d58352a

Browse files
authored
Merge pull request #5142 from tqfx/patch-1
Fix building xmake using xmake on mingw
2 parents 52f0fa6 + 1d6f7c9 commit d58352a

File tree

9 files changed

+22
-16
lines changed

9 files changed

+22
-16
lines changed

core/src/lua/xmake.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ target("lua")
2121

2222
-- add definitions
2323
add_defines("LUA_COMPAT_5_1", "LUA_COMPAT_5_2", "LUA_COMPAT_5_3", {public = true})
24-
if is_plat("windows") then
24+
if is_plat("windows", "mingw") then
2525
-- it has been defined in luaconf.h
2626
--add_defines("LUA_USE_WINDOWS")
2727
elseif is_plat("macosx", "iphoneos") then

core/src/lua/xmake.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ target "lua"
4444

4545
# add definitions
4646
add_defines "LUA_COMPAT_5_1" "LUA_COMPAT_5_2" "LUA_COMPAT_5_3" "{public}"
47-
if is_plat "mingw"; then
48-
add_defines "LUA_USE_WINDOWS"
47+
if is_plat "mingw"; then true
48+
# it has been defined in luaconf.h
49+
#add_defines "LUA_USE_WINDOWS"
4950
elif is_plat "macosx"; then
5051
add_defines "LUA_USE_MACOSX"
5152
else

core/src/xmake/curses/curses.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636
# undef MOUSE_MOVED
3737
#endif
3838
#define NCURSES_MOUSE_VERSION 2
39-
#include <curses.h>
39+
#ifdef TB_COMPILER_IS_MINGW
40+
# include <ncursesw/curses.h>
41+
#else
42+
# include <curses.h>
43+
#endif
4044
#if defined(NCURSES_VERSION)
4145
# include <locale.h>
4246
#endif

core/src/xmake/io/stdfile.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static tb_size_t xm_io_stdfile_isatty(tb_size_t type)
5656
tb_bool_t answer = tb_false;
5757
#if defined(TB_CONFIG_OS_WINDOWS)
5858
DWORD mode;
59-
HANDLE console_handle;
59+
HANDLE console_handle = tb_null;
6060
switch (type)
6161
{
6262
case XM_IO_FILE_TYPE_STDIN: console_handle = GetStdHandle(STD_INPUT_HANDLE); break;

core/src/xmake/process/openv.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131
#include "prefix.h"
3232
#include "../io/prefix.h"
33-
#if defined(TB_CONFIG_OS_MACOSX) || defined(TB_CONFIG_OS_LINUX) || defined(TB_CONFIG_OS_BSD) || defined(TB_CONFIG_OS_HAIKU)
33+
#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)
3434
# include <signal.h>
3535
#endif
3636

core/src/xmake/winos/ansi.c

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ tb_int_t xm_winos_cp_info(lua_State* lua)
9696
// check
9797
tb_assert_and_check_return_val(lua, 0);
9898

99-
tb_int_t n = lua_gettop(lua);
10099
lua_Integer cp = luaL_checkinteger(lua, 1);
101100
luaL_argcheck(lua, cp >= 0 && cp < 65536, 1, "invalid code page");
102101
CPINFOEX cp_info;

core/src/xmake/winos/logical_drives.c

-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ tb_int_t xm_winos_logical_drives(lua_State* lua)
4141
lua_newtable(lua);
4242

4343
// get logical drives
44-
tb_bool_t ok = tb_false;
4544
tb_char_t* data = tb_null;
4645
do
4746
{
@@ -70,10 +69,6 @@ tb_int_t xm_winos_logical_drives(lua_State* lua)
7069
// next drive
7170
p += tb_strlen(p) + 1;
7271
}
73-
74-
// ok
75-
ok = tb_true;
76-
7772
} while (0);
7873

7974
// exit data

core/src/xmake/xmake.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ target("xmake")
3838

3939
-- add the common source files
4040
add_files("**.c|winos/*.c")
41-
if is_plat("windows", "msys", "cygwin") then
41+
if is_plat("windows", "msys", "mingw", "cygwin") then
4242
add_files("winos/*.c")
4343
end
4444

core/xmake.lua

+10-3
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,23 @@ option_end()
6565
option("readline")
6666
set_description("Enable or disable readline library")
6767
add_links("readline")
68-
add_cincludes("readline/readline.h")
68+
add_cincludes("stdio.h", "readline/readline.h")
6969
add_cfuncs("readline")
7070
add_defines("XM_CONFIG_API_HAVE_READLINE")
7171
option_end()
7272

7373
-- the curses option
7474
option("curses")
7575
set_description("Enable or disable curses library")
76-
add_links("curses")
77-
add_cincludes("curses.h")
76+
before_check(function (option)
77+
if is_plat("mingw") then
78+
option:add("cincludes", "ncursesw/curses.h")
79+
option:add("links", "ncursesw")
80+
else
81+
option:add("cincludes", "curses.h")
82+
option:add("links", "curses")
83+
end
84+
end)
7885
add_defines("XM_CONFIG_API_HAVE_CURSES")
7986
option_end()
8087

0 commit comments

Comments
 (0)