Skip to content

Commit 646d6d2

Browse files
authored
Get triple from the make variable CC_TARGET_TRIPLE (#1558)
Allow overriding the target triple used by the Xcode Swift toolchain through the CC_TARGET_TRIPLE environment variable. As cc_toolchain.target_gnu_system_name is getting deprecated, and as rules based toolchain currently don't offer the option to set it anymore, this offers a way by which someone can define a rules based toolchain and still have working swift rules.
1 parent ccebe4d commit 646d6d2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

swift/toolchains/swift_toolchain.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def _swift_toolchain_impl(ctx):
416416
os = ctx.attr.os,
417417
target_system_name = cc_toolchain.target_gnu_system_name,
418418
)
419-
target_triple = target_triples.normalize_for_swift(
419+
target_triple = ctx.var.get("CC_TARGET_TRIPLE") or target_triples.normalize_for_swift(
420420
target_triples.parse(target_system_name),
421421
)
422422

swift/toolchains/xcode_swift_toolchain.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ def _xcode_swift_toolchain_impl(ctx):
627627
apple_toolchain = apple_common.apple_toolchain()
628628
cc_toolchain = find_cpp_toolchain(ctx)
629629

630-
target_triple = target_triples.normalize_for_swift(
630+
target_triple = ctx.var.get("CC_TARGET_TRIPLE") or target_triples.normalize_for_swift(
631631
target_triples.parse(cc_toolchain.target_gnu_system_name),
632632
)
633633

0 commit comments

Comments
 (0)