diff options
| author | ruki <[email protected]> | 2023-07-14 10:57:12 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-07-14 10:57:12 +0800 |
| commit | e246dae9b6b086a77afe28311e08d9eb7defc4b2 (patch) | |
| tree | 2d548e2462cf240f41152a44bd04d0273e1991b3 | |
| parent | bbaa5fa3d6d2e7328582219b65486debf7334213 (diff) | |
| parent | f7d4e69192efa8355d097269436917cb20417c31 (diff) | |
Merge pull request #3965 from calebkiage/fix-msys-windows-package-lookup
Fix pacman package lookup on msys Windows
| -rw-r--r-- | xmake/modules/package/manager/pacman/find_package.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/xmake/modules/package/manager/pacman/find_package.lua b/xmake/modules/package/manager/pacman/find_package.lua index 119a8169e..4daf30029 100644 --- a/xmake/modules/package/manager/pacman/find_package.lua +++ b/xmake/modules/package/manager/pacman/find_package.lua @@ -112,12 +112,28 @@ function main(name, opt) end -- for msys2/mingw? mingw-w64-[i686|x86_64]-xxx + local name_alt if is_subhost("msys") and opt.plat == "mingw" then - name = (opt.arch == "x86_64" and "mingw-w64-x86_64-" or "mingw-w64-i686-") .. name + -- try to get the package prefix from the environment first + -- https://www.msys2.org/docs/package-naming/ + local prefix = "mingw-w64-" + local arch = (opt.arch == "x86_64" and "x86_64-" or "i686-") + local msystem = os.getenv("MSYSTEM") + if msystem and not msystem:startswith("MINGW") then + local i, j = msystem:find("%D+") + name_alt = prefix .. msystem:sub(i, j):lower() .. "-" .. arch .. name + end + name = prefix .. arch .. name end -- get package files list - local list = try { function() return os.iorunv(pacman.program, {"-Q", "-l", name}) end } + local list + for _, n in ipairs({name, name_alt}) do + list = n and try { function() return os.iorunv(pacman.program, {"-Q", "-l", n}) end } + if list then + break + end + end if not list then return end |
