summaryrefslogtreecommitdiff
path: root/xmake/modules/detect
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-24 11:05:01 +0800
committerruki <[email protected]>2017-05-24 11:05:01 +0800
commit0041140dbfebce83293bcd3991760c8651f7a7ee (patch)
tree0dbdb04598df12c820df7b003f9d8cdb6a380834 /xmake/modules/detect
parent59d3a4a90038971d8a7f875bd640bd76b9525dea (diff)
add find ndk and toolchains
Diffstat (limited to 'xmake/modules/detect')
-rw-r--r--xmake/modules/detect/sdk/find_ndk_sdkvers.lua62
-rw-r--r--xmake/modules/detect/sdk/find_ndk_toolchains.lua73
-rw-r--r--xmake/modules/detect/sdk/find_xcode_sdkvers.lua (renamed from xmake/modules/detect/sdk/find_xcode_sdkver.lua)8
3 files changed, 139 insertions, 4 deletions
diff --git a/xmake/modules/detect/sdk/find_ndk_sdkvers.lua b/xmake/modules/detect/sdk/find_ndk_sdkvers.lua
new file mode 100644
index 000000000..16ad5eca7
--- /dev/null
+++ b/xmake/modules/detect/sdk/find_ndk_sdkvers.lua
@@ -0,0 +1,62 @@
+--!The Make-like Build Utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2017, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file find_ndk_sdkvers.lua
+--
+
+-- find ndk sdk versions
+--
+-- @param ndk_dir the ndk directory
+--
+-- @return the ndk sdk version array
+--
+-- @code
+--
+-- local ndk_sdkvers = find_ndk_sdkvers("/xxx/android-ndk-r10e")
+--
+-- @endcode
+--
+function main(ndk_dir)
+
+ -- get ndk directory
+ if not ndk_dir or not os.isdir(ndk_dir) then
+ return {}
+ end
+
+ -- find all sdk directories
+ local ndk_sdkvers = {}
+ for _, sdkdir in ipairs(os.dirs(path.join(ndk_dir, "platforms/android-*"))) do
+
+ -- get version
+ local filename = path.filename(sdkdir)
+ local version, count = filename:gsub("android%-", "")
+ if count > 0 then
+
+ -- get the max version
+ if tonumber(version) > 0 then
+ table.insert(ndk_sdkvers, version)
+ end
+ end
+ end
+
+ -- ok?
+ return ndk_sdkvers
+end
diff --git a/xmake/modules/detect/sdk/find_ndk_toolchains.lua b/xmake/modules/detect/sdk/find_ndk_toolchains.lua
new file mode 100644
index 000000000..f7d5b7430
--- /dev/null
+++ b/xmake/modules/detect/sdk/find_ndk_toolchains.lua
@@ -0,0 +1,73 @@
+--!The Make-like Build Utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2017, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file find_ndk_toolchains.lua
+--
+
+-- imports
+import("core.project.config")
+
+-- find ndk toolchains
+--
+-- @param ndk_dir the ndk directory
+-- @param opt the argument options
+-- .e.g {arch = "[armv5te|armv6|armv7-a|armv8-a|arm64-v8a]"}
+--
+-- @return the toolchains array. .e.g {{bin = .., cross = ..}, .. }
+--
+-- @code
+--
+-- local ndk_toolchains = find_ndk_toolchains("/xxx/android-ndk-r10e")
+-- local ndk_toolchains = find_ndk_toolchains("/xxx/android-ndk-r10e", {arch = "arm64-v8a"})
+--
+-- @endcode
+--
+function main(ndk_dir, opt)
+
+ -- init arguments
+ opt = opt or {}
+
+ -- get ndk directory
+ if not ndk_dir or not os.isdir(ndk_dir) then
+ return {}
+ end
+
+ -- get arch
+ local arch = opt.arch or config.get("arch") or "armv7-a"
+
+ -- is arm64?
+ local arm64 = arch and arch:startswith("arm64")
+
+ -- the cross
+ local cross = ifelse(arm64, "aarch64-linux-android-", "arm-linux-androideabi-")
+
+ -- save the toolchains directory
+ local ndk_toolchains = {}
+ for _, bindir in ipairs(os.dirs(path.join(ndk_dir, "toolchains", cross .. "**", "prebuilt/*/bin"))) do
+ local binfiles = os.files(path.join(bindir, cross .. "*"))
+ if binfiles and #binfiles > 0 then
+ table.insert(ndk_toolchains, {bin = bindir, cross = cross})
+ end
+ end
+
+ -- ok?
+ return ndk_toolchains
+end
diff --git a/xmake/modules/detect/sdk/find_xcode_sdkver.lua b/xmake/modules/detect/sdk/find_xcode_sdkvers.lua
index 075379eaf..fb479208c 100644
--- a/xmake/modules/detect/sdk/find_xcode_sdkver.lua
+++ b/xmake/modules/detect/sdk/find_xcode_sdkvers.lua
@@ -19,7 +19,7 @@
-- Copyright (C) 2015 - 2017, TBOOX Open Source Group.
--
-- @author ruki
--- @file find_xcode_sdkver.lua
+-- @file find_xcode_sdkvers.lua
--
-- imports
@@ -35,9 +35,9 @@ import("detect.sdk.find_xcode_dir")
--
-- @code
--
--- local xcode_sdkvers = find_xcode_sdkver()
--- local xcode_sdkvers = find_xcode_sdkver({xcode_dir = ""})
--- local xcode_sdkvers = find_xcode_sdkver({xcode_dir = "", plat = "iphoneos", arch = "arm64"})
+-- local xcode_sdkvers = find_xcode_sdkvers()
+-- local xcode_sdkvers = find_xcode_sdkvers({xcode_dir = ""})
+-- local xcode_sdkvers = find_xcode_sdkvers({xcode_dir = "", plat = "iphoneos", arch = "arm64"})
--
-- @endcode
--