summaryrefslogtreecommitdiff
path: root/xmake/toolchains/xcode
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-15 23:34:01 +0800
committerruki <[email protected]>2023-03-15 23:34:01 +0800
commitf25390857da29aa81bd47c3882fe205bf6569596 (patch)
treed8132ddc965595c3615631c5ee60795eb43f2e67 /xmake/toolchains/xcode
parent01f609b7044a43206d1a05aaa1bdc318116ffad7 (diff)
improve xcode toolchain
Diffstat (limited to 'xmake/toolchains/xcode')
-rw-r--r--xmake/toolchains/xcode/check.lua20
-rw-r--r--xmake/toolchains/xcode/xmake.lua60
2 files changed, 44 insertions, 36 deletions
diff --git a/xmake/toolchains/xcode/check.lua b/xmake/toolchains/xcode/check.lua
index 63faaf8a6..31dae7343 100644
--- a/xmake/toolchains/xcode/check.lua
+++ b/xmake/toolchains/xcode/check.lua
@@ -22,6 +22,7 @@
import("core.base.option")
import("core.project.config")
import("detect.sdks.find_xcode")
+import("private.utils.executable_path")
-- main entry
function main(toolchain)
@@ -90,6 +91,25 @@ function main(toolchain)
if xcode_sysroot then
toolchain:config_set("xcode_sysroot", xcode_sysroot)
end
+ toolchain:config_set("simulator", simulator)
+
+ -- get xcode bin directory
+ local cross
+ if toolchain:is_plat("macosx") then
+ cross = "xcrun -sdk macosx "
+ elseif toolchain:is_plat("iphoneos") then
+ cross = simulator and "xcrun -sdk iphonesimulator " or "xcrun -sdk iphoneos "
+ elseif toolchain:is_plat("watchos") then
+ cross = simulator and "xcrun -sdk watchsimulator " or "xcrun -sdk watchos "
+ elseif toolchain:is_plat("appletvos") then
+ cross = simulator and "xcrun -sdk appletvsimulator " or "xcrun -sdk appletvos "
+ else
+ raise("unknown platform for xcode!")
+ end
+ local xc_clang = executable_path(cross .. "clang")
+ if xc_clang then
+ toolchain:config_set("bindir", path.directory(xc_clang))
+ end
-- save target minver
--
diff --git a/xmake/toolchains/xcode/xmake.lua b/xmake/toolchains/xcode/xmake.lua
index f2b2683ff..da566e3ac 100644
--- a/xmake/toolchains/xcode/xmake.lua
+++ b/xmake/toolchains/xcode/xmake.lua
@@ -34,48 +34,36 @@ toolchain("xcode")
-- load toolchain
on_load(function (toolchain)
- -- get cross
- local cross, arch, simulator
- if toolchain:is_plat("macosx") then
- cross = "xcrun -sdk macosx "
- elseif toolchain:is_plat("iphoneos") then
- arch = toolchain:arch()
- simulator = (arch == "i386" or arch == "x86_64")
- cross = simulator and "xcrun -sdk iphonesimulator " or "xcrun -sdk iphoneos "
- elseif toolchain:is_plat("watchos") then
- arch = toolchain:arch()
- simulator = (arch == "i386")
- cross = simulator and "xcrun -sdk watchsimulator " or "xcrun -sdk watchos "
- elseif toolchain:is_plat("appletvos") then
- arch = toolchain:arch()
- simulator = (arch == "i386" or arch == "x86_64")
- cross = simulator and "xcrun -sdk appletvsimulator " or "xcrun -sdk appletvos "
- else
- raise("unknown platform for xcode!")
- end
-
-- set toolset
- toolchain:set("toolset", "cc", cross .. "clang")
- toolchain:set("toolset", "cxx", cross .. "clang", cross .. "clang++")
- toolchain:set("toolset", "ld", cross .. "clang++", cross .. "clang")
- toolchain:set("toolset", "sh", cross .. "clang++", cross .. "clang")
- toolchain:set("toolset", "ar", cross .. "ar")
- toolchain:set("toolset", "strip", cross .. "strip")
- toolchain:set("toolset", "dsymutil", cross .. "dsymutil", "dsymutil")
- toolchain:set("toolset", "mm", cross .. "clang")
- toolchain:set("toolset", "mxx", cross .. "clang", cross .. "clang++")
- toolchain:set("toolset", "sc", cross .. "swiftc", "swiftc")
- toolchain:set("toolset", "scld", cross .. "swiftc", "swiftc")
- toolchain:set("toolset", "scsh", cross .. "swiftc", "swiftc")
+ local bindir = toolchain:bindir()
+ local xc_clang = bindir and path.join(bindir, "clang") or "clang"
+ local xc_clangxx = bindir and path.join(bindir, "clang++") or "clang++"
+ local xc_ar = bindir and path.join(bindir, "ar") or "ar"
+ local xc_strip = bindir and path.join(bindir, "strip") or "strip"
+ local xc_swiftc = bindir and path.join(bindir, "swiftc") or "swiftc"
+ local xc_dsymutil = bindir and path.join(bindir, "dsymutil") or "dsymutil"
+
+ toolchain:set("toolset", "cc", xc_clang)
+ toolchain:set("toolset", "cxx", xc_clang, xc_clangxx)
+ toolchain:set("toolset", "ld", xc_clangxx, xc_clang)
+ toolchain:set("toolset", "sh", xc_clangxx, xc_clang)
+ toolchain:set("toolset", "ar", xc_ar)
+ toolchain:set("toolset", "strip", xc_strip)
+ toolchain:set("toolset", "dsymutil", xc_dsymutil, "dsymutil")
+ toolchain:set("toolset", "mm", xc_clang)
+ toolchain:set("toolset", "mxx", xc_clang, xc_clangxx)
+ toolchain:set("toolset", "sc", xc_swiftc, "swiftc")
+ toolchain:set("toolset", "scld", xc_swiftc, "swiftc")
+ toolchain:set("toolset", "scsh", xc_swiftc, "swiftc")
if arch then
- toolchain:set("toolset", "cpp", cross .. "clang -arch " .. arch .. " -E")
+ toolchain:set("toolset", "cpp", xc_clang .. " -arch " .. arch .. " -E")
end
if toolchain:is_plat("macosx") then
- toolchain:set("toolset", "as", cross .. "clang")
+ toolchain:set("toolset", "as", xc_clang)
elseif simulator then
- toolchain:set("toolset", "as", cross .. "clang")
+ toolchain:set("toolset", "as", xc_clang)
else
- toolchain:set("toolset", "as", path.join(os.programdir(), "scripts", "gas-preprocessor.pl " .. cross) .. "clang")
+ toolchain:set("toolset", "as", path.join(os.programdir(), "scripts", "gas-preprocessor.pl " .. xc_clang))
end
-- load configurations