summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaikari <[email protected]>2026-04-28 07:00:58 +0300
committerSaikari <[email protected]>2026-04-28 07:00:58 +0300
commit24f15fb7c24996b20f13d0163e8dd17706db18fa (patch)
tree40e13ec02773e7ac6d65c41cbbfa35b6898f0abd
parenta0add317664d49a2755406580e299ff406dc2e46 (diff)
fix: handle Windows cross-compilation prefix and installation path in Meson
-rw-r--r--xmake/modules/package/tools/meson.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua
index 598370997..5434ec7f6 100644
--- a/xmake/modules/package/tools/meson.lua
+++ b/xmake/modules/package/tools/meson.lua
@@ -329,9 +329,16 @@ end
function _get_configs(package, configs, opt)
-- add prefix
+ -- when cross-compiling on Windows to a Unix-like target (e.g. Android), Meson validates
+ -- the prefix as a Unix absolute path and rejects Windows paths like C:/... Use prefix=/
+ -- and redirect installation via DESTDIR in the install step instead.
configs = configs or {}
opt._configs_str = string.serialize(configs, {indent = false, strip = true})
- table.insert(configs, "--prefix=" .. path.unix(opt.prefix or package:installdir()))
+ if is_host("windows") and package:is_cross() and not package:is_plat("windows", "mingw") then
+ table.insert(configs, "--prefix=/")
+ else
+ table.insert(configs, "--prefix=" .. path.unix(opt.prefix or package:installdir()))
+ end
table.insert(configs, "--libdir=lib")
-- set build type
@@ -614,6 +621,14 @@ function install(package, configs, opt)
local builddir = _get_builddir(package, opt)
local argv = {"install", "-C", builddir}
+ -- when prefix=/ was used for cross-builds on Windows, redirect the install to the
+ -- actual package directory via DESTDIR so files land in the right place.
+ -- meson's destdir_join strips the leading / from prefix, giving DESTDIR/lib, DESTDIR/include, etc.
+ if is_host("windows") and package:is_cross() and not package:is_plat("windows", "mingw") then
+ table.insert(argv, "--destdir")
+ table.insert(argv, opt.prefix or package:installdir())
+ end
+
-- do install
local meson = assert(find_tool("meson"), "meson not found!")
os.vrunv(meson.program, argv, {envs = opt.envs or buildenvs(package, opt)})