Skip to content

Commit

Permalink
Remove the emit_swiftinterface build setting.
Browse files Browse the repository at this point in the history
This was only present to support Apple framework rules, but its design was flawed, so they no longer use it. Library evolution shouldn't be enabled for entire dependency subgraphs; authors of SDKs should explicitly enable it on their libraries with the `library_evolution` attribute.

PiperOrigin-RevId: 629786303
  • Loading branch information
allevato authored and swiple-rules-gardener committed May 1, 2024
1 parent 86f356c commit 1ee51c8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 31 deletions.
8 changes: 0 additions & 8 deletions swift/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:common_settings.bzl", "bool_setting")
load(
"//swift/internal:build_settings.bzl",
"per_module_swiftcopt_flag",
Expand Down Expand Up @@ -265,13 +264,6 @@ per_module_swiftcopt_flag(
visibility = ["//visibility:public"],
)

# Configuration setting for enabling the generation of swiftinterface files.
bool_setting(
name = "emit_swiftinterface",
build_setting_default = False,
visibility = ["//visibility:public"],
)

# Allows a user to override the default Swift driver during a build, if the
# toolchain is using the default.
label_flag(
Expand Down
7 changes: 3 additions & 4 deletions swift/internal/attrs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ indirect (transitive) dependents.
),
# Deprecated, but Starlark rules do not inherit `licenses` by default
# (see b/169635467).
"licenses": attr.license(), # buildifier: disable=attr-license
# buildifier: disable=attr-license
# buildifier: disable=attr-licenses
"licenses": attr.license(),
}

def swift_compilation_attrs(
Expand Down Expand Up @@ -172,9 +174,6 @@ def swift_config_attrs():
configuration settings.
"""
return {
"_config_emit_swiftinterface": attr.label(
default = "@build_bazel_rules_swift//swift:emit_swiftinterface",
),
"_per_module_swiftcopt": attr.label(
default = "@build_bazel_rules_swift//swift:per_module_swiftcopt",
),
Expand Down
13 changes: 0 additions & 13 deletions swift/internal/swift_protoc_gen_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""An aspect attached to `proto_library` targets to generate Swift artifacts."""

load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load(
"@build_bazel_rules_swift//swift:module_name.bzl",
"derive_swift_module_name",
Expand All @@ -30,8 +29,6 @@ load(":attrs.bzl", "swift_config_attrs")
load(":compiling.bzl", "compile")
load(
":feature_names.bzl",
"SWIFT_FEATURE_EMIT_SWIFTINTERFACE",
"SWIFT_FEATURE_ENABLE_LIBRARY_EVOLUTION",
"SWIFT_FEATURE_ENABLE_TESTING",
"SWIFT_FEATURE_LAYERING_CHECK_SWIFT",
)
Expand Down Expand Up @@ -236,16 +233,6 @@ def _swift_protoc_gen_aspect_impl(target, aspect_ctx):

extra_features = []

# This feature is not fully supported because the SwiftProtobuf library
# has not yet been designed to fully support library evolution. The
# intent of this is to allow users building distributable frameworks to
# use Swift protos as an _implementation-only_ detail of their
# framework, where those protos would not be exposed to clients in the
# API. Rely on it at your own risk.
if aspect_ctx.attr._config_emit_swiftinterface[BuildSettingInfo].value:
extra_features.append(SWIFT_FEATURE_ENABLE_LIBRARY_EVOLUTION)
extra_features.append(SWIFT_FEATURE_EMIT_SWIFTINTERFACE)

# Compile the generated Swift sources and produce a static library and a
# .swiftmodule as outputs. In addition to the other proto deps, we also
# pass support libraries like the SwiftProtobuf runtime as deps to the
Expand Down
7 changes: 1 addition & 6 deletions swift/swift_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_skylib//lib:sets.bzl", "sets")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load(
"@build_bazel_rules_swift//swift/internal:attrs.bzl",
"swift_deps_attr",
Expand Down Expand Up @@ -140,11 +139,7 @@ def _swift_library_impl(ctx):

extra_features = []

# TODO(b/239957001): Remove the global flag.
if (
ctx.attr.library_evolution or
ctx.attr._config_emit_swiftinterface[BuildSettingInfo].value
):
if ctx.attr.library_evolution:
extra_features.append(SWIFT_FEATURE_ENABLE_LIBRARY_EVOLUTION)
extra_features.append(SWIFT_FEATURE_EMIT_SWIFTINTERFACE)

Expand Down

1 comment on commit 1ee51c8

@brentleyjones
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.