summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-08-20 22:37:18 +0800
committerruki <[email protected]>2021-08-20 22:37:18 +0800
commitc95fdc3f443b3dee83708b42bc34383a47601e13 (patch)
tree31c0c1761b01b3a88f7748f12b70db9e31a39c4c
parentaa1fcf6c858bb139927c9e1d36e70bd7197ba8fb (diff)
improve host package
-rw-r--r--tests/projects/package/toolchain_muslcc/xmake-requires.lock24
-rw-r--r--xmake/core/package/package.lua12
-rw-r--r--xmake/core/sandbox/modules/import/core/package/package.lua20
-rw-r--r--xmake/modules/private/action/require/impl/package.lua9
4 files changed, 31 insertions, 34 deletions
diff --git a/tests/projects/package/toolchain_muslcc/xmake-requires.lock b/tests/projects/package/toolchain_muslcc/xmake-requires.lock
index 9509b8501..d31ecd965 100644
--- a/tests/projects/package/toolchain_muslcc/xmake-requires.lock
+++ b/tests/projects/package/toolchain_muslcc/xmake-requires.lock
@@ -9,7 +9,7 @@
plat = "macosx",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "2.69"
@@ -21,7 +21,7 @@
plat = "macosx",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "1.16.1"
@@ -33,7 +33,7 @@
plat = "macosx",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "3.21.0"
@@ -45,7 +45,7 @@
plat = "macosx",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "6.2.1"
@@ -57,7 +57,7 @@
plat = "macosx",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "0.22"
@@ -69,7 +69,7 @@
plat = "cross",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "v1.3.4"
@@ -81,7 +81,7 @@
plat = "cross",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "2.2.0"
@@ -93,7 +93,7 @@
plat = "macosx",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "2.4.6"
@@ -105,7 +105,7 @@
plat = "macosx",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "1.4.19"
@@ -117,7 +117,7 @@
plat = "macosx",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "20210202"
@@ -129,7 +129,7 @@
plat = "macosx",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "0.29.2"
@@ -141,7 +141,7 @@
plat = "cross",
repo = {
branch = "master",
- commit = "e87effa464611cecf28dfced70cbe491a08fe99d",
+ commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "1.2.11"
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index f7b2b7884..d68f782e4 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -118,7 +118,7 @@ function _instance:plat()
if requireinfo and requireinfo.plat then
return requireinfo.plat
end
- return package._target_plat()
+ return package.targetplat()
end
-- get the architecture of package
@@ -145,7 +145,7 @@ function _instance:targetarch()
if requireinfo and requireinfo.arch then
return requireinfo.arch
end
- return package._target_arch()
+ return package.targetarch()
end
-- get the build mode
@@ -1592,7 +1592,7 @@ end
-- the current platform is belong to the given platforms?
function package._api_is_plat(interp, ...)
- local plat = package._target_plat()
+ local plat = package.targetplat()
for _, v in ipairs(table.join(...)) do
if v and plat == v then
return true
@@ -1602,7 +1602,7 @@ end
-- the current platform is belong to the given architectures?
function package._api_is_arch(interp, ...)
- local arch = package._target_arch()
+ local arch = package.targetarch()
for _, v in ipairs(table.join(...)) do
if v and arch:find("^" .. v:gsub("%-", "%%-") .. "$") then
return true
@@ -1657,7 +1657,7 @@ function package._project()
end
-- get global target platform of package
-function package._target_plat()
+function package.targetplat()
local plat = package._memcache():get("target_plat")
if plat == nil then
if not plat and package._project() then
@@ -1675,7 +1675,7 @@ function package._target_plat()
end
-- get global target architecture of pacakge
-function package._target_arch()
+function package.targetarch()
local arch = package._memcache():get("target_arch")
if arch == nil then
if not arch and package._project() then
diff --git a/xmake/core/sandbox/modules/import/core/package/package.lua b/xmake/core/sandbox/modules/import/core/package/package.lua
index 4ba67d246..f1ec8799f 100644
--- a/xmake/core/sandbox/modules/import/core/package/package.lua
+++ b/xmake/core/sandbox/modules/import/core/package/package.lua
@@ -26,20 +26,12 @@ local project = require("project/project")
local package = require("package/package")
local raise = require("sandbox/modules/raise")
--- get cache directory
-function sandbox_core_package_package.cachedir(opt)
- return package.cachedir(opt)
-end
-
--- the install directory
-function sandbox_core_package_package.installdir()
- return package.installdir()
-end
-
--- the search directories
-function sandbox_core_package_package.searchdirs()
- return package.searchdirs()
-end
+-- inherit some builtin interfaces
+sandbox_core_package_package.cachedir = package.cachedir
+sandbox_core_package_package.installdir = package.installdir
+sandbox_core_package_package.searchdirs = package.searchdirs
+sandbox_core_package_package.targetplat = package.targetplat
+sandbox_core_package_package.targetarch = package.targetarch
-- load the package from the project file
function sandbox_core_package_package.load_from_project(packagename)
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 5084d2d29..95a54a008 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -152,8 +152,13 @@ function _load_require(require_str, requires_extra, parentinfo)
-- require packge in the current host platform
if require_extra.host then
- require_extra.plat = os.host()
- require_extra.arch = os.arch()
+ if is_subhost(core_package.targetplat()) and os.subarch() == core_package.targetarch() then
+ -- we need pass plat/arch to avoid repeat installation
+ -- @see https://github.com/xmake-io/xmake/issues/1579
+ else
+ require_extra.plat = os.subhost()
+ require_extra.arch = os.subarch()
+ end
end
-- init required item