Skip to content

Commit fb1ac8a

Browse files
committed
fix windows wasm compilation with packages
1 parent 2a2ee54 commit fb1ac8a

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

xmake/core/platform/platform.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ end
151151
-- get the toolchains
152152
function _instance:toolchains(opt)
153153
local toolchains = self:_memcache():get("toolchains")
154-
if not toolchains then
154+
if not toolchains or #toolchains == 0 then
155155

156156
-- get current valid toolchains from configuration cache
157157
local names = nil

xmake/modules/package/tools/cmake.lua

+12-5
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,16 @@ function _get_configs_for_wasm(package, configs, opt)
601601
local emscripten_cmakefile = find_file("Emscripten.cmake", path.join(emsdk.emscripten, "cmake/Modules/Platform"))
602602
assert(emscripten_cmakefile, "Emscripten.cmake not found!")
603603
table.insert(configs, "-DCMAKE_TOOLCHAIN_FILE=" .. emscripten_cmakefile)
604-
if is_subhost("windows") and opt.cmake_generator ~= "Ninja" then
605-
local mingw_make = _get_mingw32_make(package)
606-
if mingw_make then
607-
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. mingw_make)
604+
if is_subhost("windows") then
605+
if opt.cmake_generator ~= "Ninja" then
606+
local mingw_make = _get_mingw32_make(package)
607+
if mingw_make then
608+
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. mingw_make)
609+
end
610+
else
611+
local ninja = find_tool("ninja")
612+
assert(ninja, "ninja not found!")
613+
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. ninja.program)
608614
end
609615
end
610616
_get_configs_for_generic(package, configs, opt)
@@ -1214,8 +1220,9 @@ end
12141220
-- install package
12151221
function install(package, configs, opt)
12161222
opt = opt or {}
1217-
local cmake_generator = _get_cmake_generator(package, opt)
1223+
_get_configs(package, configs, opt)
12181224

1225+
local cmake_generator = _get_cmake_generator(package, opt)
12191226
-- enter build directory
12201227
local buildir = opt.buildir or package:buildir()
12211228
os.mkdir(path.join(buildir, "install"))

0 commit comments

Comments
 (0)