summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-16 00:45:51 +0800
committerruki <[email protected]>2020-12-16 00:45:51 +0800
commitb3d4c235f88fb14f0aa42c2704727a104ab33fd2 (patch)
tree16583126000d6b88da0b1eaf1294a4aba692f72f
parentdcdd8e5712a863fe225539a09671a7a6a73d60b6 (diff)
improve toolchain for xcode
-rw-r--r--xmake/modules/detect/sdks/find_xcode.lua11
-rw-r--r--xmake/rules/xcode/info_plist/xmake.lua8
-rw-r--r--xmake/rules/xcode/storyboard/xmake.lua13
-rw-r--r--xmake/rules/xcode/xcassets/xmake.lua13
-rw-r--r--xmake/toolchains/xcode/check.lua20
-rw-r--r--xmake/toolchains/xcode/load_iphoneos.lua4
-rw-r--r--xmake/toolchains/xcode/load_macosx.lua4
-rw-r--r--xmake/toolchains/xcode/load_watchos.lua4
8 files changed, 40 insertions, 37 deletions
diff --git a/xmake/modules/detect/sdks/find_xcode.lua b/xmake/modules/detect/sdks/find_xcode.lua
index 1177685a5..a42ee1985 100644
--- a/xmake/modules/detect/sdks/find_xcode.lua
+++ b/xmake/modules/detect/sdks/find_xcode.lua
@@ -147,19 +147,12 @@ function main(sdkdir, opt)
local plat = opt.plat or config.get("plat") or "macosx"
local arch = opt.arch or config.get("arch") or "x86_64"
- -- get xcode sdk version
- local xcode_sdkver = (plat == config.plat()) and config.get("xcode_sdkver")
- if not xcode_sdkver then
- xcode_sdkver = config.get("xcode_sdkver_" .. plat)
- end
-
-- find xcode
- local xcode = _find_xcode(sdkdir or config.get("xcode") or global.get("xcode"), opt.sdkver or xcode_sdkver, plat, arch)
+ 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_sdkver_" .. plat, xcode.sdkver, {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})
@@ -191,7 +184,5 @@ function main(sdkdir, opt)
-- save to cache
cacheinfo.xcode = xcode or false
cache.save(key, cacheinfo)
-
- -- ok?
return xcode
end
diff --git a/xmake/rules/xcode/info_plist/xmake.lua b/xmake/rules/xcode/info_plist/xmake.lua
index 5b36277d4..9d8d47731 100644
--- a/xmake/rules/xcode/info_plist/xmake.lua
+++ b/xmake/rules/xcode/info_plist/xmake.lua
@@ -31,6 +31,7 @@ rule("xcode.info_plist")
import("core.base.option")
import("core.theme.theme")
import("core.project.depend")
+ import("core.tool.toolchain")
import("private.utils.progress")
-- check
@@ -60,8 +61,13 @@ rule("xcode.info_plist")
PRODUCT_NAME = target:name(),
PRODUCT_DISPLAY_NAME = target:name(),
CURRENT_PROJECT_VERSION = target:version() and tostring(target:version()) or "1.0",
- MACOSX_DEPLOYMENT_TARGET = get_config("target_minver_macosx")
}
+ if target:is_plat("macosx") then
+ local toolchain_xcode = toolchain.load("xcode", {plat = target:plat(), arch = target:arch()})
+ if toolchain_xcode then
+ maps.MACOSX_DEPLOYMENT_TARGET = toolchain_xcode:config("target_minver")
+ end
+ end
if target:rule("xcode.bundle") then
maps.PRODUCT_BUNDLE_PACKAGE_TYPE = "BNDL"
elseif target:rule("xcode.framework") then
diff --git a/xmake/rules/xcode/storyboard/xmake.lua b/xmake/rules/xcode/storyboard/xmake.lua
index 83b04fbb0..95a9c9aed 100644
--- a/xmake/rules/xcode/storyboard/xmake.lua
+++ b/xmake/rules/xcode/storyboard/xmake.lua
@@ -31,6 +31,7 @@ rule("xcode.storyboard")
import("core.base.option")
import("core.theme.theme")
import("core.project.depend")
+ import("core.tool.toolchain")
import("private.utils.progress")
-- get xcode sdk directory
@@ -57,14 +58,16 @@ rule("xcode.storyboard")
os.tryrm(base_lproj)
-- do compile
- local target_minver
+ local target_minver = nil
+ local toolchain_xcode = toolchain.load("xcode", {plat = target:plat(), arch = target:arch()})
+ if toolchain_xcode then
+ target_minver = toolchain_xcode:config("target_minver")
+ end
local argv = {"--errors", "--warnings", "--notices", "--auto-activate-custom-fonts", "--output-format", "human-readable-text"}
- if is_plat("macosx") then
- target_minver = get_config("target_minver_macosx")
+ if target:is_plat("macosx") then
table.insert(argv, "--target-device")
table.insert(argv, "mac")
- elseif is_plat("iphoneos") then
- target_minver = get_config("target_minver_iphoneos")
+ elseif target:is_plat("iphoneos") then
table.insert(argv, "--target-device")
table.insert(argv, "iphone")
table.insert(argv, "--target-device")
diff --git a/xmake/rules/xcode/xcassets/xmake.lua b/xmake/rules/xcode/xcassets/xmake.lua
index 5c1912dd4..31c26a56d 100644
--- a/xmake/rules/xcode/xcassets/xmake.lua
+++ b/xmake/rules/xcode/xcassets/xmake.lua
@@ -31,6 +31,7 @@ rule("xcode.xcassets")
import("core.base.option")
import("core.theme.theme")
import("core.project.depend")
+ import("core.tool.toolchain")
import("private.utils.progress")
-- get xcode sdk directory
@@ -60,16 +61,18 @@ rule("xcode.xcassets")
io.writefile(assetcatalog_generated_info_plist, "")
-- do compile
- local target_minver
+ local target_minver = nil
+ local toolchain_xcode = toolchain.load("xcode", {plat = target:plat(), arch = target:arch()})
+ if toolchain_xcode then
+ target_minver = toolchain_xcode:config("target_minver")
+ end
local argv = {"--warnings", "--notices", "--output-format", "human-readable-text"}
- if is_plat("macosx") then
- target_minver = get_config("target_minver_macosx")
+ if target:is_plat("macosx") then
table.insert(argv, "--target-device")
table.insert(argv, "mac")
table.insert(argv, "--platform")
table.insert(argv, "macosx")
- elseif is_plat("iphoneos") then
- target_minver = get_config("target_minver_iphoneos")
+ elseif target:is_plat("iphoneos") then
table.insert(argv, "--target-device")
table.insert(argv, "iphone")
table.insert(argv, "--target-device")
diff --git a/xmake/toolchains/xcode/check.lua b/xmake/toolchains/xcode/check.lua
index 579def16c..c815cf5d0 100644
--- a/xmake/toolchains/xcode/check.lua
+++ b/xmake/toolchains/xcode/check.lua
@@ -27,8 +27,13 @@ import("detect.sdks.find_xcode")
function main(toolchain)
-- find xcode
- local xcode = find_xcode(config.get("xcode"), {force = not optional, verbose = true, plat = toolchain:plat(), arch = toolchain:arch()})
+ local xcode_sdkver = toolchain:config("xcode_sdkver") or config.get("xcode_sdkver")
+ local xcode = find_xcode(config.get("xcode"), {force = not optional, verbose = true,
+ sdkver = xcode_sdkver,
+ plat = toolchain:plat(),
+ arch = toolchain:arch()})
if xcode then
+ xcode_sdkver = xcode.sdkver
config.set("xcode", xcode.sdkdir, {force = true, readonly = true})
else
return false
@@ -44,14 +49,7 @@ function main(toolchain)
-- target("test")
-- set_toolchains("xcode", {plat = os.host(), arch = os.arch()})
--
- local xcode_sdkver = toolchain:is_plat(config.plat()) and config.get("xcode_sdkver")
- if not xcode_sdkver then
- xcode_sdkver = config.get("xcode_sdkver_" .. toolchain:plat())
- end
- local target_minver = toolchain:is_plat(config.plat()) and config.get("target_minver")
- if not target_minver then
- target_minver = config.get("target_minver_" .. toolchain:plat())
- end
+ local target_minver = toolchain:config("target_minver") and config.get("target_minver")
if xcode_sdkver and not target_minver then
target_minver = xcode_sdkver
if toolchain:is_plat("macosx") then
@@ -61,6 +59,8 @@ function main(toolchain)
end
end
end
- config.set("target_minver_" .. toolchain:plat(), target_minver)
+ toolchain:config_set("xcode_sdkver", xcode_sdkver)
+ toolchain:config_set("target_minver", target_minver)
+ toolchain:configs_save()
return true
end
diff --git a/xmake/toolchains/xcode/load_iphoneos.lua b/xmake/toolchains/xcode/load_iphoneos.lua
index cbae31f91..e399f290a 100644
--- a/xmake/toolchains/xcode/load_iphoneos.lua
+++ b/xmake/toolchains/xcode/load_iphoneos.lua
@@ -32,7 +32,7 @@ function main(toolchain)
local platname = simulator and "iPhoneSimulator" or "iPhoneOS"
-- init target minimal version
- local target_minver = config.get("target_minver_iphoneos")
+ local target_minver = toolchain:config("target_minver")
if target_minver and tonumber(target_minver) > 10 and (arch == "armv7" or arch == "armv7s" or arch == "i386") then
target_minver = "10" -- iOS 10 is the maximum deployment target for 32-bit targets
end
@@ -40,7 +40,7 @@ function main(toolchain)
-- init the xcode sdk directory
local xcode_dir = config.get("xcode")
- local xcode_sdkver = config.get("xcode_sdkver_iphoneos")
+ local xcode_sdkver = toolchain:config("xcode_sdkver")
local xcode_sdkdir = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode_dir, platname, platname, xcode_sdkver)
-- init flags for c/c++
diff --git a/xmake/toolchains/xcode/load_macosx.lua b/xmake/toolchains/xcode/load_macosx.lua
index 8b5241b45..86bd03252 100644
--- a/xmake/toolchains/xcode/load_macosx.lua
+++ b/xmake/toolchains/xcode/load_macosx.lua
@@ -26,11 +26,11 @@ function main(toolchain)
-- init flags for architecture
local arch = toolchain:arch()
- local target_minver = config.get("target_minver_macosx")
+ local target_minver = toolchain:config("target_minver")
-- init flags for the xcode sdk directory
local xcode_dir = config.get("xcode")
- local xcode_sdkver = config.get("xcode_sdkver_macosx")
+ local xcode_sdkver = toolchain:config("xcode_sdkver")
local xcode_sdkdir = nil
if xcode_dir and xcode_sdkver then
xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk"
diff --git a/xmake/toolchains/xcode/load_watchos.lua b/xmake/toolchains/xcode/load_watchos.lua
index 6efa6f547..08121277e 100644
--- a/xmake/toolchains/xcode/load_watchos.lua
+++ b/xmake/toolchains/xcode/load_watchos.lua
@@ -32,12 +32,12 @@ function main(toolchain)
local platname = simulator and "WatchSimulator" or "WatchOS"
-- init target minimal version
- local target_minver = config.get("target_minver_watchos")
+ local target_minver = toolchain:config("target_minver")
local target_minver_flags = (simulator and "-mwatchos-simulator-version-min=" or "-mwatchos-version-min=") .. target_minver
-- init the xcode sdk directory
local xcode_dir = config.get("xcode")
- local xcode_sdkver = config.get("xcode_sdkver_watchos")
+ local xcode_sdkver = toolchain:config("xcode_sdkver")
local xcode_sdkdir = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode_dir, platname, platname, xcode_sdkver)
-- init flags for c/c++