From e4ad1cc258a33946d506f1ed8805b2bdbcaeff17 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 29 Oct 2020 17:26:14 -0700 Subject: [PATCH] Create a build setting to allow forcing a Swift target to Apple with bazel transitions. PiperOrigin-RevId: 339779917 --- swift/BUILD | 8 ++++++++ swift/internal/BUILD | 1 + swift/internal/attrs.bzl | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/swift/BUILD b/swift/BUILD index ad1437b20..46f20ac04 100644 --- a/swift/BUILD +++ b/swift/BUILD @@ -49,6 +49,14 @@ bool_setting( build_setting_default = False, ) +# Configuration setting for forcing generation of Apple targets. +# NOTE: this is only intended for use with transitions that want to force +# building of an Apple target when building for Linux. +bool_setting( + name = "force_apple_target", + build_setting_default = False, +) + # Allows a user to override the default Swift driver during a build, if the # toolchain is using the default. label_flag( diff --git a/swift/internal/BUILD b/swift/internal/BUILD index cd917cea9..8c931448c 100644 --- a/swift/internal/BUILD +++ b/swift/internal/BUILD @@ -90,6 +90,7 @@ bzl_library( "@bazel_skylib//lib:dicts", "@bazel_skylib//lib:partial", "@bazel_skylib//lib:paths", + "@bazel_skylib//rules:common_settings", ], ) diff --git a/swift/internal/attrs.bzl b/swift/internal/attrs.bzl index 07f7ffc1d..791980e9e 100644 --- a/swift/internal/attrs.bzl +++ b/swift/internal/attrs.bzl @@ -328,7 +328,7 @@ def swift_toolchain_driver_attrs(): return { "swift_executable": attr.label( allow_single_file = True, - cfg = "host", + cfg = "exec", doc = """\ A replacement Swift driver executable. @@ -340,7 +340,7 @@ that it is invoked in the correct mode (i.e., `swift`, `swiftc`, ), "_default_swift_executable": attr.label( allow_files = True, - cfg = "host", + cfg = "exec", default = Label( "@build_bazel_rules_swift//swift:default_swift_executable", ),