summaryrefslogtreecommitdiff
path: root/xmake/rules/xcode
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-17 10:59:28 +0800
committerGitHub <[email protected]>2020-12-17 10:59:28 +0800
commite95f99d7d99daf3c065dd04d457b2a8a81545380 (patch)
tree72816b1c749dd12e31da06b9b9d97ffc8d057866 /xmake/rules/xcode
parent37521d4aa857d57773b0f6cb9311856d3787c6f5 (diff)
parent98a044d2947d070d035fe76c651fdbf9f0c3b135 (diff)
Merge pull request #1141 from xmake-io/toolchain
Improve toolchain
Diffstat (limited to 'xmake/rules/xcode')
-rw-r--r--xmake/rules/xcode/application/build.lua4
-rw-r--r--xmake/rules/xcode/application/install.lua6
-rw-r--r--xmake/rules/xcode/application/load.lua6
-rw-r--r--xmake/rules/xcode/application/package.lua2
-rw-r--r--xmake/rules/xcode/application/run.lua4
-rw-r--r--xmake/rules/xcode/application/uninstall.lua4
-rw-r--r--xmake/rules/xcode/bundle/xmake.lua4
-rw-r--r--xmake/rules/xcode/info_plist/xmake.lua8
-rw-r--r--xmake/rules/xcode/storyboard/xmake.lua15
-rw-r--r--xmake/rules/xcode/xcassets/xmake.lua15
10 files changed, 40 insertions, 28 deletions
diff --git a/xmake/rules/xcode/application/build.lua b/xmake/rules/xcode/application/build.lua
index 432ab8bf9..a83e42684 100644
--- a/xmake/rules/xcode/application/build.lua
+++ b/xmake/rules/xcode/application/build.lua
@@ -41,7 +41,7 @@ function main (target, opt)
-- copy target file
local binarydir = contentsdir
- if is_plat("macosx") then
+ if target:is_plat("macosx") then
binarydir = path.join(contentsdir, "MacOS")
end
os.vcp(target:targetfile(), path.join(binarydir, path.filename(target:targetfile())))
@@ -72,7 +72,7 @@ function main (target, opt)
-- generate embedded.mobileprovision to *.app/embedded.mobileprovision
local mobile_provision_embedded = path.join(bundledir, "embedded.mobileprovision")
local mobile_provision = target:values("xcode.mobile_provision") or get_config("xcode_mobile_provision")
- if mobile_provision and is_plat("iphoneos") then
+ if mobile_provision and target:is_plat("iphoneos") then
os.tryrm(mobile_provision_embedded)
local provisions = codesign.mobile_provisions()
if provisions then
diff --git a/xmake/rules/xcode/application/install.lua b/xmake/rules/xcode/application/install.lua
index bc76248ab..dee303ce4 100644
--- a/xmake/rules/xcode/application/install.lua
+++ b/xmake/rules/xcode/application/install.lua
@@ -62,13 +62,13 @@ end
-- main entry
function main (target)
- if is_plat("iphoneos") then
- if is_arch("x86_64", "i386") then
+ if target:is_plat("iphoneos") then
+ if target:is_arch("x86_64", "i386") then
_install_for_ios_simulator(target)
else
_install_for_ios(target)
end
- elseif is_plat("macosx") then
+ elseif target:is_plat("macosx") then
_install_for_macosx(target)
end
end
diff --git a/xmake/rules/xcode/application/load.lua b/xmake/rules/xcode/application/load.lua
index e4f76191e..7cf0625f0 100644
--- a/xmake/rules/xcode/application/load.lua
+++ b/xmake/rules/xcode/application/load.lua
@@ -29,7 +29,7 @@ function main (target)
-- get contents and resources directory
local contentsdir = bundledir
local resourcesdir = bundledir
- if is_plat("macosx") then
+ if target:is_plat("macosx") then
contentsdir = path.join(bundledir, "Contents")
resourcesdir = path.join(bundledir, "Contents", "Resources")
end
@@ -41,12 +41,12 @@ function main (target)
target:set("filename", target:basename())
-- set install directory
- if is_plat("macosx") and not target:get("installdir") then
+ if target:is_plat("macosx") and not target:get("installdir") then
target:set("installdir", "/Applications")
end
-- add frameworks
- if is_plat("macosx") then
+ if target:is_plat("macosx") then
target:add("frameworks", "AppKit")
else
target:add("frameworks", "UIKit")
diff --git a/xmake/rules/xcode/application/package.lua b/xmake/rules/xcode/application/package.lua
index d7aa9cbfd..bcf8d60fe 100644
--- a/xmake/rules/xcode/application/package.lua
+++ b/xmake/rules/xcode/application/package.lua
@@ -40,7 +40,7 @@ end
-- main entry
function main (target, opt)
- if is_plat("iphoneos") then
+ if target:is_plat("iphoneos") then
_package_for_ios(target)
end
end
diff --git a/xmake/rules/xcode/application/run.lua b/xmake/rules/xcode/application/run.lua
index 19bbf9b85..14a7c0f12 100644
--- a/xmake/rules/xcode/application/run.lua
+++ b/xmake/rules/xcode/application/run.lua
@@ -87,9 +87,9 @@ end
-- main entry
function main (target, opt)
- if is_plat("macosx") then
+ if target:is_plat("macosx") then
_run_on_macosx(target, opt)
- elseif is_plat("iphoneos") and is_arch("x86_64", "i386") then
+ elseif target:is_plat("iphoneos") and target:is_arch("x86_64", "i386") then
_run_on_simulator(target, opt)
else
raise("we can only run application on macOS or simulator!")
diff --git a/xmake/rules/xcode/application/uninstall.lua b/xmake/rules/xcode/application/uninstall.lua
index be06e9fff..421cb8e83 100644
--- a/xmake/rules/xcode/application/uninstall.lua
+++ b/xmake/rules/xcode/application/uninstall.lua
@@ -38,9 +38,9 @@ end
-- main entry
function main (target)
- if is_plat("iphoneos") then
+ if target:is_plat("iphoneos") then
_uninstall_for_ios(target)
- elseif is_plat("macosx") then
+ elseif target:is_plat("macosx") then
_uninstall_for_macosx(target)
end
end
diff --git a/xmake/rules/xcode/bundle/xmake.lua b/xmake/rules/xcode/bundle/xmake.lua
index c96fc72ac..9cbd92b6f 100644
--- a/xmake/rules/xcode/bundle/xmake.lua
+++ b/xmake/rules/xcode/bundle/xmake.lua
@@ -35,7 +35,7 @@ rule("xcode.bundle")
-- get contents and resources directory
local contentsdir = bundledir
local resourcesdir = bundledir
- if is_plat("macosx") then
+ if target:is_plat("macosx") then
contentsdir = path.join(bundledir, "Contents")
resourcesdir = path.join(bundledir, "Contents", "Resources")
end
@@ -74,7 +74,7 @@ rule("xcode.bundle")
progress.show(opt.progress, "${color.build.target}generating.xcode.$(mode) %s", path.filename(bundledir))
-- copy target file
- if is_plat("macosx") then
+ if target:is_plat("macosx") then
os.vcp(target:targetfile(), path.join(contentsdir, "MacOS", path.filename(target:targetfile())))
else
os.vcp(target:targetfile(), path.join(contentsdir, path.filename(target:targetfile())))
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..bfa88e6e1 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")
@@ -83,7 +86,7 @@ rule("xcode.storyboard")
-- do link
argv = {"--errors", "--warnings", "--notices", "--auto-activate-custom-fonts", "--output-format", "human-readable-text"}
- if is_plat("macosx") then
+ if target:is_plat("macosx") then
table.insert(argv, "--target-device")
table.insert(argv, "mac")
end
diff --git a/xmake/rules/xcode/xcassets/xmake.lua b/xmake/rules/xcode/xcassets/xmake.lua
index 5c1912dd4..d20fc278c 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")
@@ -85,7 +88,7 @@ rule("xcode.xcassets")
end
table.insert(argv, "--app-icon")
table.insert(argv, "AppIcon")
- if is_plat("iphoneos") then
+ if target:is_plat("iphoneos") then
table.insert(argv, "--enable-on-demand-resources")
table.insert(argv, "YES")
table.insert(argv, "--compress-pngs")