summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-03-18 23:29:20 +0800
committerruki <[email protected]>2021-03-18 23:29:20 +0800
commit6c5d06600df7b859791fafb8ea87fd87f63fb825 (patch)
tree87543d39131ce6437a70a4355fb291e7b0867182
parent5f4104bb7c5b188965f30d401762162294764b73 (diff)
improve ndk toolchain
-rw-r--r--tests/projects/bpf/minimal/xmake.lua5
-rw-r--r--xmake/core/package/package.lua32
-rw-r--r--xmake/modules/private/action/require/impl/package.lua1
-rw-r--r--xmake/toolchains/msvc/xmake.lua12
-rw-r--r--xmake/toolchains/ndk/check.lua7
-rw-r--r--xmake/toolchains/ndk/xmake.lua12
6 files changed, 47 insertions, 22 deletions
diff --git a/tests/projects/bpf/minimal/xmake.lua b/tests/projects/bpf/minimal/xmake.lua
index ed9a0dd0c..8507b8aa1 100644
--- a/tests/projects/bpf/minimal/xmake.lua
+++ b/tests/projects/bpf/minimal/xmake.lua
@@ -3,7 +3,10 @@ add_rules("platform.linux.bpf")
add_requires("linux-tools", {configs = {bpftool = true}})
add_requires("libbpf")
-if not is_plat("android") then
+if is_plat("android") then
+ add_requires("ndk >=22.x")
+ set_toolchains("@ndk", {sdkver = "23"})
+else
add_requires("llvm >=10.x")
set_toolchains("@llvm")
add_requires("linux-headers")
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 7c6d0b3d6..f2c437924 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -1362,8 +1362,8 @@ end
-- @return true or false
--
function _instance:has_cfuncs(funcs, opt)
- if self:plat() ~= config.get("plat") then
- -- TODO
+ if not self:is_plat(config.get("plat")) or self:config("toolchains") then
+ -- TODO we also need check it later for package with custom toolchains
return true
end
opt = opt or {}
@@ -1379,8 +1379,8 @@ end
-- @return true or false
--
function _instance:has_cxxfuncs(funcs, opt)
- if self:plat() ~= config.get("plat") then
- -- TODO
+ if not self:is_plat(config.get("plat")) or self:config("toolchains") then
+ -- TODO we also need check it later for package with custom toolchains
return true
end
opt = opt or {}
@@ -1396,8 +1396,8 @@ end
-- @return true or false
--
function _instance:has_ctypes(types, opt)
- if self:plat() ~= config.get("plat") then
- -- TODO
+ if not self:is_plat(config.get("plat")) or self:config("toolchains") then
+ -- TODO we also need check it later for package with custom toolchains
return true
end
opt = opt or {}
@@ -1413,8 +1413,8 @@ end
-- @return true or false
--
function _instance:has_cxxtypes(types, opt)
- if self:plat() ~= config.get("plat") then
- -- TODO
+ if not self:is_plat(config.get("plat")) or self:config("toolchains") then
+ -- TODO we also need check it later for package with custom toolchains
return true
end
opt = opt or {}
@@ -1430,8 +1430,8 @@ end
-- @return true or false
--
function _instance:has_cincludes(includes, opt)
- if self:plat() ~= config.get("plat") then
- -- TODO
+ if not self:is_plat(config.get("plat")) or self:config("toolchains") then
+ -- TODO we also need check it later for package with custom toolchains
return true
end
opt = opt or {}
@@ -1447,8 +1447,8 @@ end
-- @return true or false
--
function _instance:has_cxxincludes(includes, opt)
- if self:plat() ~= config.get("plat") then
- -- TODO
+ if not self:is_plat(config.get("plat")) or self:config("toolchains") then
+ -- TODO we also need check it later for package with custom toolchains
return true
end
opt = opt or {}
@@ -1464,8 +1464,8 @@ end
-- @return true or false
--
function _instance:check_csnippets(snippets, opt)
- if self:plat() ~= config.get("plat") then
- -- TODO
+ if not self:is_plat(config.get("plat")) or self:config("toolchains") then
+ -- TODO we also need check it later for package with custom toolchains
return true
end
opt = opt or {}
@@ -1481,8 +1481,8 @@ end
-- @return true or false
--
function _instance:check_cxxsnippets(snippets, opt)
- if self:plat() ~= config.get("plat") then
- -- TODO
+ if not self:is_plat(config.get("plat")) or self:config("toolchains") then
+ -- TODO we also need check it later for package with custom toolchains
return true
end
opt = opt or {}
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 091984643..c70a933cc 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -342,6 +342,7 @@ function _init_requireinfo(requireinfo, package, opt)
-- pass root toolchains to top library package
if opt.is_toplevel and package:is_cross() and package:is_library() then
requireinfo.configs = requireinfo.configs or {}
+ -- TODO get extra configs of toolchain
requireinfo.configs.toolchains = requireinfo.configs.toolchains or project.get("target.toolchains") or get_config("toolchain")
end
end
diff --git a/xmake/toolchains/msvc/xmake.lua b/xmake/toolchains/msvc/xmake.lua
index 2b9f4eb1e..a79cb4268 100644
--- a/xmake/toolchains/msvc/xmake.lua
+++ b/xmake/toolchains/msvc/xmake.lua
@@ -18,7 +18,17 @@
-- @file xmake.lua
--
--- define toolchain
+-- msvc toolchain
+--
+-- @param vs the vs version
+--
+-- @code
+-- target("test")
+-- ...
+-- set_toolchains("msvc")
+-- set_toolchains("msvc", {vs = "2019"})
+-- @endcode
+--
toolchain("msvc")
-- set homepage
diff --git a/xmake/toolchains/ndk/check.lua b/xmake/toolchains/ndk/check.lua
index 583e6d591..9f54cdb9a 100644
--- a/xmake/toolchains/ndk/check.lua
+++ b/xmake/toolchains/ndk/check.lua
@@ -25,13 +25,13 @@ import("detect.sdks.find_android_sdk")
-- check the ndk toolchain
function _check_ndk(toolchain)
- local ndk = find_ndk(toolchain:config("ndk") or config.get("ndk"), {force = true, verbose = true})
+ local ndk = find_ndk(toolchain:config("ndk") or config.get("ndk"), {force = true, verbose = true, sdkver = toolchain:config("sdkver")})
if not ndk then
-- find it from packages
for _, package in ipairs(toolchain:packages()) do
local installdir = package:installdir()
if installdir and os.isdir(installdir) then
- ndk = find_ndk(installdir, {force = true, verbose = true})
+ ndk = find_ndk(installdir, {force = true, verbose = true, sdkver = toolchain:config("sdkver")})
if ndk then
break
end
@@ -49,11 +49,12 @@ function _check_ndk(toolchain)
toolchain:config_set("ndk_sysroot", ndk.sysroot)
toolchain:configs_save()
else
+ --[[TODO
-- failed
cprint("${bright color.error}please run:")
cprint(" - xmake config --ndk=xxx")
cprint("or - xmake global --ndk=xxx")
- raise()
+ raise()]]
end
end
diff --git a/xmake/toolchains/ndk/xmake.lua b/xmake/toolchains/ndk/xmake.lua
index 099deeae9..609efb4a2 100644
--- a/xmake/toolchains/ndk/xmake.lua
+++ b/xmake/toolchains/ndk/xmake.lua
@@ -18,7 +18,17 @@
-- @file xmake.lua
--
--- define toolchain
+-- android ndk toolchain
+--
+-- @param sdkver the platform sdk version
+--
+-- @code
+-- target("test")
+-- ...
+-- set_toolchains("ndk")
+-- set_toolchains("ndk", {sdkver = "23"})
+-- @endcode
+--
toolchain("ndk")
-- set homepage