diff options
| -rw-r--r-- | tests/projects/package/toolchain_llvm/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/actions/require/install.lua | 6 | ||||
| -rw-r--r-- | xmake/core/project/requireinfo.lua | 5 | ||||
| -rw-r--r-- | xmake/toolchains/llvm/check.lua | 14 |
4 files changed, 25 insertions, 2 deletions
diff --git a/tests/projects/package/toolchain_llvm/xmake.lua b/tests/projects/package/toolchain_llvm/xmake.lua index 8ce025d00..5e2f17b3c 100644 --- a/tests/projects/package/toolchain_llvm/xmake.lua +++ b/tests/projects/package/toolchain_llvm/xmake.lua @@ -1,5 +1,5 @@ add_rules("mode.debug", "mode.release") -add_requires("llvm 11.0.0") +add_requires("llvm 11.0.0", {alias = "llvm-11"}) target("test") set_kind("binary") diff --git a/xmake/actions/require/install.lua b/xmake/actions/require/install.lua index 90366b1b6..888f64978 100644 --- a/xmake/actions/require/install.lua +++ b/xmake/actions/require/install.lua @@ -73,6 +73,11 @@ function _register_required_package_libs(instance, requireinfo, is_deps) end end +-- register the base info of required package +function _register_required_package_base(instance, requireinfo) + requireinfo:set("__installdir", instance:installdir()) +end + -- register the required local package function _register_required_package(instance, requireinfo) @@ -85,6 +90,7 @@ function _register_required_package(instance, requireinfo) -- add packages info with all dependencies local envs = {} + _register_required_package_base(instance, requireinfo) _register_required_package_libs(instance, requireinfo) _register_required_package_envs(instance, envs) local orderdeps = instance:orderdeps() diff --git a/xmake/core/project/requireinfo.lua b/xmake/core/project/requireinfo.lua index 0c90e6fb5..218f346ff 100644 --- a/xmake/core/project/requireinfo.lua +++ b/xmake/core/project/requireinfo.lua @@ -108,6 +108,11 @@ function requireinfo:requirestr() return self:get("__requirestr") end +-- get the install directory +function requireinfo:installdir() + return self:get("__installdir") +end + -- get the extra info from the given name function requireinfo:extra(name) local extrainfo = self:extrainfo() diff --git a/xmake/toolchains/llvm/check.lua b/xmake/toolchains/llvm/check.lua index eaebf8eaa..f22d65f5e 100644 --- a/xmake/toolchains/llvm/check.lua +++ b/xmake/toolchains/llvm/check.lua @@ -62,8 +62,20 @@ function main(toolchain) end end - -- find cross toolchain + -- find cross toolchain from external envirnoment local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir}) + if not cross_toolchain then + -- find it from packages + for _, package in ipairs(toolchain:packages()) do + local installdir = package:installdir() + if installdir and os.isdir(installdir) then + cross_toolchain = find_cross_toolchain(installdir) + if cross_toolchain then + break + end + end + end + end if cross_toolchain then config.set("cross", cross_toolchain.cross, {readonly = true, force = true}) config.set("bin", cross_toolchain.bindir, {readonly = true, force = true}) |
