Skip to content

Fix building xmake using xmake on mingw #5142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/lua/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions core/src/lua/xmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion core/src/xmake/curses/curses.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/src/xmake/io/stdfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/src/xmake/process/openv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion core/src/xmake/winos/ansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions core/src/xmake/winos/logical_drives.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/src/xmake/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 10 additions & 3 deletions core/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,23 @@ 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()

-- 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()

Expand Down
Loading