diff options
| author | ImperatorS79 <[email protected]> | 2022-08-13 13:15:21 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-08-13 13:15:21 +0200 |
| commit | 3e74e829daa4b6eb66f0a19b9547cfea063e1514 (patch) | |
| tree | 97567cfe6219a408aa6865f7843c8b7b98d2893f | |
| parent | be3bab756494bd895943d115b05d0c32c6d42128 (diff) | |
Call cygpath once at the beginning for msys2 pacman packages
| -rw-r--r-- | xmake/modules/package/manager/pacman/find_package.lua | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/xmake/modules/package/manager/pacman/find_package.lua b/xmake/modules/package/manager/pacman/find_package.lua index 41b9355e5..f3010a888 100644 --- a/xmake/modules/package/manager/pacman/find_package.lua +++ b/xmake/modules/package/manager/pacman/find_package.lua @@ -29,11 +29,16 @@ function _find_package_from_list(list, name, pacman, opt) -- mingw + pacman = cygpath available local cygpath = nil + local pathtomsys2 = "" if is_subhost("msys") and opt.plat == "mingw" then cygpath = find_tool("cygpath") if not cygpath then return end + pathtomsys = os.iorunv(cygpath.program, {"--windows", "/"}) + if pathtomsys:endswith("\n") then + pathtomsys = pathtomsys:sub(1, -2) + end end -- iterate over each file path inside the pacman package @@ -43,14 +48,13 @@ function _find_package_from_list(list, name, pacman, opt) if line:find("/include/", 1, true) and (line:endswith(".h") or line:endswith(".hpp")) then if not line:startswith("/usr/include/") then local hpath = line - if is_subhost("msys") and opt.plat == "mingw" then - hpath = os.iorunv(cygpath.program, {"--windows", line}) - + if is_subhost("msys") and opt.plat == "mingw" then + hpath = path.join(pathtomsys, line) if opt.arch == "x86_64" then - local basehpath = os.iorunv(cygpath.program, {"--windows", "/mingw64/include"}) + local basehpath = path.join(pathtomsys, "/mingw64/include") table.insert(result.includedirs, basehpath) else - local basehpath = os.iorunv(cygpath.program, {"--windows", "/mingw32/include"}) + local basehpath = path.join(pathtomsys, "/mingw32/include") table.insert(result.includedirs, basehpath) end end @@ -58,7 +62,7 @@ function _find_package_from_list(list, name, pacman, opt) end -- remove lib and .a, .dll.a and .so to have the links elseif line:endswith(".dll.a") then -- only for mingw - local apath = os.iorunv(cygpath.program, {"--windows", line}) + local apath = path.join(pathtomsys, line) apath = apath:trim() table.insert(result.linkdirs, path.directory(apath)) table.insert(result.links, target.linkname(path.filename(apath), {plat = opt.plat})) @@ -68,7 +72,7 @@ function _find_package_from_list(list, name, pacman, opt) elseif line:endswith(".a") then local apath = line if is_subhost("msys") and opt.plat == "mingw" then - apath = os.iorunv(cygpath.program, {"--windows", line}) + apath = path.join(pathtomsys, line) apath = apath:trim() end table.insert(result.linkdirs, path.directory(apath)) @@ -91,7 +95,7 @@ function _find_package_from_list(list, name, pacman, opt) result.version = version:split('-')[1] else result = nil - end + end return result end |
