-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Boolean
library_evolution
attribute to swift_library
Historically, library evolution has been supported by a global flag that Apple framework rules transition on in order to build all dependencies with library evolution enabled. In retrospect, this is wrong; we shouldn't be automatically applying library evolution to the whole subgraph in this way. Instead, the owner of the framework should explicitly specify library evolution on the client-facing modules that make up their SDK. The goal here is to ensure that framework owners carefully audit their public `deps` vs. implementation-only `private_deps` so that the `.swiftinterface` doesn't attempt to import anything that it shouldn't, especially with Swift 5.7 validating emitted interfaces after compilation by default. This change only adds the new attribute; the flag is still honored while we have clients and rules_apple depending on it. PiperOrigin-RevId: 486750877 (cherry picked from commit b9175e6) Cherry-pick notes: With this change the private swiftinterface is enabled by `ctx.attr.library_evolution` as well. It can be disabled with `features = ["-swift.emit_private_swiftinterface”]`. Signed-off-by: Brentley Jones <github@brentleyjones.com>
- Loading branch information
1 parent
d8cc3ea
commit 7e14958
Showing
12 changed files
with
178 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
load("//swift:swift_library.bzl", "swift_library") | ||
load( | ||
"//test/fixtures:common.bzl", | ||
"FIXTURE_TAGS", | ||
) | ||
load( | ||
"//test/rules:swift_library_artifact_collector.bzl", | ||
"swift_library_artifact_collector", | ||
) | ||
|
||
package( | ||
default_testonly = True, | ||
default_visibility = ["//test:__subpackages__"], | ||
) | ||
|
||
licenses(["notice"]) | ||
|
||
# Checking in pre-built artifacts like a `.swiftinterface` and static libraries | ||
# would require different artifacts for every platform the test might run on. | ||
# Instead, build it on-demand but forward the outputs using the "artifact | ||
# collector" rule below to make them act as if they were pre-built outputs when | ||
# referenced by the `swift_import` rule. | ||
# | ||
# These must be in a separate package than the `swift_import` target because | ||
# that rule propagates its pre-built inputs in `DefaultInfo`. | ||
|
||
swift_library( | ||
name = "toy_module_library", | ||
srcs = ["ToyModule.swift"], | ||
library_evolution = True, | ||
module_name = "ToyModule", | ||
tags = FIXTURE_TAGS, | ||
) | ||
|
||
swift_library_artifact_collector( | ||
name = "toy_module_artifact_collector", | ||
static_library = "toy_outputs/libToyModule.a", | ||
swiftdoc = "toy_outputs/ToyModule.swiftdoc", | ||
swiftinterface = "toy_outputs/ToyModule.swiftinterface", | ||
tags = FIXTURE_TAGS, | ||
target = ":toy_module_library", | ||
target_compatible_with = ["@platforms//os:macos"], | ||
) | ||
|
||
swift_library( | ||
name = "toy_module_library_without_library_evolution", | ||
srcs = ["ToyModule.swift"], | ||
library_evolution = False, | ||
module_name = "ToyModuleNoEvolution", | ||
tags = FIXTURE_TAGS, | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.