summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-04-26 00:55:13 +0800
committerruki <[email protected]>2023-04-26 00:55:13 +0800
commite988ef97f3a07d02a8bf4404beff8a3f2890c9ae (patch)
tree8435b28db033c8034e23dfc555adaa2d84ccfdab
parent2ff74cf8ed1752193abf5de0c5bf2a88646a8e08 (diff)
improve sysroot for macosx #3686
-rw-r--r--xmake/toolchains/xcode/check.lua43
1 files changed, 25 insertions, 18 deletions
diff --git a/xmake/toolchains/xcode/check.lua b/xmake/toolchains/xcode/check.lua
index 31dae7343..e026ddb86 100644
--- a/xmake/toolchains/xcode/check.lua
+++ b/xmake/toolchains/xcode/check.lua
@@ -72,6 +72,24 @@ function main(toolchain)
end
end
+ -- 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 xcode sysroot directory
local xcode_sysroot
if xcode.sdkdir and xcode_sdkver then
@@ -87,30 +105,19 @@ function main(toolchain)
local platname = simulator and "AppleTVSimulator" or "AppleTVOS"
xcode_sysroot = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode.sdkdir, platname, platname, xcode_sdkver)
end
+ else
+ -- maybe it is from CommandLineTools, e.g. /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
+ -- @see https://github.com/xmake-io/xmake/issues/3686
+ local sdkpath = try { function () return os.iorun(cross .. "--show-sdk-path") end }
+ if sdkpath then
+ xcode_sysroot = sdkpath:trim()
+ end
end
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
--
-- @note we need to differentiate the version for the system,