Skip to content

Commit b327704

Browse files
committed
improve to get mingw32-make
1 parent 9e4f3d7 commit b327704

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

xmake/modules/package/tools/cmake.lua

+14-6
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,13 @@ end
357357

358358
-- get mingw32 make
359359
function _get_mingw32_make(package)
360-
local mingw = assert(package:build_getenv("mingw") or package:build_getenv("sdk"), "mingw not found!")
361-
return _translate_bin_path(path.join(mingw, "bin", "mingw32-make.exe"))
360+
local mingw = package:build_getenv("mingw") or package:build_getenv("sdk")
361+
if mingw then
362+
local mingw_make = _translate_bin_path(path.join(mingw, "bin", "mingw32-make.exe"))
363+
if os.isfile(mingw_make) then
364+
return mingw_make
365+
end
366+
end
362367
end
363368

364369
-- https://github.com/xmake-io/xmake-repo/pull/1096
@@ -597,7 +602,10 @@ function _get_configs_for_wasm(package, configs, opt)
597602
assert(emscripten_cmakefile, "Emscripten.cmake not found!")
598603
table.insert(configs, "-DCMAKE_TOOLCHAIN_FILE=" .. emscripten_cmakefile)
599604
if is_subhost("windows") and opt.cmake_generator ~= "Ninja" then
600-
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. _get_mingw32_make(package))
605+
local mingw_make = _get_mingw32_make(package)
606+
if mingw_make then
607+
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. mingw_make)
608+
end
601609
end
602610
_get_configs_for_generic(package, configs, opt)
603611
end
@@ -1004,7 +1012,7 @@ function _build_for_make(package, configs, opt)
10041012
if is_host("bsd") then
10051013
os.vrunv("gmake", argv)
10061014
elseif is_subhost("windows") and package:is_plat("mingw") then
1007-
local mingw_make = _get_mingw32_make(package)
1015+
local mingw_make = assert(_get_mingw32_make(package), "mingw32-make.exe not found!")
10081016
os.vrunv(mingw_make, argv)
10091017
elseif package:is_plat("android") and is_host("windows") then
10101018
local make
@@ -1079,7 +1087,7 @@ function _install_for_make(package, configs, opt)
10791087
os.vrunv("gmake", argv)
10801088
os.vrunv("gmake", {"install"})
10811089
elseif is_subhost("windows") and package:is_plat("mingw", "wasm") then
1082-
local mingw_make = _get_mingw32_make(package)
1090+
local mingw_make = assert(_get_mingw32_make(package), "mingw32-make.exe not found!")
10831091
os.vrunv(mingw_make, argv)
10841092
os.vrunv(mingw_make, {"install"})
10851093
elseif package:is_plat("android") and is_host("windows") then
@@ -1134,7 +1142,7 @@ function _get_cmake_generator(package, opt)
11341142
cmake_generator = "Ninja"
11351143
elseif is_subhost("windows") and package:is_plat("mingw") then
11361144
local mingw_make = _get_mingw32_make(package)
1137-
if not os.isfile(mingw_make) and find_tool("ninja") then
1145+
if not mingw_make and find_tool("ninja") then
11381146
cmake_generator = "Ninja"
11391147
end
11401148
end

0 commit comments

Comments
 (0)