Skip to content

Commit 7864ac8

Browse files
authored
Merge pull request #111299 from stuartcarnie/swift_build
Build: Fix container build path for swift
2 parents 816ec99 + ad74ed6 commit 7864ac8

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

platform/ios/detect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def get_opts():
2525

2626
return [
2727
("vulkan_sdk_path", "Path to the Vulkan SDK", ""),
28+
("SWIFT_FRONTEND", "Path to the swift-frontend binary", ""),
2829
# APPLE_TOOLCHAIN_PATH Example: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
2930
(("APPLE_TOOLCHAIN_PATH", "IOS_TOOLCHAIN_PATH"), "Path to the Apple toolchain", ""),
3031
(("APPLE_SDK_PATH", "IOS_SDK_PATH"), "Path to the iOS SDK", ""),

platform/macos/detect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def get_opts():
2929

3030
return [
3131
("osxcross_sdk", "OSXCross SDK version", "darwin16"),
32+
("SWIFT_FRONTEND", "Path to the swift-frontend binary", ""),
3233
("MACOS_SDK_PATH", "Path to the macOS SDK", ""),
3334
("vulkan_sdk_path", "Path to the Vulkan SDK", ""),
3435
EnumVariable("macports_clang", "Build using Clang from MacPorts", "no", ["no", "5.0", "devel"], ignorecase=2),

platform/visionos/detect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def get_opts():
2424
from SCons.Variables import BoolVariable
2525

2626
return [
27+
("SWIFT_FRONTEND", "Path to the swift-frontend binary", ""),
2728
# APPLE_TOOLCHAIN_PATH Example: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
2829
("APPLE_TOOLCHAIN_PATH", "Path to the Apple toolchain", ""),
2930
(("APPLE_SDK_PATH", "VISIONOS_SDK_PATH"), "Path to the visionOS SDK", ""),

platform_methods.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,16 @@ def setup_swift_builder(env, apple_platform, sdk_path, current_path, bridging_he
270270

271271
env["ALL_SWIFT_FILES"] = all_swift_files
272272
env["CURRENT_PATH"] = current_path
273-
frontend_path = "$APPLE_TOOLCHAIN_PATH/usr/bin/swift-frontend"
273+
if "SWIFT_FRONTEND" in env and env["SWIFT_FRONTEND"] != "":
274+
frontend_path = env["SWIFT_FRONTEND"]
275+
elif "osxcross" not in env:
276+
frontend_path = "$APPLE_TOOLCHAIN_PATH/usr/bin/swift-frontend"
277+
else:
278+
frontend_path = None
279+
280+
if frontend_path is None:
281+
raise Exception("Swift frontend path is not set. Please set SWIFT_FRONTEND.")
282+
274283
bridging_header_path = current_path + "/" + bridging_header_filename
275284
env["SWIFTC"] = frontend_path + " -frontend -c" # Swift compiler
276285
env["SWIFTCFLAGS"] = [
@@ -290,6 +299,14 @@ def setup_swift_builder(env, apple_platform, sdk_path, current_path, bridging_he
290299
"-I./", # Pass the current directory as the header root so bridging headers can include files from any point of the hierarchy
291300
]
292301

302+
if "osxcross" in env:
303+
env.Append(
304+
SWIFTCFLAGS=[
305+
"-resource-dir",
306+
"/root/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift",
307+
]
308+
)
309+
293310
if env["debug_symbols"]:
294311
env.Append(SWIFTCFLAGS=["-g"])
295312

0 commit comments

Comments
 (0)