summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-18 12:56:16 +0800
committerruki <[email protected]>2017-05-18 12:56:16 +0800
commitc1165f853e205bbd5bd1395dd4f4a6b725facc8e (patch)
treebe9b7ef31a1f29330c6ce2c274f0cd42a832bc1d
parent1a58cc30d32c677566efcb3006dc537f9c157793 (diff)
improve find xcode sdkver
-rw-r--r--xmake/modules/detect/sdk/find_xcode_sdkver.lua24
-rw-r--r--xmake/platforms/checker.lua65
-rw-r--r--xmake/platforms/iphoneos/check.lua5
-rw-r--r--xmake/platforms/macosx/check.lua5
-rw-r--r--xmake/platforms/watchos/check.lua5
5 files changed, 28 insertions, 76 deletions
diff --git a/xmake/modules/detect/sdk/find_xcode_sdkver.lua b/xmake/modules/detect/sdk/find_xcode_sdkver.lua
index 9e25a0737..6d1fc0857 100644
--- a/xmake/modules/detect/sdk/find_xcode_sdkver.lua
+++ b/xmake/modules/detect/sdk/find_xcode_sdkver.lua
@@ -26,18 +26,18 @@
import("core.project.config")
import("detect.sdk.find_xcode_dir")
--- find xcode sdk version for the given platform
+-- find xcode sdk versions for the given platform
--
-- @param argv the arguments
-- .e.g {xcode_dir = "", plat = "[iphoneos|watchos]", arch = "[armv7|armv7s|arm64|i386|x86_64]"}
--
--- @return the xcode directory
+-- @return the xcode sdk version array
--
-- @code
--
--- local xcode_sdkver = find_xcode_sdkver()
--- local xcode_sdkver = find_xcode_sdkver({xcode_dir = ""})
--- local xcode_sdkver = find_xcode_sdkver({xcode_dir = "", plat = "iphoneos", arch = "arm64"})
+-- 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"})
--
-- @endcode
--
@@ -47,14 +47,15 @@ function main(argv)
argv = argv or {}
-- get xcode directory
+ local xcode_sdkvers = {}
local xcode_dir = argv.xcode_dir or find_xcode_dir()
if not os.isdir(xcode_dir) then
- return
+ return xcode_sdkvers
end
-- get plat and arch
- local plat = argv.plat or config.get("plat")
- local arch = argv.arch or config.get("arch")
+ local plat = argv.plat or config.get("plat") or "macosx"
+ local arch = argv.arch or config.get("arch") or "x86_64"
-- select xcode sdkdir
local xcode_sdkdir = nil
@@ -77,10 +78,13 @@ function main(argv)
-- attempt to match the directory
if xcode_sdkdir then
for _, dir in ipairs(os.dirs(path.join(xcode_dir, xcode_sdkdir))) do
- xcode_sdkver = dir:match("%d+%.%d+")
+ local xcode_sdkver = dir:match("%d+%.%d+")
if xcode_sdkver then
- return xcode_sdkver
+ table.insert(xcode_sdkvers, xcode_sdkver)
end
end
end
+
+ -- ok?
+ return xcode_sdkvers
end
diff --git a/xmake/platforms/checker.lua b/xmake/platforms/checker.lua
index 8bebf730f..e81846353 100644
--- a/xmake/platforms/checker.lua
+++ b/xmake/platforms/checker.lua
@@ -25,6 +25,8 @@
-- imports
import("core.tool.tool")
import("core.base.option")
+import("detect.sdk.find_xcode_dir")
+import("detect.sdk.find_xcode_sdkver")
-- find the given tool
function _toolchain_check(config, toolkind, toolinfo)
@@ -151,28 +153,14 @@ function check_arch(config, default)
end
-- check the xcode application directory
-function check_xcode(config)
+function check_xcode_dir(config)
-- get the xcode directory
local xcode_dir = config.get("xcode_dir")
if not xcode_dir then
- -- attempt to get the default directory
- if not xcode_dir then
- if os.isdir("/Applications/Xcode.app") then
- xcode_dir = "/Applications/Xcode.app"
- end
- end
-
- -- attempt to match the other directories
- if not xcode_dir then
- local dirs = os.match("/Applications/Xcode*.app", true)
- if dirs and #dirs ~= 0 then
- xcode_dir = dirs[1]
- end
- end
-
-- check ok? update it
+ xcode_dir = find_xcode_dir()
if xcode_dir then
-- save it
@@ -197,30 +185,12 @@ function check_xcode_sdkver(config)
-- get plat
local plat = config.get("plat")
- -- the xcode sdk directories
- local xcode_sdkdirs =
- {
- macosx = "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk"
- , iphoneos = "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk"
- , iphonesimulator = "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.sdk"
- , watchos = "/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS*.sdk"
- , watchsimulator = "/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator*.sdk"
- }
-
-- get the xcode sdk version
- local xcode_sdkver = config.get("xcode_sdkver")
+ local xcode_sdkver = config.get("xcode_sdkver")
if not xcode_sdkver then
- -- attempt to match the directory
- if not xcode_sdkver then
- local dirs = os.match(config.get("xcode_dir") .. xcode_sdkdirs[plat], true)
- for _, dir in ipairs(dirs) do
- xcode_sdkver = string.match(dir, "%d+%.%d+")
- if xcode_sdkver then break end
- end
- end
-
-- check ok? update it
+ xcode_sdkver = find_xcode_sdkver({xcode_dir = config.get("xcode_dir"), plat = config.get("plat"), arch = config.get("arch")})[1]
if xcode_sdkver then
-- save it
@@ -237,30 +207,11 @@ function check_xcode_sdkver(config)
raise()
end
end
-end
-
--- check the target minimal version
-function check_target_minver(config)
- -- get the target minimal version
+ -- get target minver
local target_minver = config.get("target_minver")
if not target_minver then
-
- -- the default versions
- local versions =
- {
- macosx = "10.9"
- , iphoneos = "7.0"
- , iphonesimulator = "7.0"
- , watchos = "2.1"
- , watchsimulator = "2.1"
- }
-
- -- init the default target minimal version
- config.set("target_minver", config.get("xcode_sdkver") or versions[config.get("plat")])
-
- -- trace
- cprint("checking for the target minimal version ... ${green}%s", config.get("target_minver"))
+ config.set("target_minver", xcode_sdkver)
end
end
diff --git a/xmake/platforms/iphoneos/check.lua b/xmake/platforms/iphoneos/check.lua
index e5217b2a1..d8a4e1bce 100644
--- a/xmake/platforms/iphoneos/check.lua
+++ b/xmake/platforms/iphoneos/check.lua
@@ -106,15 +106,14 @@ function main(kind, toolkind)
_g.config =
{
{ checker.check_arch, "armv7" }
- , checker.check_xcode
+ , checker.check_xcode_dir
, checker.check_xcode_sdkver
- , checker.check_target_minver
}
-- init the check list of global
_g.global =
{
- checker.check_xcode
+ checker.check_xcode_dir
}
-- check it
diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua
index 14b5ef42b..6aec3fa2d 100644
--- a/xmake/platforms/macosx/check.lua
+++ b/xmake/platforms/macosx/check.lua
@@ -109,15 +109,14 @@ function main(kind, toolkind)
_g.config =
{
checker.check_arch
- , checker.check_xcode
+ , checker.check_xcode_dir
, checker.check_xcode_sdkver
- , checker.check_target_minver
}
-- init the check list of global
_g.global =
{
- checker.check_xcode
+ checker.check_xcode_dir
}
-- check it
diff --git a/xmake/platforms/watchos/check.lua b/xmake/platforms/watchos/check.lua
index 80db91aea..f4e7bab19 100644
--- a/xmake/platforms/watchos/check.lua
+++ b/xmake/platforms/watchos/check.lua
@@ -106,15 +106,14 @@ function main(kind, toolkind)
_g.config =
{
{ checker.check_arch, "armv7k" }
- , checker.check_xcode
+ , checker.check_xcode_dir
, checker.check_xcode_sdkver
- , checker.check_target_minver
}
-- init the check list of global
_g.global =
{
- checker.check_xcode
+ checker.check_xcode_dir
}
-- check it