From 2ade3faa14fb35de7222a0834575b640fc832016 Mon Sep 17 00:00:00 2001 From: Adin Cebic Date: Wed, 16 Sep 2026 14:32:55 +0200 Subject: [PATCH 1/3] buildifier --- .bazelci/presubmit.yml | 2 +- .pre-commit-config.yaml | 2 +- MODULE.bazel | 22 +-- doc/providers.md | 26 ++-- examples/xplatform/xctest/BUILD | 10 +- mixed_language/internal/library.bzl | 18 +-- proto/swift_proto_compiler.bzl | 14 +- proto/swift_proto_library.bzl | 30 ++-- swift/internal/attrs.bzl | 28 ++-- .../extensions/standalone_toolchain.bzl | 6 +- swift/internal/extensions/swift_sdks.bzl | 6 +- swift/internal/features.bzl | 2 +- swift/internal/providers.bzl | 24 ++-- swift/internal/system_clang_module.bzl | 18 +-- swift/internal/system_module_transition.bzl | 4 +- swift/internal/system_swiftinterface.bzl | 8 +- swift/internal/wmo.bzl | 4 +- swift/providers.bzl | 44 +++--- swift/swift_module_mapping_test.bzl | 20 +-- swift/toolchains/config/compile_config.bzl | 4 +- swift/toolchains/swift_toolchain.bzl | 128 +++++++++--------- swift/toolchains/swift_tools.bzl | 16 +-- swift/toolchains/xcode_swift_toolchain.bzl | 48 +++---- test/features_tests.bzl | 4 +- test/hermetic_pcm/extract_swiftmodule.bzl | 6 +- test/output_file_map_tests.bzl | 2 +- test/rules/action_command_line_test.bzl | 14 +- test/rules/action_inputs_test.bzl | 8 +- test/rules/android_validation_test.bzl | 8 +- test/rules/explicit_swift_module_map_test.bzl | 6 +- test/rules/swift_shell_test.bzl | 14 +- test/split_derived_files_tests.bzl | 6 +- test/transitions.bzl | 10 +- tools/explicit_modules/extensions.bzl | 18 +-- ...precomputed_xcode_explicit_module_repo.bzl | 8 +- .../xcode_explicit_module_hub_repo.bzl | 8 +- .../xcode_explicit_module_repo.bzl | 8 +- 37 files changed, 302 insertions(+), 302 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 25be04e3e..0a41289ba 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -130,4 +130,4 @@ tasks: - "bazel run //doc:gazelle" - "git diff --exit-code || { echo '::error::Gazelle-generated BUILD files are out of date. Run: bazel run //doc:gazelle'; exit 1; }" -buildifier: 8.5.1 +buildifier: 10.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e3ff5b36e..ed70db850 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/keith/pre-commit-buildifier - rev: 8.5.1.1 + rev: 10.0.1 hooks: - id: buildifier - id: buildifier-lint diff --git a/MODULE.bazel b/MODULE.bazel index a63d85635..36dcbb3ea 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -196,17 +196,17 @@ system_sdk.configure_sdks( "CoreAudio_Private", # TODO: Remove once CI >= Xcode 26.4 "MobileGestaltPrivate", ], - "iPhoneSimulator": [ - "AssetsLibrary", # TODO: Remove once CI >= Xcode 26.4 - "CoreAudio_Private", + "MacOSX": [ "MobileGestaltPrivate", ], - "iPhoneOS": [ - "AssetsLibrary", # TODO: Remove once CI >= Xcode 26.4 + "WatchOS": [ + "BrowserEngineKit", "CoreAudio_Private", # TODO: Remove once CI >= Xcode 26.4 "MobileGestaltPrivate", ], - "MacOSX": [ + "WatchSimulator": [ + "BrowserEngineKit", + "CoreAudio_Private", # TODO: Remove once CI >= Xcode 26.4 "MobileGestaltPrivate", ], "XROS": [ @@ -219,14 +219,14 @@ system_sdk.configure_sdks( "CoreAudio_Private", # TODO: Remove once CI >= Xcode 26.4 "MobileGestaltPrivate", ], - "WatchOS": [ - "BrowserEngineKit", + "iPhoneOS": [ + "AssetsLibrary", # TODO: Remove once CI >= Xcode 26.4 "CoreAudio_Private", # TODO: Remove once CI >= Xcode 26.4 "MobileGestaltPrivate", ], - "WatchSimulator": [ - "BrowserEngineKit", - "CoreAudio_Private", # TODO: Remove once CI >= Xcode 26.4 + "iPhoneSimulator": [ + "AssetsLibrary", # TODO: Remove once CI >= Xcode 26.4 + "CoreAudio_Private", "MobileGestaltPrivate", ], }, diff --git a/doc/providers.md b/doc/providers.md index 51f1c634d..397f6d092 100644 --- a/doc/providers.md +++ b/doc/providers.md @@ -208,7 +208,7 @@ Provides information needed to generate Swift code from `ProtoInfo` providers ## SwiftProtoInfo
-SwiftProtoInfo(module_name, module_mappings, direct_pbswift_files, pbswift_files)
+SwiftProtoInfo(direct_pbswift_files, module_mappings, module_name, pbswift_files)
 
Propagates Swift-specific information about a `proto_library`. @@ -217,9 +217,9 @@ Propagates Swift-specific information about a `proto_library`. | Name | Description | | :------------- | :------------- | -| module_name | The name of the Swift module compiled from the `swift_proto_library` which produced this provider. | -| module_mappings | `list` of `struct`s. Each struct contains `module_name` and `proto_file_paths` fields that denote the transitive mappings from `.proto` files to Swift modules. This allows messages that reference messages in other libraries to import those modules in generated code. | | direct_pbswift_files | `list` of `File`s. The Swift source files (e.g. `.pb.swift`) generated from the `ProtoInfo` providers of the direct proto dependencies of the `swift_proto_library` target. | +| module_mappings | `list` of `struct`s. Each struct contains `module_name` and `proto_file_paths` fields that denote the transitive mappings from `.proto` files to Swift modules. This allows messages that reference messages in other libraries to import those modules in generated code. | +| module_name | The name of the Swift module compiled from the `swift_proto_library` which produced this provider. | | pbswift_files | `depset` of `File`s. The Swift source files (e.g. `.pb.swift`) generated from the `ProtoInfo` providers of the direct and transitive transitive proto dependencies of the `swift_proto_library` target. | @@ -266,11 +266,11 @@ Propagates synthesized Swift interfaces for modules.
 SwiftToolchainInfo(action_configs, cc_language, cc_toolchain_info, clang_implicit_deps_providers,
                    const_protocols_to_gather, cross_import_overlays, debug_outputs_provider,
-                   developer_dirs, entry_point_linkopts_provider, feature_allowlists,
-                   generated_header_module_implicit_deps_providers, implicit_deps_providers,
-                   module_aliases, package_configurations, requested_features,
-                   dynamic_runtime_cc_info, root_dir, static_runtime_cc_info, swift_worker,
-                   system_modules, implicit_system_modules, test_configuration, tool_configs,
+                   developer_dirs, dynamic_runtime_cc_info, entry_point_linkopts_provider,
+                   feature_allowlists, generated_header_module_implicit_deps_providers,
+                   implicit_deps_providers, implicit_system_modules, module_aliases,
+                   package_configurations, requested_features, root_dir, static_runtime_cc_info,
+                   swift_worker, system_modules, test_configuration, tool_configs,
                    unsupported_features)
 
@@ -289,19 +289,19 @@ that use the toolchain. | cross_import_overlays | A list of `SwiftCrossImportOverlayInfo` providers whose `SwiftInfo` providers will be automatically injected into the dependencies of Swift compilations if their declaring module and bystanding module are both already declared as dependencies. | | debug_outputs_provider | An optional function that provides toolchain-specific logic around the handling of additional debug outputs for `swift_binary` and `swift_test` targets.

If specified, this function must take the following keyword arguments:

* `ctx`: The rule context of the calling binary or test rule.

It must return a `struct` with the following fields:

* `additional_outputs`: Additional outputs expected from the linking action.

* `variables_extension`: A dictionary of additional crosstool variables to pass to the linking action. | | developer_dirs | A list of `structs` containing the following fields:

* `developer_path_label`: A `string` representing the type of developer path.

* `path`: A `string` representing the path to the developer framework. | +| dynamic_runtime_cc_info | The `CcInfo` that selects the toolchain's ordinary dynamic Swift runtime, or `None` if the toolchain supplies its runtime through implicit dependencies. Final links select this provider unless `swift.static_stdlib` is enabled; it is not propagated by libraries. | | entry_point_linkopts_provider | A function that returns flags that should be passed to the linker to control the name of the entry point of a linked binary for rules that customize their entry point.

This function must take the following keyword arguments:

* `entry_point_name`: The name of the entry point function, as was passed to the Swift compiler using the `-entry-point-function-name` flag.

It must return a `struct` with the following fields:

* `linkopts`: A list of strings that will be passed as additional linker flags when linking a binary with a custom entry point. | | feature_allowlists | A list of `SwiftFeatureAllowlistInfo` providers that allow or prohibit packages from requesting or disabling features. | | generated_header_module_implicit_deps_providers | A `struct` with the following fields, which are providers from targets that should be treated as compile-time inputs to actions that precompile the explicit module for the generated Objective-C header of a Swift module:

* `cc_infos`: A list of `CcInfo` providers from targets specified as the toolchain's implicit dependencies.

* `swift_infos`: A list of `SwiftInfo` providers from targets specified as the toolchain's implicit dependencies.

This is used to provide modular dependencies for the fixed inclusions (Darwin, Foundation) that are unconditionally emitted in those files.

For ease of use, this field is never `None`; it will always be a valid `struct` containing the fields described above, even if those lists are empty. | | implicit_deps_providers | A `struct` with the following fields, which represent providers from targets that should be added as implicit dependencies of any Swift compilation or linking target (but not to precompiled explicit C/Objective-C modules):

* `cc_infos`: A list of `CcInfo` providers from targets specified as the toolchain's implicit dependencies.

* `swift_infos`: A list of `SwiftInfo` providers from targets specified as the toolchain's implicit dependencies.

For ease of use, this field is never `None`; it will always be a valid `struct` containing the fields described above, even if those lists are empty. | +| implicit_system_modules | A `struct` with in the same shape as `system_modules` for the system modules that every Swift compilation implicitly requires. | | module_aliases | A `SwiftModuleAliasesInfo` provider that defines the module aliases to use during compilation. | | package_configurations | A list of `SwiftPackageConfigurationInfo` providers that specify additional compilation configuration options that are applied to targets on a per-package basis. | | requested_features | `List` of `string`s. Features that should be implicitly enabled by default for targets built using this toolchain, unless overridden by the user by listing their negation in the `features` attribute of a target/package or in the `--features` command line flag.

These features determine various compilation and debugging behaviors of the Swift build rules, and they are also passed to the C++ APIs used when linking (so features defined in CROSSTOOL may be used here). | -| dynamic_runtime_cc_info | The `CcInfo` that selects the toolchain's ordinary dynamic Swift runtime, or `None` if the toolchain supplies its runtime through implicit dependencies. Final links select this provider unless `swift.static_stdlib` is enabled; it is not propagated by libraries. | | root_dir | `String`. The workspace-relative root directory of the toolchain. | | static_runtime_cc_info | A `CcInfo` that selects the static Swift runtime, or `None` if the toolchain does not support static Swift runtime linking. Final links select this provider when `swift.static_stdlib` is enabled; it is not propagated by libraries. | | swift_worker | `File`. The executable representing the worker executable used to invoke the compiler and other Swift tools (for both incremental and non-incremental compiles). | | system_modules | A `struct` with the following fields, which represent providers from targets that should be added as implicit dependencies of any compilation or linking target:

* `cc_infos`: A list of `CcInfo` providers from targets specified as the toolchain's implicit dependencies.

* `swift_infos`: A list of `SwiftInfo` providers from targets specified as the toolchain's implicit dependencies.

For ease of use, this field is never `None`; it will always be a valid `struct` containing the fields described above, even if those lists are empty. | -| implicit_system_modules | A `struct` with in the same shape as `system_modules` for the system modules that every Swift compilation implicitly requires. | | test_configuration | `Struct` containing the following fields:

* `binary_name`: A template string used to compute the name of the output binary for `swift_test` rules. Any occurrences of the string `"{name}"` will be substituted by the name of the target.

* `env`: A `dict` of environment variables to be set when running tests that were built with this toolchain.

* `execution_requirements`: A `dict` of execution requirements for tests that were built with this toolchain.

* `objc_test_discovery`: A Boolean value indicating whether test targets should discover tests dynamically using the Objective-C runtime.

* `test_linking_contexts`: A list of `CcLinkingContext`s that provide additional flags to use when linking test binaries.

This is used, for example, with Xcode-based toolchains to ensure that the `xctest` helper and coverage tools are found in the correct developer directory when running tests. | | tool_configs | This field is an internal implementation detail of the build rules. | | unsupported_features | `List` of `string`s. Features that should be implicitly disabled by default for targets built using this toolchain, unless overridden by the user by listing them in the `features` attribute of a target/package or in the `--features` command line flag.

These features determine various compilation and debugging behaviors of the Swift build rules, and they are also passed to the C++ APIs used when linking (so features defined in CROSSTOOL may be used here). | @@ -312,7 +312,7 @@ that use the toolchain. ## SwiftToolsInfo
-SwiftToolsInfo(swift_driver, swift_autolink_extract, swift_symbolgraph_extract, additional_inputs)
+SwiftToolsInfo(additional_inputs, swift_autolink_extract, swift_driver, swift_symbolgraph_extract)
 
Propagates information about Swift toolchain tools that can be specified as @@ -325,10 +325,10 @@ dependencies, ensuring they are available in the execution environment. | Name | Description | | :------------- | :------------- | -| swift_driver | `File`. The Swift driver executable that orchestrates compilation and linking operations. This is the main entry point for invoking the Swift compiler toolchain. | +| additional_inputs | `List` of `File`s. Additional files to add to the action input root when calling these tools. | | swift_autolink_extract | `File`. The executable that extracts autolink information from object files. This tool is used to determine which libraries need to be linked based on import statements in Swift code. | +| swift_driver | `File`. The Swift driver executable that orchestrates compilation and linking operations. This is the main entry point for invoking the Swift compiler toolchain. | | swift_symbolgraph_extract | `File`. The executable that extracts symbol graph information from Swift modules. This tool generates structured data about APIs, which can be used for documentation generation and other tooling purposes. | -| additional_inputs | `List` of `File`s. Additional files to add to the action input root when calling these tools. | diff --git a/examples/xplatform/xctest/BUILD b/examples/xplatform/xctest/BUILD index 5bb4767b6..1ca489d36 100644 --- a/examples/xplatform/xctest/BUILD +++ b/examples/xplatform/xctest/BUILD @@ -8,8 +8,8 @@ swift_test( "SimpleTests.swift", ], env = { - "XCTEST_ENV_VAR": "TRUE", "XCTEST_BINDIR_ENV_VAR": "$(BINDIR)", + "XCTEST_ENV_VAR": "TRUE", }, ) @@ -19,8 +19,8 @@ swift_test( "SimpleTests.swift", ], env = { - "XCTEST_ENV_VAR": "TRUE", "XCTEST_BINDIR_ENV_VAR": "$(BINDIR)", + "XCTEST_ENV_VAR": "TRUE", }, features = ["tsan"], # TODO: Re-enable on Linux once Swift race is figured out (or maybe Swift is upgraded) @@ -33,8 +33,8 @@ swift_test( "SimpleTests.swift", ], env = { - "XCTEST_ENV_VAR": "TRUE", "XCTEST_BINDIR_ENV_VAR": "$(BINDIR)", + "XCTEST_ENV_VAR": "TRUE", }, features = ["asan"], # TODO: Re-enable on Linux once Swift memory leak is figured out (or maybe Swift is upgraded) @@ -47,8 +47,8 @@ swift_test( "SimpleTests.swift", ], env = { - "XCTEST_ENV_VAR": "TRUE", "XCTEST_BINDIR_ENV_VAR": "$(BINDIR)", + "XCTEST_ENV_VAR": "TRUE", }, features = ["ubsan"], # TODO: Re-enable on Linux if Swift ever supports ubsan on linux @@ -61,8 +61,8 @@ swift_test( "SimpleTests.swift", ], env = { - "XCTEST_ENV_VAR": "TRUE", "XCTEST_BINDIR_ENV_VAR": "$(BINDIR)", + "XCTEST_ENV_VAR": "TRUE", }, features = [ "tsan", diff --git a/mixed_language/internal/library.bzl b/mixed_language/internal/library.bzl index 2acfc6d12..7410a34d8 100644 --- a/mixed_language/internal/library.bzl +++ b/mixed_language/internal/library.bzl @@ -250,6 +250,15 @@ The non-Swift portion of the mixed language module. aspects = [swift_clang_module_aspect], doc = "Dependencies of the target being built.", ), + "module_map": attr.label( + allow_single_file = True, + doc = "The module map for the module.", + mandatory = True, + ), + "module_name": attr.string( + doc = "The name of the module.", + mandatory = True, + ), "swift_target": attr.label( doc = """ The Swift portion of the mixed language module. @@ -262,15 +271,6 @@ The Swift portion of the mixed language module. doc = "The umbrella header for the module.", mandatory = True, ), - "module_name": attr.string( - doc = "The name of the module.", - mandatory = True, - ), - "module_map": attr.label( - allow_single_file = True, - doc = "The module map for the module.", - mandatory = True, - ), "_module_map_extender": attr.label( cfg = "exec", executable = True, diff --git a/proto/swift_proto_compiler.bzl b/proto/swift_proto_compiler.bzl index 493eed407..f491fb9b1 100644 --- a/proto/swift_proto_compiler.bzl +++ b/proto/swift_proto_compiler.bzl @@ -220,9 +220,9 @@ def _swift_proto_compile(label, actions, swift_proto_compiler_info, additional_c template = swift_proto_compiler_info.internal.copy_swift_sources_template, output = copy_swift_sources_file, substitutions = { - "{temporary_output_directory_path}": temporary_output_directory.path, "{permanent_output_directory_path}": permanent_output_directory_path, "{swift_source_file_paths}": " ".join([src.path for src in swift_srcs]), + "{temporary_output_directory_path}": temporary_output_directory.path, }, is_executable = True, ) @@ -302,12 +302,6 @@ Typically, these are Well Known Types and proto runtime libraries. """, providers = [SwiftInfo], ), - "protoc": attr.label( - allow_single_file = True, - cfg = "exec", - executable = True, - mandatory = False, - ), "plugin": attr.label( doc = """\ A proto compiler plugin executable binary. @@ -377,6 +371,12 @@ protoc \ """, mandatory = True, ), + "protoc": attr.label( + allow_single_file = True, + cfg = "exec", + executable = True, + mandatory = False, + ), "suffixes": attr.string_list( doc = """\ Suffix used for Swift files generated by the plugin from protos. diff --git a/proto/swift_proto_library.bzl b/proto/swift_proto_library.bzl index 5da66e26b..df625748a 100644 --- a/proto/swift_proto_library.bzl +++ b/proto/swift_proto_library.bzl @@ -109,21 +109,6 @@ swift_proto_library = rule( requires_srcs = False, ), { - "protos": attr.label_list( - doc = """\ -A list of `proto_library` targets (or targets producing `ProtoInfo`), -from which the Swift source files should be generated. -""", - providers = [ProtoInfo], - ), - "compilers": attr.label_list( - default = ["//proto/compilers:swift_proto"], - doc = """\ -One or more `swift_proto_compiler` targets (or targets producing `SwiftProtoCompilerInfo`), -from which the Swift protos will be generated. -""", - providers = [SwiftProtoCompilerInfo], - ), "additional_compiler_deps": swift_deps_attr( aspects = [ swift_clang_module_aspect, @@ -142,6 +127,21 @@ See the documentation of the respective compiler rules for more information on which fields are accepted and how they are used. """, ), + "compilers": attr.label_list( + default = ["//proto/compilers:swift_proto"], + doc = """\ +One or more `swift_proto_compiler` targets (or targets producing `SwiftProtoCompilerInfo`), +from which the Swift protos will be generated. +""", + providers = [SwiftProtoCompilerInfo], + ), + "protos": attr.label_list( + doc = """\ +A list of `proto_library` targets (or targets producing `ProtoInfo`), +from which the Swift source files should be generated. +""", + providers = [ProtoInfo], + ), }, ), doc = """\ diff --git a/swift/internal/attrs.bzl b/swift/internal/attrs.bzl index cc52935c1..46fd56a63 100644 --- a/swift/internal/attrs.bzl +++ b/swift/internal/attrs.bzl @@ -284,20 +284,6 @@ def swift_library_rule_attrs( ), swift_config_attrs(), { - "library_evolution": attr.bool( - default = False, - doc = """\ -Indicates whether the Swift code should be compiled with library evolution mode -enabled. - -This attribute should be used to compile a module that will be distributed as -part of a client-facing (non-implementation-only) module in a library or -framework that will be distributed for use outside of the Bazel build graph. -Setting this to true will compile the module with the `-library-evolution` flag -and emit a `.swiftinterface` file as one of the compilation outputs. -""", - mandatory = False, - ), "alwayslink": attr.bool( default = True, doc = """\ @@ -353,6 +339,20 @@ effectively empty (except for a large amount of prologue and epilogue code) and this is generally wasteful because the extra file needs to be propagated in the build graph and, when explicit modules are enabled, extra actions must be executed to compile the Objective-C module for the generated header. +""", + mandatory = False, + ), + "library_evolution": attr.bool( + default = False, + doc = """\ +Indicates whether the Swift code should be compiled with library evolution mode +enabled. + +This attribute should be used to compile a module that will be distributed as +part of a client-facing (non-implementation-only) module in a library or +framework that will be distributed for use outside of the Bazel build graph. +Setting this to true will compile the module with the `-library-evolution` flag +and emit a `.swiftinterface` file as one of the compilation outputs. """, mandatory = False, ), diff --git a/swift/internal/extensions/standalone_toolchain.bzl b/swift/internal/extensions/standalone_toolchain.bzl index 801aad70d..2af84d78d 100644 --- a/swift/internal/extensions/standalone_toolchain.bzl +++ b/swift/internal/extensions/standalone_toolchain.bzl @@ -107,9 +107,6 @@ def _standalone_toolchain_impl(repository_ctx): standalone_toolchain = repository_rule( implementation = _standalone_toolchain_impl, attrs = { - "_build_template": attr.label( - default = "//swift/internal/extensions:toolchain.BUILD", - ), "platform": attr.string( doc = "The host platform name in the swift package download URL", mandatory = True, @@ -121,5 +118,8 @@ standalone_toolchain = repository_rule( doc = "Version of the swift toolchain to be installed.", mandatory = True, ), + "_build_template": attr.label( + default = "//swift/internal/extensions:toolchain.BUILD", + ), }, ) diff --git a/swift/internal/extensions/swift_sdks.bzl b/swift/internal/extensions/swift_sdks.bzl index 5d3142d7b..799c24c18 100644 --- a/swift/internal/extensions/swift_sdks.bzl +++ b/swift/internal/extensions/swift_sdks.bzl @@ -114,9 +114,6 @@ def _swift_android_sdk_impl(repository_ctx): swift_android_sdk_repository = repository_rule( attrs = _common_attrs() | { - "_build_template": attr.label( - default = "//swift/internal/extensions:androidsdk.BUILD", - ), "paired_swiftc": attr.label( doc = """\ The `swiftc` of the standalone toolchain this SDK is paired with, used to locate @@ -124,6 +121,9 @@ the clang builtin headers that match the clang embedded in the Swift compiler. """, mandatory = True, ), + "_build_template": attr.label( + default = "//swift/internal/extensions:androidsdk.BUILD", + ), }, doc = """\ Downloads the Android Swift SDK artifact bundle and defines Swift toolchains that diff --git a/swift/internal/features.bzl b/swift/internal/features.bzl index 669b7f9c5..a6f4bdbed 100644 --- a/swift/internal/features.bzl +++ b/swift/internal/features.bzl @@ -453,8 +453,8 @@ def _compute_features( # Starlark doesn't support re-binding variables captured from an enclosing lexical scope # so we resort to mutation to achieve the same result. state = { - "requested_features": sets.make([]), "disabled_features": sets.make([]), + "requested_features": sets.make([]), } def _update_features(newly_requested_features, newly_disabled_features): diff --git a/swift/internal/providers.bzl b/swift/internal/providers.bzl index 87cc322dd..345314a72 100644 --- a/swift/internal/providers.bzl +++ b/swift/internal/providers.bzl @@ -76,14 +76,22 @@ Propagated by the `swift_overlay` rule to represent information needed to compile a Swift overlay with its paired C/Objective-C module. """, fields = { - "label": "The label of the `swift_overlay` target.", - "srcs": "The source files to compile in the overlay.", "additional_inputs": "Additional inputs to the compiler.", + "alwayslink": """\ +Bool. Whether the overlay should always be included in the final binary's +linkage. +""", "copts": """\ List of strings. Swift compiler flags to pass when compiling the overlay. """, "defines": """\ List of strings. Compiler conditions to set when compiling the overlay. +""", + "deps": """\ +A `struct` containing the following fields: + +* `cc_infos`: A list of `CcInfo` providers from the overlay's `deps`. +* `swift_infos`: A list of `SwiftInfo` providers from the overlay's `deps`. """, "disabled_features": """\ List of strings. Features that should be disabled when compiling the overlay. @@ -95,6 +103,7 @@ List of strings. Features that should be enabled when compiling the overlay. Bool. Whether to add the developer framework search paths when compiling the overlay. """, + "label": "The label of the `swift_overlay` target.", "library_evolution": """\ Bool. Whether to compile the overlay with library evolution enabled. """, @@ -112,15 +121,6 @@ A `struct` containing the following fields: * `swift_infos`: A list of `SwiftInfo` providers from the overlay's `private_deps`. """, - "alwayslink": """\ -Bool. Whether the overlay should always be included in the final binary's -linkage. -""", - "deps": """\ -A `struct` containing the following fields: - -* `cc_infos`: A list of `CcInfo` providers from the overlay's `deps`. -* `swift_infos`: A list of `SwiftInfo` providers from the overlay's `deps`. -""", + "srcs": "The source files to compile in the overlay.", }, ) diff --git a/swift/internal/system_clang_module.bzl b/swift/internal/system_clang_module.bzl index fde519125..4abae80b9 100644 --- a/swift/internal/system_clang_module.bzl +++ b/swift/internal/system_clang_module.bzl @@ -98,6 +98,15 @@ def _system_clang_module_impl(ctx): system_clang_module = rule( cfg = sdk_min_os_transition, attrs = sdk_min_os_transition_attrs() | { + "module_name": attr.string( + doc = """\ +The name of the top-level module in the module map that this target represents. + +A single `module.modulemap` file can contain multiple top-level modules, this +attribute is used to specify which one this target corresponds to. +""", + mandatory = True, + ), "modules": attr.label_list( allow_empty = True, doc = """\ @@ -109,15 +118,6 @@ the SDK module graph from consumers. mandatory = False, providers = [[CcInfo]], ), - "module_name": attr.string( - doc = """\ -The name of the top-level module in the module map that this target represents. - -A single `module.modulemap` file can contain multiple top-level modules, this -attribute is used to specify which one this target corresponds to. -""", - mandatory = True, - ), "system_module_map": attr.string( doc = """\ The path to a system framework module map. diff --git a/swift/internal/system_module_transition.bzl b/swift/internal/system_module_transition.bzl index 191a05d1d..e5ac89bd0 100644 --- a/swift/internal/system_module_transition.bzl +++ b/swift/internal/system_module_transition.bzl @@ -19,11 +19,11 @@ _MIN_OS_OPTIONS = [ _SDK_NAME_TO_MIN_OS_OPTION = { "AppleTVOS": "//command_line_option:tvos_minimum_os", "AppleTVSimulator": "//command_line_option:tvos_minimum_os", - "iPhoneOS": "//command_line_option:ios_minimum_os", - "iPhoneSimulator": "//command_line_option:ios_minimum_os", "MacOSX": "//command_line_option:macos_minimum_os", "WatchOS": "//command_line_option:watchos_minimum_os", "WatchSimulator": "//command_line_option:watchos_minimum_os", + "iPhoneOS": "//command_line_option:ios_minimum_os", + "iPhoneSimulator": "//command_line_option:ios_minimum_os", } def sdk_min_os_transition_attrs(): diff --git a/swift/internal/system_swiftinterface.bzl b/swift/internal/system_swiftinterface.bzl index 9592be675..9c5acc339 100644 --- a/swift/internal/system_swiftinterface.bzl +++ b/swift/internal/system_swiftinterface.bzl @@ -119,6 +119,10 @@ recurse into the SDK module graph from consumers. mandatory = False, providers = [[CcInfo, SwiftInfo]], ), + "swiftinterface": attr.label( + allow_single_file = [".swiftinterface"], + doc = "A declared Swift textual interface file to compile.", + ), "system_swiftinterface": attr.string( doc = """\ The path to a system Swift textual interface. @@ -127,10 +131,6 @@ Variables `__BAZEL_XCODE_SDKROOT__` and `__BAZEL_XCODE_DEVELOPER_DIR__` will be substituted. """, ), - "swiftinterface": attr.label( - allow_single_file = [".swiftinterface"], - doc = "A declared Swift textual interface file to compile.", - ), }, doc = """\ Compiles an Xcode-provided Swift textual interface into a `.swiftmodule` for a diff --git a/swift/internal/wmo.bzl b/swift/internal/wmo.bzl index a3446bfd0..7dc2842c0 100644 --- a/swift/internal/wmo.bzl +++ b/swift/internal/wmo.bzl @@ -23,9 +23,9 @@ load( # Swift command line flags that enable whole module optimization. (This # dictionary is used as a set for quick lookup; the values are irrelevant.) _WMO_FLAGS = { - "-wmo": True, - "-whole-module-optimization": True, "-force-single-frontend-invocation": True, + "-whole-module-optimization": True, + "-wmo": True, } def features_from_swiftcopts(swiftcopts): diff --git a/swift/providers.bzl b/swift/providers.bzl index 72c86727c..b6286dbc7 100644 --- a/swift/providers.bzl +++ b/swift/providers.bzl @@ -236,8 +236,9 @@ Opaque struct passing information from the compiler target to the compile functi SwiftProtoInfo = provider( doc = "Propagates Swift-specific information about a `proto_library`.", fields = { - "module_name": """\ -The name of the Swift module compiled from the `swift_proto_library` which produced this provider. + "direct_pbswift_files": """\ +`list` of `File`s. The Swift source files (e.g. `.pb.swift`) generated from the +`ProtoInfo` providers of the direct proto dependencies of the `swift_proto_library` target. """, "module_mappings": """\ `list` of `struct`s. Each struct contains `module_name` and @@ -245,9 +246,8 @@ The name of the Swift module compiled from the `swift_proto_library` which produ files to Swift modules. This allows messages that reference messages in other libraries to import those modules in generated code. """, - "direct_pbswift_files": """\ -`list` of `File`s. The Swift source files (e.g. `.pb.swift`) generated from the -`ProtoInfo` providers of the direct proto dependencies of the `swift_proto_library` target. + "module_name": """\ +The name of the Swift module compiled from the `swift_proto_library` which produced this provider. """, "pbswift_files": """\ `depset` of `File`s. The Swift source files (e.g. `.pb.swift`) generated from the @@ -368,6 +368,12 @@ A list of `structs` containing the following fields: * `developer_path_label`: A `string` representing the type of developer path. * `path`: A `string` representing the path to the developer framework. +""", + "dynamic_runtime_cc_info": """\ +The `CcInfo` that selects the toolchain's ordinary dynamic Swift runtime, or +`None` if the toolchain supplies its runtime through implicit dependencies. +Final links select this provider unless `swift.static_stdlib` is enabled; it is +not propagated by libraries. """, "entry_point_linkopts_provider": """\ A function that returns flags that should be passed to the linker to control the @@ -418,6 +424,10 @@ linking target (but not to precompiled explicit C/Objective-C modules): For ease of use, this field is never `None`; it will always be a valid `struct` containing the fields described above, even if those lists are empty. +""", + "implicit_system_modules": """\ +A `struct` with in the same shape as `system_modules` for the system modules +that every Swift compilation implicitly requires. """, "module_aliases": """\ A `SwiftModuleAliasesInfo` provider that defines the module aliases to use @@ -437,12 +447,6 @@ their negation in the `features` attribute of a target/package or in the These features determine various compilation and debugging behaviors of the Swift build rules, and they are also passed to the C++ APIs used when linking (so features defined in CROSSTOOL may be used here). -""", - "dynamic_runtime_cc_info": """\ -The `CcInfo` that selects the toolchain's ordinary dynamic Swift runtime, or -`None` if the toolchain supplies its runtime through implicit dependencies. -Final links select this provider unless `swift.static_stdlib` is enabled; it is -not propagated by libraries. """, "root_dir": """\ `String`. The workspace-relative root directory of the toolchain. @@ -470,10 +474,6 @@ linking target: For ease of use, this field is never `None`; it will always be a valid `struct` containing the fields described above, even if those lists are empty. -""", - "implicit_system_modules": """\ -A `struct` with in the same shape as `system_modules` for the system modules -that every Swift compilation implicitly requires. """, "test_configuration": """\ `Struct` containing the following fields: @@ -523,23 +523,23 @@ This provider allows users to specify Swift toolchain executables as explicit dependencies, ensuring they are available in the execution environment. """, fields = { - "swift_driver": """\ -`File`. The Swift driver executable that orchestrates compilation and linking -operations. This is the main entry point for invoking the Swift compiler -toolchain. + "additional_inputs": """\ +`List` of `File`s. Additional files to add to the action input root when calling these tools. """, "swift_autolink_extract": """\ `File`. The executable that extracts autolink information from object files. This tool is used to determine which libraries need to be linked based on import statements in Swift code. +""", + "swift_driver": """\ +`File`. The Swift driver executable that orchestrates compilation and linking +operations. This is the main entry point for invoking the Swift compiler +toolchain. """, "swift_symbolgraph_extract": """\ `File`. The executable that extracts symbol graph information from Swift modules. This tool generates structured data about APIs, which can be used for documentation generation and other tooling purposes. -""", - "additional_inputs": """\ -`List` of `File`s. Additional files to add to the action input root when calling these tools. """, }, ) diff --git a/swift/swift_module_mapping_test.bzl b/swift/swift_module_mapping_test.bzl index 67e5dbd3e..cd59ca84a 100644 --- a/swift/swift_module_mapping_test.bzl +++ b/swift/swift_module_mapping_test.bzl @@ -125,6 +125,16 @@ set -eu swift_module_mapping_test = rule( attrs = { + "deps": attr.label_list( + allow_empty = False, + aspects = [_swift_module_mapping_test_module_collector], + doc = """\ +A list of Swift targets whose transitive closure will be validated against the +`swift_module_mapping` target specified by `mapping`. +""", + mandatory = True, + providers = [[SwiftInfo]], + ), "exclude": attr.string_list( default = [], doc = """\ @@ -141,16 +151,6 @@ closure of `deps` will be validated. mandatory = True, providers = [[SwiftModuleAliasesInfo]], ), - "deps": attr.label_list( - allow_empty = False, - aspects = [_swift_module_mapping_test_module_collector], - doc = """\ -A list of Swift targets whose transitive closure will be validated against the -`swift_module_mapping` target specified by `mapping`. -""", - mandatory = True, - providers = [[SwiftInfo]], - ), }, doc = """\ Validates that a `swift_module_mapping` target covers all the modules in the diff --git a/swift/toolchains/config/compile_config.bzl b/swift/toolchains/config/compile_config.bzl index 8c9a94eb2..4079c436f 100644 --- a/swift/toolchains/config/compile_config.bzl +++ b/swift/toolchains/config/compile_config.bzl @@ -106,9 +106,9 @@ _DEFAULT_WMO_THREAD_COUNT = 12 # Swift command line flags that enable whole module optimization. (This # dictionary is used as a set for quick lookup; the values are irrelevant.) _WMO_FLAGS = { - "-wmo": True, - "-whole-module-optimization": True, "-force-single-frontend-invocation": True, + "-whole-module-optimization": True, + "-wmo": True, } def compile_action_configs( diff --git a/swift/toolchains/swift_toolchain.bzl b/swift/toolchains/swift_toolchain.bzl index 9b000e991..dbf499309 100644 --- a/swift/toolchains/swift_toolchain.bzl +++ b/swift/toolchains/swift_toolchain.bzl @@ -892,6 +892,21 @@ architecture-specific content, such as "x86_64" in "lib/swift/linux/x86_64". """, mandatory = True, ), + "const_protocols_to_gather": attr.label( + default = Label( + "//swift/toolchains/config:const_protocols_to_gather.json", + ), + allow_single_file = True, + doc = """\ +The label of the file specifying a list of protocols for extraction of conformances' +const values. +""", + ), + "copts": attr.string_list( + doc = """\ +A list of additional Swift compiler flags that should be passed to Swift compile actions. +""", + ), "cross_import_overlays": attr.label_list( allow_empty = True, doc = """\ @@ -906,6 +921,20 @@ declared as dependencies. [SwiftCrossImportOverlaysInfo], ], ), + "dynamic_runtime": attr.label_list( + doc = """\ +Shared Swift runtime libraries that are added to the dynamic runtime linking +context. +""", + allow_files = True, + ), + "env": attr.string_dict( + doc = """\ +The preserved environment variables required for the toolchain to operate +normally. +""", + mandatory = False, + ), "feature_allowlists": attr.label_list( doc = """\ A list of `swift_feature_allowlist` targets that allow or prohibit packages from @@ -913,6 +942,26 @@ requesting or disabling features. """, providers = [[SwiftFeatureAllowlistInfo]], ), + "linker_inputs": attr.label_list( + allow_files = True, + doc = """\ +Files that must be available to link actions when `linkopts` is set, such as +the Swift runtime libraries of a Swift SDK. +""", + ), + "linkopts": attr.string_list( + doc = """\ +The *complete* set of linker flags for the Swift runtime when that runtime is +provided by a Swift SDK (for example WebAssembly or Android) rather than by the +host toolchain — typically search paths for, and inputs from, `linker_inputs`, +plus the SDK's runtime objects. + +This is not additive: when set, it *replaces* the runtime link flags the +toolchain would otherwise compute, because those are specific to a Linux host +toolchain and do not apply to a cross-compiled SDK target. Leave it unset for an +ordinary host toolchain, which computes its own flags. +""", + ), "os": attr.string( doc = """\ The name of the operating system that this toolchain targets. @@ -929,13 +978,15 @@ configuration options that are applied to targets on a per-package basis. """, providers = [[SwiftPackageConfigurationInfo]], ), + "parsed_version": attr.string( + mandatory = True, + ), "root": attr.string(), - "dynamic_runtime": attr.label_list( + "sdkroot": attr.string( doc = """\ -Shared Swift runtime libraries that are added to the dynamic runtime linking -context. +The root of a SDK to be used for building the target. """, - allow_files = True, + mandatory = False, ), "static_runtime": attr.label_list( doc = """\ @@ -944,17 +995,22 @@ static runtime link actions. """, allow_files = True, ), - "parsed_version": attr.string( - mandatory = True, + "tool_executable_suffix": attr.string( + doc = """\ +The suffix to apply to the tools when invoking them. This is a platform +dependent value (e.g. `.exe` on Window). +""", + mandatory = False, ), "version_file": attr.label( mandatory = True, allow_single_file = True, ), - "copts": attr.string_list( + "xctest_version": attr.string( doc = """\ -A list of additional Swift compiler flags that should be passed to Swift compile actions. +The version of XCTest that the toolchain packages. """, + mandatory = False, ), "_copts": attr.label( default = Label("//swift:copt"), @@ -984,62 +1040,6 @@ for incremental compilation using a persistent mode. """, executable = True, ), - "const_protocols_to_gather": attr.label( - default = Label( - "//swift/toolchains/config:const_protocols_to_gather.json", - ), - allow_single_file = True, - doc = """\ -The label of the file specifying a list of protocols for extraction of conformances' -const values. -""", - ), - "env": attr.string_dict( - doc = """\ -The preserved environment variables required for the toolchain to operate -normally. -""", - mandatory = False, - ), - "linker_inputs": attr.label_list( - allow_files = True, - doc = """\ -Files that must be available to link actions when `linkopts` is set, such as -the Swift runtime libraries of a Swift SDK. -""", - ), - "linkopts": attr.string_list( - doc = """\ -The *complete* set of linker flags for the Swift runtime when that runtime is -provided by a Swift SDK (for example WebAssembly or Android) rather than by the -host toolchain — typically search paths for, and inputs from, `linker_inputs`, -plus the SDK's runtime objects. - -This is not additive: when set, it *replaces* the runtime link flags the -toolchain would otherwise compute, because those are specific to a Linux host -toolchain and do not apply to a cross-compiled SDK target. Leave it unset for an -ordinary host toolchain, which computes its own flags. -""", - ), - "sdkroot": attr.string( - doc = """\ -The root of a SDK to be used for building the target. -""", - mandatory = False, - ), - "tool_executable_suffix": attr.string( - doc = """\ -The suffix to apply to the tools when invoking them. This is a platform -dependent value (e.g. `.exe` on Window). -""", - mandatory = False, - ), - "xctest_version": attr.string( - doc = """\ -The version of XCTest that the toolchain packages. -""", - mandatory = False, - ), }, ), doc = "Represents a Swift compiler toolchain.", diff --git a/swift/toolchains/swift_tools.bzl b/swift/toolchains/swift_tools.bzl index 6dc00d317..8ca23b213 100644 --- a/swift/toolchains/swift_tools.bzl +++ b/swift/toolchains/swift_tools.bzl @@ -46,9 +46,9 @@ Example: """, implementation = _swift_tools_impl, attrs = { - "swift_driver": attr.label( - allow_single_file = True, - doc = "Label of the Swift driver executable.", + "additional_inputs": attr.label_list( + allow_files = True, + doc = "List of labels to include in the input-tree when invoking these tools.", mandatory = True, ), "swift_autolink_extract": attr.label( @@ -56,14 +56,14 @@ Example: doc = "Label of the swift-autolink-extract executable.", mandatory = True, ), - "swift_symbolgraph_extract": attr.label( + "swift_driver": attr.label( allow_single_file = True, - doc = "Label of the swift-symbolgraph-extract executable.", + doc = "Label of the Swift driver executable.", mandatory = True, ), - "additional_inputs": attr.label_list( - allow_files = True, - doc = "List of labels to include in the input-tree when invoking these tools.", + "swift_symbolgraph_extract": attr.label( + allow_single_file = True, + doc = "Label of the swift-symbolgraph-extract executable.", mandatory = True, ), }, diff --git a/swift/toolchains/xcode_swift_toolchain.bzl b/swift/toolchains/xcode_swift_toolchain.bzl index 93d80a6df..dadaa09b5 100644 --- a/swift/toolchains/xcode_swift_toolchain.bzl +++ b/swift/toolchains/xcode_swift_toolchain.bzl @@ -1020,6 +1020,21 @@ implicit dependencies. """, providers = [[SwiftInfo]], ), + "const_protocols_to_gather": attr.label( + default = Label( + "//swift/toolchains/config:const_protocols_to_gather.json", + ), + allow_single_file = True, + doc = """\ +The label of the file specifying a list of protocols for extraction of conformances' +const values. +""", + ), + "copts": attr.string_list( + doc = """\ +A list of additional Swift compiler flags that should be passed to Swift compile actions. +""", + ), "cross_import_overlays": attr.label_list( allow_empty = True, doc = """\ @@ -1084,27 +1099,13 @@ implicit dependencies of any Swift compilation or linking target. [SwiftInfo], ], ), - "package_configurations": attr.label_list( - doc = """\ -A list of `swift_package_configuration` targets that specify additional compiler -configuration options that are applied to targets on a per-package basis. -""", - providers = [[SwiftPackageConfigurationInfo]], - ), - "const_protocols_to_gather": attr.label( - default = Label( - "//swift/toolchains/config:const_protocols_to_gather.json", - ), - allow_single_file = True, - doc = """\ -The label of the file specifying a list of protocols for extraction of conformances' -const values. -""", - ), - "copts": attr.string_list( + "implicit_system_modules": attr.label( doc = """\ -A list of additional Swift compiler flags that should be passed to Swift compile actions. +The target of the system modules that every Swift compilation implicitly +requires. """, + mandatory = False, + providers = [[CcInfo, SwiftInfo]], ), "objc_copts": attr.string_list( doc = """\ @@ -1112,13 +1113,12 @@ A list of additional Objective-C compiler flags that should be passed (preceded to Swift compile actions *and* Swift explicit module precompile actions. """, ), - "implicit_system_modules": attr.label( + "package_configurations": attr.label_list( doc = """\ -The target of the system modules that every Swift compilation implicitly -requires. +A list of `swift_package_configuration` targets that specify additional compiler +configuration options that are applied to targets on a per-package basis. """, - mandatory = False, - providers = [[CcInfo, SwiftInfo]], + providers = [[SwiftPackageConfigurationInfo]], ), "system_modules": attr.label( doc = """\ diff --git a/test/features_tests.bzl b/test/features_tests.bzl index 21c7484ec..6ae4fc0e9 100644 --- a/test/features_tests.bzl +++ b/test/features_tests.bzl @@ -359,8 +359,8 @@ def features_test_suite(name, tags = []): module_map = "test/fixtures/basic/second.swift-explicit-module-map.json", module_name = "first", expected_mapping = { - "modulePath": "test/fixtures/basic/first.swiftmodule", "docPath": "test/fixtures/basic/first.swiftdoc", + "modulePath": "test/fixtures/basic/first.swiftmodule", "sourceInfoPath": "test/fixtures/basic/first.swiftsourceinfo", }, target_under_test = "//test/fixtures/basic:second", @@ -422,8 +422,8 @@ def features_test_suite(name, tags = []): module_map = "test/fixtures/basic/second.swift-explicit-module-map.json", module_name = "first", expected_mapping = { - "modulePath": "test/fixtures/basic/first.swiftmodule", "docPath": "test/fixtures/basic/first.swiftdoc", + "modulePath": "test/fixtures/basic/first.swiftmodule", }, not_expected_keys = ["sourceInfoPath"], target_under_test = "//test/fixtures/basic:second", diff --git a/test/hermetic_pcm/extract_swiftmodule.bzl b/test/hermetic_pcm/extract_swiftmodule.bzl index 09ab4c31c..b5a7445cd 100644 --- a/test/hermetic_pcm/extract_swiftmodule.bzl +++ b/test/hermetic_pcm/extract_swiftmodule.bzl @@ -36,15 +36,15 @@ def _extract_swiftmodule_impl(ctx): extract_swiftmodule = rule( implementation = _extract_swiftmodule_impl, attrs = { + "extra_features": attr.string_list( + doc = "Additional features to apply when extracting the `.swiftmodule`.", + ), "target": attr.label( mandatory = True, cfg = _features_transition, doc = "A Swift target carrying SwiftInfo whose `.swiftmodule` should be extracted.", providers = [[SwiftInfo]], ), - "extra_features": attr.string_list( - doc = "Additional features to apply when extracting the `.swiftmodule`.", - ), }, doc = "Re-exposes the `.swiftmodule` from a target's `SwiftInfo` as `DefaultInfo.files`.", ) diff --git a/test/output_file_map_tests.bzl b/test/output_file_map_tests.bzl index 528fd28e0..e1910a5c2 100644 --- a/test/output_file_map_tests.bzl +++ b/test/output_file_map_tests.bzl @@ -99,8 +99,8 @@ def output_file_map_test_suite(name, tags = []): output_file_map_test( name = "{}_default".format(name), expected_mapping = { - "object": "test/fixtures/debug_settings/simple_objs/Empty.swift.o", "const-values": "test/fixtures/debug_settings/simple_objs/Empty.swift.swiftconstvalues", + "object": "test/fixtures/debug_settings/simple_objs/Empty.swift.o", }, file_entry = "test/fixtures/debug_settings/Empty.swift", output_file_map = "test/fixtures/debug_settings/simple.output_file_map.json", diff --git a/test/rules/action_command_line_test.bzl b/test/rules/action_command_line_test.bzl index 8c5c4aabf..c405333db 100644 --- a/test/rules/action_command_line_test.bzl +++ b/test/rules/action_command_line_test.bzl @@ -111,6 +111,13 @@ def make_action_command_line_test_rule(config_settings = {}): A list of strings representing substrings expected to appear in the action command line, after concatenating all command line arguments into a single space-delimited string. +""", + ), + "mnemonic": attr.string( + mandatory = True, + doc = """\ +The mnemonic of the action to be inspected on the target under test. It is +expected that there will be exactly one of these. """, ), "not_expected_argv": attr.string_list( @@ -119,13 +126,6 @@ space-delimited string. A list of strings representing substrings expected not to appear in the action command line, after concatenating all command line arguments into a single space-delimited string. -""", - ), - "mnemonic": attr.string( - mandatory = True, - doc = """\ -The mnemonic of the action to be inspected on the target under test. It is -expected that there will be exactly one of these. """, ), }, diff --git a/test/rules/action_inputs_test.bzl b/test/rules/action_inputs_test.bzl index 82433d11b..1e6969e07 100644 --- a/test/rules/action_inputs_test.bzl +++ b/test/rules/action_inputs_test.bzl @@ -100,14 +100,14 @@ def make_action_inputs_test_rule(config_settings = {}): return analysistest.make( _action_inputs_test_impl, attrs = { - "mnemonic": attr.string( - mandatory = True, - doc = "The mnemonic of the action to test.", - ), "expected_inputs": attr.string_list( default = [], doc = "List of filenames or short_paths that should be present in action inputs.", ), + "mnemonic": attr.string( + mandatory = True, + doc = "The mnemonic of the action to test.", + ), "not_expected_inputs": attr.string_list( default = [], doc = "List of filenames or short_paths that should not be present in action inputs.", diff --git a/test/rules/android_validation_test.bzl b/test/rules/android_validation_test.bzl index bd7d7cf5a..06cb9c7eb 100644 --- a/test/rules/android_validation_test.bzl +++ b/test/rules/android_validation_test.bzl @@ -83,14 +83,14 @@ android_so_abi_test = rule( "not_needed_libraries": attr.string_list( doc = "Shared library names not expected in the ELF dynamic NEEDED entries.", ), - "_cc_toolchain": attr.label( - cfg = _android_transition, - default = "@rules_cc//cc:current_cc_toolchain", - ), "shared_library": attr.string( mandatory = True, doc = "The APK entry path of the JNI shared library to inspect.", ), + "_cc_toolchain": attr.label( + cfg = _android_transition, + default = "@rules_cc//cc:current_cc_toolchain", + ), "_runfiles": attr.label( default = "@bazel_tools//tools/bash/runfiles", ), diff --git a/test/rules/explicit_swift_module_map_test.bzl b/test/rules/explicit_swift_module_map_test.bzl index d60c5ae3d..eb521fdcb 100644 --- a/test/rules/explicit_swift_module_map_test.bzl +++ b/test/rules/explicit_swift_module_map_test.bzl @@ -100,6 +100,9 @@ def make_explicit_swift_module_map_test_rule(config_settings = {}): return analysistest.make( _explicit_swift_module_map_test_impl, attrs = { + "expected_mapping": attr.string_dict( + doc = "Expected path fields and their suffixes, excluding configuration-specific prefixes.", + ), "module_map": attr.string( mandatory = True, doc = "The short path of the generated explicit module map.", @@ -108,9 +111,6 @@ def make_explicit_swift_module_map_test_rule(config_settings = {}): mandatory = True, doc = "The Swift module whose entry should be inspected.", ), - "expected_mapping": attr.string_dict( - doc = "Expected path fields and their suffixes, excluding configuration-specific prefixes.", - ), "not_expected_keys": attr.string_list( doc = "Fields that must be absent from the module entry.", ), diff --git a/test/rules/swift_shell_test.bzl b/test/rules/swift_shell_test.bzl index ee23b10e2..a7fd4a159 100644 --- a/test/rules/swift_shell_test.bzl +++ b/test/rules/swift_shell_test.bzl @@ -42,8 +42,8 @@ def _swift_shell_test_impl(ctx): output = output_script, substitutions = { "%executable%": ctx.workspace_name + "/" + test_executable.short_path, - "%expected_return_code%": str(ctx.attr.expected_return_code), "%expected_logs%": shell.array_literal(ctx.attr.expected_logs), + "%expected_return_code%": str(ctx.attr.expected_return_code), "%not_expected_logs%": shell.array_literal(ctx.attr.not_expected_logs), }, is_executable = True, @@ -63,13 +63,13 @@ def _swift_shell_test_impl(ctx): swift_shell_test = rule( attrs = { - "expected_return_code": attr.int( - doc = "The expected return code from the target under test", - ), "expected_logs": attr.string_list( mandatory = False, doc = "Logs that are expected to be emitted", ), + "expected_return_code": attr.int( + doc = "The expected return code from the target under test", + ), "not_expected_logs": attr.string_list( mandatory = False, doc = "Logs that are not expected to be emitted", @@ -79,13 +79,13 @@ swift_shell_test = rule( doc = "The Swift binary whose outputs to test.", providers = [DefaultInfo], ), - "_tool": attr.label( - default = Label("@bazel_tools//tools/bash/runfiles"), - ), "_runner_template": attr.label( allow_single_file = True, default = Label("//test/rules:swift_shell_runner.sh.template"), ), + "_tool": attr.label( + default = Label("@bazel_tools//tools/bash/runfiles"), + ), }, implementation = _swift_shell_test_impl, test = True, diff --git a/test/split_derived_files_tests.bzl b/test/split_derived_files_tests.bzl index 1c4712ef7..e86291d78 100644 --- a/test/split_derived_files_tests.bzl +++ b/test/split_derived_files_tests.bzl @@ -101,12 +101,12 @@ split_swiftmodule_copts_test = make_action_command_line_test_rule( str(Label("//swift:copt")): [ "-DHELLO", ], - "//command_line_option:objccopt": [ - "-DWORLD=1", - ], "//command_line_option:features": [ "swift.split_derived_files_generation", ], + "//command_line_option:objccopt": [ + "-DWORLD=1", + ], }, ) diff --git a/test/transitions.bzl b/test/transitions.bzl index 50baa8312..da9023bcf 100644 --- a/test/transitions.bzl +++ b/test/transitions.bzl @@ -54,17 +54,14 @@ _TRANSITION_ATTRS = { "extra_toolchains": attr.string_list( doc = "Toolchains appended to --extra_toolchains for the transitioned target.", ), - "minimum_os": attr.string( - doc = "Optional value to set `--macos_minimum_os` to.", - ), "ios_minimum_os": attr.string( doc = "Optional value to set `--ios_minimum_os` to.", ), "macos_minimum_os": attr.string( doc = "Optional value to set `--macos_minimum_os` to.", ), - "tvos_minimum_os": attr.string( - doc = "Optional value to set `--tvos_minimum_os` to.", + "minimum_os": attr.string( + doc = "Optional value to set `--macos_minimum_os` to.", ), "platform": attr.string( doc = "Optional target platform label (e.g. `@apple_support//platforms:macos_x86_64`).", @@ -72,6 +69,9 @@ _TRANSITION_ATTRS = { "transitive_features": attr.string_list( doc = "Feature strings appended to `//command_line_option:features` and `//command_line_option:host_features`.", ), + "tvos_minimum_os": attr.string( + doc = "Optional value to set `--tvos_minimum_os` to.", + ), } def _attrs(target_doc): diff --git a/tools/explicit_modules/extensions.bzl b/tools/explicit_modules/extensions.bzl index ca16c62b0..6b765514b 100644 --- a/tools/explicit_modules/extensions.bzl +++ b/tools/explicit_modules/extensions.bzl @@ -207,15 +207,15 @@ _system_sdk_stub_repo = repository_rule( _configure_xcode_tag = tag_class( attrs = { - "version": attr.string( - mandatory = True, - doc = "Canonical Xcode version string (e.g. 26.4.0.17E192).", - ), "build_file": attr.label( mandatory = True, allow_single_file = True, doc = "Explicit module BUILD for the given Xcode.", ), + "version": attr.string( + mandatory = True, + doc = "Canonical Xcode version string (e.g. 26.4.0.17E192).", + ), }, doc = "Manually pass the explicit module BUILD file for a specific Xcode version", ) @@ -226,14 +226,14 @@ _configure_sdks_tag = tag_class( default = {}, doc = "Dictionary of SDK names to module names that should be excluded from scanning.", ), - "names": attr.string_list( - default = [], - doc = "SDK names to scan (e.g. 'MacOSX', 'iPhoneOS')", - ), "include_all": attr.bool( default = False, doc = "Whether to include all SDKs instead of just the ones specified in 'names'.", ), + "names": attr.string_list( + default = [], + doc = "SDK names to scan (e.g. 'MacOSX', 'iPhoneOS')", + ), }, doc = "Limit dynamic scanning to a specific subset of Apple SDKs.", ) @@ -241,8 +241,8 @@ _configure_sdks_tag = tag_class( system_sdk = module_extension( implementation = _sdk_extension_impl, tag_classes = { - "configure_xcode": _configure_xcode_tag, "configure_sdks": _configure_sdks_tag, + "configure_xcode": _configure_xcode_tag, }, doc = "Generate BUILD files for explicit modules.", environ = [ diff --git a/tools/explicit_modules/precomputed_xcode_explicit_module_repo.bzl b/tools/explicit_modules/precomputed_xcode_explicit_module_repo.bzl index 217ae191f..30ef02324 100644 --- a/tools/explicit_modules/precomputed_xcode_explicit_module_repo.bzl +++ b/tools/explicit_modules/precomputed_xcode_explicit_module_repo.bzl @@ -41,15 +41,15 @@ def _precomputed_xcode_explicit_module_repo_impl(rctx): precomputed_xcode_explicit_module_repo = repository_rule( implementation = _precomputed_xcode_explicit_module_repo_impl, attrs = { - "xcode_version": attr.string( - mandatory = True, - doc = "Canonical Xcode version string (e.g. 26.4.0.17E192).", - ), "build_file": attr.label( mandatory = True, allow_single_file = True, doc = "Explicit module BUILD for the given Xcode.", ), + "xcode_version": attr.string( + mandatory = True, + doc = "Canonical Xcode version string (e.g. 26.4.0.17E192).", + ), }, doc = "Per-Xcode explicit module config with a user-passed BUILD file.", ) diff --git a/tools/explicit_modules/xcode_explicit_module_hub_repo.bzl b/tools/explicit_modules/xcode_explicit_module_hub_repo.bzl index 82969a80f..f68be058f 100644 --- a/tools/explicit_modules/xcode_explicit_module_hub_repo.bzl +++ b/tools/explicit_modules/xcode_explicit_module_hub_repo.bzl @@ -79,15 +79,15 @@ def _xcode_explicit_module_hub_repo_impl(rctx): xcode_explicit_module_hub_repo = repository_rule( implementation = _xcode_explicit_module_hub_repo_impl, attrs = { - "xcode_versions": attr.string_list( - mandatory = True, - doc = "All canonical Xcode versions (default included).", - ), "default_manifest": attr.label( mandatory = True, allow_single_file = True, doc = "Label of the default repo's module_names.json.", ), + "xcode_versions": attr.string_list( + mandatory = True, + doc = "All canonical Xcode versions (default included).", + ), }, doc = "Export explicit module definitions referencing Xcode version specific repos.", environ = [ diff --git a/tools/explicit_modules/xcode_explicit_module_repo.bzl b/tools/explicit_modules/xcode_explicit_module_repo.bzl index 34bf5c3c9..6dbfd2aab 100644 --- a/tools/explicit_modules/xcode_explicit_module_repo.bzl +++ b/tools/explicit_modules/xcode_explicit_module_repo.bzl @@ -69,15 +69,15 @@ xcode_explicit_module_repo = repository_rule( "sdks": attr.string_list( doc = "Optional list of SDK names (e.g. 'MacOSX', 'iPhoneSimulator') to scan. If empty, all SDKs are scanned.", ), - "xcode_version": attr.string( - mandatory = True, - doc = "Canonical Xcode version string (e.g. 26.4.0.17E192).", - ), "xcode_locator": attr.label( mandatory = True, allow_single_file = True, doc = "Label of the compiled xcode-locator binary.", ), + "xcode_version": attr.string( + mandatory = True, + doc = "Canonical Xcode version string (e.g. 26.4.0.17E192).", + ), "_script": attr.label( default = Label("//tools/explicit_modules:scan.py"), allow_single_file = True, From cd5b9fbd60d3bb6f97732cc8ad4672586af4d5d2 Mon Sep 17 00:00:00 2001 From: Adin Cebic Date: Wed, 16 Sep 2026 15:03:31 +0200 Subject: [PATCH 2/3] fix --- examples/cross_compilation/wasm/BUILD.bazel | 4 ++-- swift/module_name.bzl | 3 ++- test/fixtures/precompile_user_compile_flags/BUILD | 2 +- tools/explicit_modules/BUILD.bazel | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/cross_compilation/wasm/BUILD.bazel b/examples/cross_compilation/wasm/BUILD.bazel index e26a9d3b0..d89803a10 100644 --- a/examples/cross_compilation/wasm/BUILD.bazel +++ b/examples/cross_compilation/wasm/BUILD.bazel @@ -83,6 +83,6 @@ genrule( "web_app/index.html", "web_app/Reactor.wasm", ], - cmd = "cp $(location web/index.html) $(RULEDIR)/web_app/index.html && " + - "cp $(location :Reactor.wasm) $(RULEDIR)/web_app/Reactor.wasm", + cmd = "cp $(execpath web/index.html) $(RULEDIR)/web_app/index.html && " + + "cp $(execpath :Reactor.wasm) $(RULEDIR)/web_app/Reactor.wasm", ) diff --git a/swift/module_name.bzl b/swift/module_name.bzl index a2c487c78..d44fcecd5 100644 --- a/swift/module_name.bzl +++ b/swift/module_name.bzl @@ -20,7 +20,7 @@ visibility("public") def derive_swift_module_name( *args, - feature_configuration = None): # @unused + feature_configuration = None): """Returns a derived module name from the given build label. For targets whose module name is not explicitly specified, the module name @@ -50,6 +50,7 @@ def derive_swift_module_name( Returns: The module name derived from the label. """ + _ = feature_configuration if (len(args) == 1 and hasattr(args[0], "package") and hasattr(args[0], "name")): diff --git a/test/fixtures/precompile_user_compile_flags/BUILD b/test/fixtures/precompile_user_compile_flags/BUILD index 9e06eabd2..ff31d3023 100644 --- a/test/fixtures/precompile_user_compile_flags/BUILD +++ b/test/fixtures/precompile_user_compile_flags/BUILD @@ -32,7 +32,7 @@ cc_library( "-DFIXTURE_FROM_COPTS=1", "-DFIXTURE_FROM_COPTS_WITH_SPACES=rules\\ swift\\ fixture", "-DFIXTURE_FROM_QUOTED_COPTS='quoted rules swift fixture'", - "-include$(location :Defines.h)", + "-include$(execpath :Defines.h)", ], local_defines = ["FIXTURE_FROM_LOCAL_DEFINES=1"], tags = FIXTURE_TAGS, diff --git a/tools/explicit_modules/BUILD.bazel b/tools/explicit_modules/BUILD.bazel index 4df8ab851..814a5b03c 100644 --- a/tools/explicit_modules/BUILD.bazel +++ b/tools/explicit_modules/BUILD.bazel @@ -8,7 +8,7 @@ exports_files(["scan.py"]) sh_binary( name = "scan", srcs = ["scan_wrapper.sh"], - args = ["$(location :scan.py)"], + args = ["$(rootpath :scan.py)"], data = ["scan.py"], ) From 022e0d09866daebdf766f80b56ad654939cd45ca Mon Sep 17 00:00:00 2001 From: Adin Cebic Date: Wed, 16 Sep 2026 18:56:49 +0200 Subject: [PATCH 3/3] remove --- doc/api.md | 3 +-- swift/module_name.bzl | 9 +-------- swift/swift_binary.bzl | 5 +---- swift/swift_clang_module_aspect.bzl | 10 ++-------- swift/swift_compiler_plugin.bzl | 5 +---- swift/swift_library.bzl | 5 +---- swift/swift_test.bzl | 5 +---- 7 files changed, 8 insertions(+), 34 deletions(-) diff --git a/doc/api.md b/doc/api.md index acd11a4e9..6aec44efa 100755 --- a/doc/api.md +++ b/doc/api.md @@ -99,7 +99,7 @@ A provider whose type/layout is an implementation detail and should not ## derive_swift_module_name
-derive_swift_module_name(*args, feature_configuration)
+derive_swift_module_name(*args)
 
Returns a derived module name from the given build label. @@ -125,7 +125,6 @@ This mapping is intended to be fairly predictable, but not reversible. | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| feature_configuration | The Swift feature configuration being used when compiling the target. This currently does nothing; it will be used by upcoming changes to manage the migration of module names to raw identifiers that use the Bazel target label. | `None` | | args | Either a single argument of type `Label`, or two arguments of type `str` where the first argument is the package name and the second argument is the target name. | none | **RETURNS** diff --git a/swift/module_name.bzl b/swift/module_name.bzl index d44fcecd5..4a7bdb7f7 100644 --- a/swift/module_name.bzl +++ b/swift/module_name.bzl @@ -18,9 +18,7 @@ load("@bazel_skylib//lib:types.bzl", "types") visibility("public") -def derive_swift_module_name( - *args, - feature_configuration = None): +def derive_swift_module_name(*args): """Returns a derived module name from the given build label. For targets whose module name is not explicitly specified, the module name @@ -42,15 +40,10 @@ def derive_swift_module_name( *args: Either a single argument of type `Label`, or two arguments of type `str` where the first argument is the package name and the second argument is the target name. - feature_configuration: The Swift feature configuration being used when - compiling the target. This currently does nothing; it will be used - by upcoming changes to manage the migration of module names to raw - identifiers that use the Bazel target label. Returns: The module name derived from the label. """ - _ = feature_configuration if (len(args) == 1 and hasattr(args[0], "package") and hasattr(args[0], "name")): diff --git a/swift/swift_binary.bzl b/swift/swift_binary.bzl index e259c8e33..2e3bc60b3 100644 --- a/swift/swift_binary.bzl +++ b/swift/swift_binary.bzl @@ -117,10 +117,7 @@ def _swift_binary_impl(ctx): if srcs: module_name = ctx.attr.module_name if not module_name: - module_name = derive_swift_module_name( - ctx.label, - feature_configuration = feature_configuration, - ) + module_name = derive_swift_module_name(ctx.label) if skip_entry_point: entry_point_name = None diff --git a/swift/swift_clang_module_aspect.bzl b/swift/swift_clang_module_aspect.bzl index bb7421f5f..c117a0bc4 100644 --- a/swift/swift_clang_module_aspect.bzl +++ b/swift/swift_clang_module_aspect.bzl @@ -285,10 +285,7 @@ def _module_info_for_target( # was some other `Objc`-providing target, derive the module name # now. if not module_name: - module_name = derive_swift_module_name( - target.label, - feature_configuration = feature_configuration, - ) + module_name = derive_swift_module_name(target.label) module_map_file = _generate_module_map( actions = aspect_ctx.actions, @@ -842,10 +839,7 @@ def _swift_clang_module_aspect_impl(target, aspect_ctx, toolchain_type): ) if interop_info and not module_name: - module_name = derive_swift_module_name( - target.label, - feature_configuration = feature_configuration, - ) + module_name = derive_swift_module_name(target.label) if interop_info or ObjcInfo in target or CcInfo in target: return providers + _handle_module( diff --git a/swift/swift_compiler_plugin.bzl b/swift/swift_compiler_plugin.bzl index 41fe19d5f..9667cf460 100644 --- a/swift/swift_compiler_plugin.bzl +++ b/swift/swift_compiler_plugin.bzl @@ -74,10 +74,7 @@ def _swift_compiler_plugin_impl(ctx): module_name = ctx.attr.module_name if not module_name: - module_name = derive_swift_module_name( - ctx.label, - feature_configuration = feature_configuration, - ) + module_name = derive_swift_module_name(ctx.label) entry_point_name = entry_point_function_name(module_name) compile_result = compile( diff --git a/swift/swift_library.bzl b/swift/swift_library.bzl index 056723b21..5badf81f0 100644 --- a/swift/swift_library.bzl +++ b/swift/swift_library.bzl @@ -159,10 +159,7 @@ def _swift_library_impl(ctx): module_name = ctx.attr.module_name if not module_name: - module_name = derive_swift_module_name( - ctx.label, - feature_configuration = feature_configuration, - ) + module_name = derive_swift_module_name(ctx.label) swift_infos = get_providers(deps, SwiftInfo) private_swift_infos = get_providers(private_deps, SwiftInfo) diff --git a/swift/swift_test.bzl b/swift/swift_test.bzl index 3289a142c..1db7032f3 100644 --- a/swift/swift_test.bzl +++ b/swift/swift_test.bzl @@ -348,10 +348,7 @@ def _swift_test_impl(ctx): module_name = ctx.attr.module_name if not module_name: - module_name = derive_swift_module_name( - ctx.label, - feature_configuration = feature_configuration, - ) + module_name = derive_swift_module_name(ctx.label) include_dev_srch_paths = include_developer_search_paths(ctx.attr)