Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions swift/toolchains/swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load(
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
"find_cpp_toolchain",
"use_cpp_toolchain",
)
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
Expand Down Expand Up @@ -92,6 +91,8 @@ load(
)
load("//swift/toolchains/config:tool_config.bzl", "ToolConfigInfo")

_CPP_TOOLCHAIN_TYPE = Label("@bazel_tools//tools/cpp:toolchain_type")

def _swift_compile_resource_set(_os, inputs_size):
# The `os` argument is unused, but the Starlark API requires both
# positional arguments.
Expand Down Expand Up @@ -410,7 +411,7 @@ def _parse_target_system_name(*, arch, os, target_system_name):

def _swift_toolchain_impl(ctx):
toolchain_root = ctx.attr.root
cc_toolchain = find_cpp_toolchain(ctx)
cc_toolchain = ctx.exec_groups["default"].toolchains[_CPP_TOOLCHAIN_TYPE].cc
target_system_name = _parse_target_system_name(
arch = ctx.attr.arch,
os = ctx.attr.os,
Expand Down Expand Up @@ -706,7 +707,14 @@ The version of XCTest that the toolchain packages.
},
),
doc = "Represents a Swift compiler toolchain.",
exec_groups = {
# An execution group that has no specific platform requirements. This
# ensures that the execution platform of this Swift toolchain does not
# unnecessarily constrain the execution platform of the C++ toolchain.
"default": exec_group(
toolchains = use_cpp_toolchain(),
),
},
fragments = [] if bazel_features.cc.swift_fragment_removed else ["swift"],
toolchains = use_cpp_toolchain(),
implementation = _swift_toolchain_impl,
)
14 changes: 11 additions & 3 deletions swift/toolchains/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load(
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
"find_cpp_toolchain",
"use_cpp_toolchain",
)
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
Expand Down Expand Up @@ -108,6 +107,8 @@ load(
)
load("//swift/toolchains/config:tool_config.bzl", "ToolConfigInfo")

_CPP_TOOLCHAIN_TYPE = Label("@bazel_tools//tools/cpp:toolchain_type")

def _platform_developer_framework_dir(
apple_toolchain,
target_triple):
Expand Down Expand Up @@ -626,7 +627,7 @@ def _dsym_provider(*, ctx):
def _xcode_swift_toolchain_impl(ctx):
cpp_fragment = ctx.fragments.cpp
apple_toolchain = apple_common.apple_toolchain()
cc_toolchain = find_cpp_toolchain(ctx)
cc_toolchain = ctx.exec_groups["default"].toolchains[_CPP_TOOLCHAIN_TYPE].cc

target_triple = ctx.var.get("CC_TARGET_TRIPLE") or target_triples.normalize_for_swift(
target_triples.parse(cc_toolchain.target_gnu_system_name),
Expand Down Expand Up @@ -998,10 +999,17 @@ for incremental compilation using a persistent mode.
},
),
doc = "Represents a Swift compiler toolchain provided by Xcode.",
exec_groups = {
# An execution group that has no specific platform requirements. This
# ensures that the execution platform of this Swift toolchain does not
# unnecessarily constrain the execution platform of the C++ toolchain.
"default": exec_group(
toolchains = use_cpp_toolchain(),
),
},
fragments = [
"cpp",
"objc",
] + ([] if bazel_features.cc.swift_fragment_removed else ["swift"]),
toolchains = use_cpp_toolchain(),
implementation = _xcode_swift_toolchain_impl,
)
14 changes: 11 additions & 3 deletions test/fixtures/linking/fake_framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

load(
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
"find_cpp_toolchain",
"use_cpp_toolchain",
)
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")

_CPP_TOOLCHAIN_TYPE = Label("@bazel_tools//tools/cpp:toolchain_type")

def _impl(ctx):
binary1 = ctx.actions.declare_file("framework1.framework/framework1")
ctx.actions.write(binary1, "empty")

binary2 = ctx.actions.declare_file("framework2.framework/framework2")
ctx.actions.write(binary2, "empty")

cc_toolchain = find_cpp_toolchain(ctx)
cc_toolchain = ctx.exec_groups["default"].toolchains[_CPP_TOOLCHAIN_TYPE].cc
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
Expand Down Expand Up @@ -56,6 +57,13 @@ fake_framework = rule(
doc = "The C++ toolchain to use.",
),
},
toolchains = use_cpp_toolchain(),
exec_groups = {
# An execution group that has no specific platform requirements. This
# ensures that the execution platform of this Swift toolchain does not
# unnecessarily constrain the execution platform of the C++ toolchain.
"default": exec_group(
toolchains = use_cpp_toolchain(),
),
},
fragments = ["cpp"],
)