diff options
| author | ruki <[email protected]> | 2020-12-17 00:40:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-12-17 00:40:44 +0800 |
| commit | 8e149f26ccfc93a756074915b5d5f052ba73ed85 (patch) | |
| tree | d2e6d0b509ba4650fb70c9174f358117f3806664 /xmake/modules/detect | |
| parent | 98bdd72d370d044081667a325c27138b2d61892a (diff) | |
improve to check xcode
Diffstat (limited to 'xmake/modules/detect')
| -rw-r--r-- | xmake/modules/detect/sdks/find_xcode.lua | 105 |
1 files changed, 41 insertions, 64 deletions
diff --git a/xmake/modules/detect/sdks/find_xcode.lua b/xmake/modules/detect/sdks/find_xcode.lua index 8416a50b8..4e7a1f677 100644 --- a/xmake/modules/detect/sdks/find_xcode.lua +++ b/xmake/modules/detect/sdks/find_xcode.lua @@ -27,7 +27,7 @@ import("lib.detect.find_directory") import("private.tools.codesign") -- find xcode directory -function _find_sdkdir(sdkdir) +function _find_sdkdir(sdkdir, opt) if sdkdir and os.isdir(sdkdir) then return sdkdir end @@ -35,9 +35,11 @@ function _find_sdkdir(sdkdir) end -- find the sdk version of xcode -function _find_xcode_sdkver(sdkdir, plat, arch) +function _find_xcode_sdkver(sdkdir, opt) -- select platform sdkdir + local plat = opt.plat + local arch = opt.arch local platsdkdir = nil if plat == "iphoneos" then if arch == "i386" or arch == "x86_64" then @@ -65,52 +67,56 @@ function _find_xcode_sdkver(sdkdir, plat, arch) end -- find the xcode toolchain -function _find_xcode(sdkdir, xcode_sdkver, plat, arch) +function _find_xcode(sdkdir, opt) -- find xcode root directory - sdkdir = _find_sdkdir(sdkdir) + sdkdir = _find_sdkdir(sdkdir, opt) if not sdkdir then return {} end -- find the sdk version - local sdkver = xcode_sdkver or _find_xcode_sdkver(sdkdir, plat, arch) + local sdkver = opt.sdkver or _find_xcode_sdkver(sdkdir, opt) if not sdkver then return {} end - -- find codesign identity - local codesign_identity = config.get("xcode_codesign_identity") - if codesign_identity == nil then -- we will disable codesign_identity if be false - codesign_identity = global.get("xcode_codesign_identity") - end - if codesign_identity == nil then - local codesign_identities = codesign.codesign_identities() - if codesign_identities then - for identity, _ in pairs(codesign_identities) do - codesign_identity = identity - break + -- find codesign + if opt.find_codesign then + + -- find codesign identity + local codesign_identity = config.get("xcode_codesign_identity") + if codesign_identity == nil then -- we will disable codesign_identity if be false + codesign_identity = global.get("xcode_codesign_identity") + end + if codesign_identity == nil then + local codesign_identities = codesign.codesign_identities() + if codesign_identities then + for identity, _ in pairs(codesign_identities) do + codesign_identity = identity + break + end end end - end - -- find mobile provision only for iphoneos - local mobile_provision - if plat == "iphoneos" then - local mobile_provisions = codesign.mobile_provisions() - if mobile_provisions then - mobile_provision = config.get("xcode_mobile_provision") - if mobile_provision == nil then -- we will disable mobile_provision if be false - mobile_provision = global.get("xcode_mobile_provision") - end - if mobile_provision == nil then - for provision, _ in pairs(mobile_provisions) do - mobile_provision = provision - break + -- find mobile provision only for iphoneos + local mobile_provision + if opt.plat == "iphoneos" then + local mobile_provisions = codesign.mobile_provisions() + if mobile_provisions then + mobile_provision = config.get("xcode_mobile_provision") + if mobile_provision == nil then -- we will disable mobile_provision if be false + mobile_provision = global.get("xcode_mobile_provision") + end + if mobile_provision == nil then + for provision, _ in pairs(mobile_provisions) do + mobile_provision = provision + break + end + -- valid mobile provision not found? reset it + elseif not mobile_provisions[mobile_provision] then + mobile_provision = nil end - -- valid mobile provision not found? reset it - elseif not mobile_provisions[mobile_provision] then - mobile_provision = nil end end end @@ -121,7 +127,7 @@ end -- -- @param sdkdir the xcode directory -- @param opt the argument options --- e.g. {verbose = true, force = false, sdkver = 19, toolchains_ver = "4.9"} +-- e.g. {verbose = true, force = false, sdkver = 19, find_codesign = true} -- -- @return the xcode toolchain. e.g. {bindir = .., cross = ..} -- @@ -148,36 +154,7 @@ function main(sdkdir, opt) local arch = opt.arch or config.get("arch") or os.arch() -- find xcode - local xcode = _find_xcode(sdkdir or config.get("xcode") or global.get("xcode"), opt.sdkver, plat, arch) - if xcode and xcode.sdkdir then - - -- save to config - config.set("xcode", xcode.sdkdir, {force = true, readonly = true}) - config.set("xcode_codesign_identity", xcode.codesign_identity, {force = true, readonly = true}) - config.set("xcode_mobile_provision", xcode.mobile_provision, {force = true, readonly = true}) - - -- trace - if opt.verbose or option.get("verbose") then - cprint("checking for Xcode directory ... ${color.success}%s", xcode.sdkdir) - cprint("checking for SDK (%s) version of Xcode ... ${color.success}%s", plat, xcode.sdkver) - if xcode.codesign_identity then - cprint("checking for Codesign Identity of Xcode ... ${color.success}%s", xcode.codesign_identity) - else - cprint("checking for Codesign Identity of Xcode ... ${color.nothing}${text.nothing}") - end - if plat == "iphoneos" then - if xcode.mobile_provision then - cprint("checking for Mobile Provision of Xcode ... ${color.success}%s", xcode.mobile_provision) - else - cprint("checking for Mobile Provision of Xcode ... ${color.nothing}${text.nothing}") - end - end - end - else - if opt.verbose or option.get("verbose") then - cprint("checking for Xcode directory ... ${color.nothing}${text.nothing}") - end - end + local xcode = _find_xcode(sdkdir or config.get("xcode") or global.get("xcode"), opt) -- save to cache cacheinfo.xcode = xcode or false |
