summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-04-11 00:56:19 +0800
committerruki <[email protected]>2024-04-11 00:56:19 +0800
commit3871415320ddf8ceeaa3a2851a6b27d8a5fa7e71 (patch)
tree90a8ed8bf03591c5dce484a23abefe48e9891171
parent56b62725e6e35fa9265f9f6251dae84dd6933df5 (diff)
disable some fetch packages for cross
-rw-r--r--xmake/core/base/private/is_cross.lua2
-rw-r--r--xmake/modules/package/manager/apt/find_package.lua8
-rw-r--r--xmake/modules/package/manager/brew/find_package.lua6
-rw-r--r--xmake/modules/package/manager/pacman/find_package.lua13
-rw-r--r--xmake/modules/package/manager/portage/find_package.lua6
-rw-r--r--xmake/modules/package/manager/system/find_package.lua6
-rw-r--r--xmake/modules/package/manager/zypper/find_package.lua3
7 files changed, 28 insertions, 16 deletions
diff --git a/xmake/core/base/private/is_cross.lua b/xmake/core/base/private/is_cross.lua
index 7c02aa18c..32fb7aae6 100644
--- a/xmake/core/base/private/is_cross.lua
+++ b/xmake/core/base/private/is_cross.lua
@@ -23,6 +23,8 @@ local os = require("base/os")
-- is cross-compilation?
function is_cross(plat, arch)
+ plat = plat or os.subhost()
+ arch = arch or os.subarch()
if os.host() == "windows" then
local host_arch = os.arch()
if plat == "windows" then
diff --git a/xmake/modules/package/manager/apt/find_package.lua b/xmake/modules/package/manager/apt/find_package.lua
index 614b1028f..74ccc07bb 100644
--- a/xmake/modules/package/manager/apt/find_package.lua
+++ b/xmake/modules/package/manager/apt/find_package.lua
@@ -23,6 +23,7 @@ import("core.base.option")
import("core.project.config")
import("core.project.target")
import("lib.detect.find_tool")
+import("private.core.base.is_cross")
import("package.manager.pkgconfig.find_package", {alias = "find_package_from_pkgconfig"})
-- find package
@@ -129,19 +130,14 @@ end
-- @param opt the options, e.g. {verbose = true, version = "1.12.0")
--
function main(name, opt)
-
- -- check
opt = opt or {}
- if not is_host(opt.plat) or os.arch() ~= opt.arch then
+ if is_cross(opt.plat, opt.arch) then
return
end
- -- find dpkg
local dpkg = find_tool("dpkg")
if not dpkg then
return
end
-
- -- find package
return _find_package(dpkg, name, opt)
end
diff --git a/xmake/modules/package/manager/brew/find_package.lua b/xmake/modules/package/manager/brew/find_package.lua
index 953d34f4e..81a98e170 100644
--- a/xmake/modules/package/manager/brew/find_package.lua
+++ b/xmake/modules/package/manager/brew/find_package.lua
@@ -25,6 +25,7 @@ import("lib.detect.find_path")
import("lib.detect.pkgconfig")
import("core.project.target")
import("package.manager.find_package")
+import("private.core.base.is_cross")
-- get the root directory of the brew packages
function _brew_pkg_rootdir()
@@ -92,9 +93,12 @@ end
-- @param opt the options, e.g. {verbose = true, version = "1.12.x")
--
function main(name, opt)
+ opt = opt or {}
+ if is_cross(opt.plat, opt.arch) then
+ return
+ end
-- find the prefix directory of brew
- opt = opt or {}
local brew_pkg_rootdir = _brew_pkg_rootdir()
if not brew_pkg_rootdir then
return
diff --git a/xmake/modules/package/manager/pacman/find_package.lua b/xmake/modules/package/manager/pacman/find_package.lua
index 92e5ccf52..f68b3550b 100644
--- a/xmake/modules/package/manager/pacman/find_package.lua
+++ b/xmake/modules/package/manager/pacman/find_package.lua
@@ -22,6 +22,7 @@
import("core.base.option")
import("core.project.target")
import("lib.detect.find_tool")
+import("private.core.base.is_cross")
import("package.manager.pkgconfig.find_package", {alias = "find_package_from_pkgconfig"})
-- get result from list of file inside pacman package
@@ -51,7 +52,7 @@ 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
+ if is_subhost("msys") and opt.plat == "mingw" then
hpath = path.join(pathtomsys, line)
local basehpath = path.join(pathtomsys, msystem .. "/include")
table.insert(result.includedirs, basehpath)
@@ -103,9 +104,12 @@ end
-- @param opt the options, e.g. {verbose = true, version = "1.12.x")
--
function main(name, opt)
+ opt = opt or {}
+ if is_cross(opt.plat, opt.arch) then
+ return
+ end
-- find pacman
- opt = opt or {}
local pacman = find_tool("pacman")
if not pacman then
return
@@ -125,13 +129,13 @@ function main(name, opt)
name = prefix .. arch .. name
end
end
-
+
-- get package files list
list = name and try { function() return os.iorunv(pacman.program, {"-Q", "-l", name}) end }
if not list then
return
end
-
+
-- parse package files list
local linkdirs = {}
local pkgconfig_files = {}
@@ -179,6 +183,5 @@ function main(name, opt)
-- if there is no .pc, we parse the package content to obtain the data we want
result = _find_package_from_list(list, name, pacman, opt)
end
-
return result
end
diff --git a/xmake/modules/package/manager/portage/find_package.lua b/xmake/modules/package/manager/portage/find_package.lua
index f08b8e39f..4f0c7b349 100644
--- a/xmake/modules/package/manager/portage/find_package.lua
+++ b/xmake/modules/package/manager/portage/find_package.lua
@@ -22,6 +22,7 @@
import("core.base.option")
import("lib.detect.find_file")
import("lib.detect.find_tool")
+import("private.core.base.is_cross")
import("package.manager.pkgconfig.find_package", {alias = "find_package_from_pkgconfig"})
-- find package from the system directories
@@ -30,9 +31,10 @@ import("package.manager.pkgconfig.find_package", {alias = "find_package_from_pkg
-- @param opt the options, e.g. {verbose = true, version = "1.12.x")
--
function main(name, opt)
-
- -- init options
opt = opt or {}
+ if is_cross(opt.plat, opt.arch) then
+ return
+ end
-- for msys2/mingw? mingw-w64-[i686|x86_64]-xxx
if opt.plat == "mingw" then
diff --git a/xmake/modules/package/manager/system/find_package.lua b/xmake/modules/package/manager/system/find_package.lua
index dd1fd099a..9a2a7ea55 100644
--- a/xmake/modules/package/manager/system/find_package.lua
+++ b/xmake/modules/package/manager/system/find_package.lua
@@ -20,6 +20,7 @@
-- imports
import("core.language.language")
+import("private.core.base.is_cross")
import("lib.detect.check_cxsnippets")
-- get package items
@@ -57,8 +58,11 @@ end
--
function main(name, opt)
opt = opt or {}
- local configs = opt.configs or {}
+ if is_cross(opt.plat, opt.arch) then
+ return
+ end
+ local configs = opt.configs or {}
local items = _get_package_items()
local snippet_configs = {}
for _, name in ipairs(items) do
diff --git a/xmake/modules/package/manager/zypper/find_package.lua b/xmake/modules/package/manager/zypper/find_package.lua
index ea5651004..490b76161 100644
--- a/xmake/modules/package/manager/zypper/find_package.lua
+++ b/xmake/modules/package/manager/zypper/find_package.lua
@@ -23,6 +23,7 @@ import("core.base.option")
import("core.project.config")
import("core.project.target")
import("lib.detect.find_tool")
+import("private.core.base.is_cross")
import("package.manager.pkgconfig.find_package", { alias = "find_package_from_pkgconfig" })
-- find package
@@ -137,7 +138,7 @@ end
--
function main(name, opt)
opt = opt or {}
- if not is_host(opt.plat) or os.arch() ~= opt.arch then
+ if is_cross(opt.plat, opt.arch) then
return
end
local rpm = find_tool("rpm")