Skip to content

Commit

Permalink
Move rules and other build definitions into their own public files an…
Browse files Browse the repository at this point in the history
…d deprecate the umbrella `swift.bzl` file.

Aside from the file moves, this required some minor shuffling of definitions in a few files that contains both internal and external defs, to ensure that more wasn't exported than intended.

This change doesn't delete `swift.bzl` yet; follow-up changes will update `load` statements that reference it directly first.

PiperOrigin-RevId: 449274280
(cherry picked from commit 57cdd76)
Signed-off-by: Brentley Jones <github@brentleyjones.com>
  • Loading branch information
allevato authored and brentleyjones committed Jun 20, 2024
1 parent 046e642 commit cf155fc
Show file tree
Hide file tree
Showing 32 changed files with 1,105 additions and 1,014 deletions.
49 changes: 29 additions & 20 deletions doc/doc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@

"""Bazel rules to define Swift libraries and executable binaries.
Users should load these rules from one or both of the following Bazel files:
```build
@build_bazel_rules_swift//swift:swift.bzl
@build_bazel_rules_swift//proto:proto.bzl
```
Do not import definitions from the `internal` subdirectory directly.
Users should load these rules from `.bzl` files under the `swift` and `proto`
directories. Do not import definitions from the `internal` subdirectory
directly.
For example:
```build
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("@build_bazel_rules_swift//swift:swift_library.bzl", "swift_library")
load("@build_bazel_rules_swift//proto:proto.bzl", "swift_proto_library")
```
"""
Expand All @@ -44,26 +39,40 @@ load(
_swift_proto_library_group = "swift_proto_library_group",
)
load(
"//swift:swift.bzl",
# providers
"//swift:providers.bzl",
_SwiftInfo = "SwiftInfo",
_SwiftToolchainInfo = "SwiftToolchainInfo",
# rules
_swift_binary = "swift_binary",
# api
_swift_common = "swift_common",
)
load("//swift:swift_binary.bzl", _swift_binary = "swift_binary")
load("//swift:swift_common.bzl", _swift_common = "swift_common")
load(
"//swift:swift_compiler_plugin.bzl",
_swift_compiler_plugin = "swift_compiler_plugin",
_universal_swift_compiler_plugin = "universal_swift_compiler_plugin",
)
load(
"//swift:swift_feature_allowlist.bzl",
_swift_feature_allowlist = "swift_feature_allowlist",
_swift_import = "swift_import",
)
load("//swift:swift_import.bzl", _swift_import = "swift_import")
load(
"//swift:swift_interop_hint.bzl",
_swift_interop_hint = "swift_interop_hint",
_swift_library = "swift_library",
)
load("//swift:swift_library.bzl", _swift_library = "swift_library")
load(
"//swift:swift_library_group.bzl",
_swift_library_group = "swift_library_group",
)
load(
"//swift:swift_module_alias.bzl",
_swift_module_alias = "swift_module_alias",
)
load(
"//swift:swift_package_configuration.bzl",
_swift_package_configuration = "swift_package_configuration",
_swift_test = "swift_test",
# aspects
_universal_swift_compiler_plugin = "universal_swift_compiler_plugin",
)
load("//swift:swift_test.bzl", _swift_test = "swift_test")

# The following are re-exported symbols for consumption from stardoc.

Expand Down
13 changes: 4 additions & 9 deletions doc/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@

Bazel rules to define Swift libraries and executable binaries.

Users should load these rules from one or both of the following Bazel files:

```build
@build_bazel_rules_swift//swift:swift.bzl
@build_bazel_rules_swift//proto:proto.bzl
```

Do not import definitions from the `internal` subdirectory directly.
Users should load these rules from `.bzl` files under the `swift` and `proto`
directories. Do not import definitions from the `internal` subdirectory
directly.

For example:

```build
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("@build_bazel_rules_swift//swift:swift_library.bzl", "swift_library")
load("@build_bazel_rules_swift//proto:proto.bzl", "swift_proto_library")
```
On this page:
Expand Down
2 changes: 1 addition & 1 deletion proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ bzl_library(
name = "swift_proto_library",
srcs = ["swift_proto_library.bzl"],
deps = [
"//swift:swift_clang_module_aspect",
"//swift/internal:attrs",
"//swift/internal:compiling",
"//swift/internal:linking",
"//swift/internal:swift_clang_module_aspect",
"//swift/internal:utils",
"@bazel_skylib//lib:dicts",
"@rules_proto//proto:defs",
Expand Down
10 changes: 4 additions & 6 deletions proto/swift_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ load(
"SwiftProtoCompilerInfo",
"swift_common",
)

# buildifier: disable=bzl-visibility
load(
"//swift/internal:attrs.bzl",
"swift_deps_attr",
"//swift:swift_clang_module_aspect.bzl",
"swift_clang_module_aspect",
)

# buildifier: disable=bzl-visibility
load(
"//swift/internal:swift_clang_module_aspect.bzl",
"swift_clang_module_aspect",
"//swift/internal:attrs.bzl",
"swift_deps_attr",
)

# buildifier: disable=bzl-visibility
Expand Down
Loading

0 comments on commit cf155fc

Please sign in to comment.