Skip to content

Commit d141ada

Browse files
committed
Remove swift_update_packages.
1 parent 430b6a9 commit d141ada

File tree

35 files changed

+33
-427
lines changed

35 files changed

+33
-427
lines changed

README.md

+4-18
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ common --enable_bzlmod
8787
Add a dependency on `rules_swift_package_manager`.
8888

8989
<!-- BEGIN MODULE SNIPPET -->
90+
9091
```python
9192
bazel_dep(name = "rules_swift_package_manager", version = "0.30.0")
9293
```
94+
9395
<!-- END MODULE SNIPPET -->
9496

9597
You will also need to add a dependency on Gazelle, `rules_swift`, and possibly `rules_apple`. Follow
@@ -137,7 +139,6 @@ Add the following to the `BUILD.bazel` file at the root of your workspace.
137139

138140
```bzl
139141
load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")
140-
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
141142

142143
# Ignore the `.build` folder that is created by running Swift package manager
143144
# commands. The Swift Gazelle plugin executes some Swift package manager
@@ -158,23 +159,6 @@ gazelle_binary(
158159
],
159160
)
160161

161-
# This macro defines two targets: `swift_update_pkgs` and
162-
# `swift_update_pkgs_to_latest`.
163-
#
164-
# The `swift_update_pkgs` target should be run whenever the list of external
165-
# dependencies is updated in the `Package.swift`. Running this target will
166-
# populate the `swift_deps.bzl` with `swift_package` declarations for all of
167-
# the direct and transitive Swift packages that your project uses.
168-
#
169-
# The `swift_update_pkgs_to_latest` target should be run when you want to
170-
# update your Swift dependencies to their latest eligible version.
171-
swift_update_packages(
172-
name = "swift_update_pkgs",
173-
gazelle = ":gazelle_bin",
174-
generate_swift_deps_for_workspace = False,
175-
update_bzlmod_stanzas = True,
176-
)
177-
178162
# This target updates the Bazel build files for your project. Run this target
179163
# whenever you add or remove source files from your project.
180164
gazelle(
@@ -183,6 +167,8 @@ gazelle(
183167
)
184168
```
185169

170+
<!-- TODO: Remove swift_update_pkgs stuff and fix doc. -->
171+
186172
### 5. Resolve the external dependencies for your project.
187173

188174
Resolve the external dependencies for your project by running the following:

bzlmod/workspace/BUILD.bazel

-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
22
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg")
33
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
44
load("@cgrindel_bazel_starlib//updatesrc:defs.bzl", "updatesrc_update_all")
5-
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
65

76
# MARK: - Tidy / Update Source Files
87

@@ -12,7 +11,6 @@ tidy(
1211
name = "tidy",
1312
targets = [
1413
":update_all",
15-
":swift_update_pkgs",
1614
":update_build_files",
1715
],
1816
)
@@ -35,11 +33,4 @@ gazelle(
3533
gazelle = ":gazelle_bin",
3634
)
3735

38-
swift_update_packages(
39-
name = "swift_update_pkgs",
40-
gazelle = ":gazelle_bin",
41-
generate_swift_deps_for_workspace = False,
42-
update_bzlmod_stanzas = True,
43-
)
44-
4536
bzlformat_pkg(name = "bzlformat")

docs/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ _DOC_INFOS = [
3737
name = "rules_and_macros",
3838
label = "//swiftpkg:defs",
3939
symbols = [
40-
"swift_update_packages",
40+
"swift_deps_index",
4141
],
4242
),
4343
]

docs/legacy_quickstart.md

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ files, at this time.
6161

6262
Add the following to the `BUILD.bazel` file at the root of your workspace.
6363

64+
<!-- TODO: Remove swift_update_pkgs stuff and update doc. -->
65+
6466
```python
6567
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
6668
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")

docs/patch_swift_package.md

+13-12
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ create a patch file using your favorite tool. For instance, if you are using `gi
1010
patch file by running the following:
1111

1212
```sh
13-
# Assuming that your fix is in commit 33c0229, you can run the following to
13+
# Assuming that your fix is in commit 33c0229, you can run the following to
1414
# generate a patch file.
1515
$ git format-patch -1 33c0229
1616
```
1717

1818
## Copy the Patch File to Your Repository
1919

20-
Next, create a directory in your workspace and copy the patch file to that directory. For example,
20+
Next, create a directory in your workspace and copy the patch file to that directory. For example,
2121
if you are applying a patch for the `swift-cmark` package, you could do the following:
2222

2323
```sh
@@ -32,14 +32,14 @@ $ echo 'exports_files(["0001-Do-not-exclude-files-that-are-needed-for-compilatio
3232
> third-party/swift-cmark/BUILD
3333
```
3434

35-
_NOTE: Even if you use BUILD.bazel as your preferred build file name, be sure to name this build
35+
_NOTE: Even if you use BUILD.bazel as your preferred build file name, be sure to name this build
3636
file BUILD. In Bazel 6.2.1 testing under `rules_bazel_integration_test`, Bazel would not recognize
3737
the package if the file was named BUILD.bazel._
3838

3939
## Create a Patches YAML File
4040

4141
The Gazelle plugin provided by `rules_swift_package_manager` can read in a YAML file that describes
42-
the patches that should be applied for one or more Swift packages.
42+
the patches that should be applied for one or more Swift packages.
4343

4444
Continuing our example, create a file called `swift_pkgs_patches.yml` with the following contents:
4545

@@ -51,18 +51,19 @@ swift-cmark:
5151
5252
The key (e.g. `swift-cmark`) is the Swift package's identity. The supported fields are:
5353

54-
| YAML Field | Description |
55-
| ---------- | ----------- |
56-
| `files` | A list of patch files to apply. |
57-
| `args` | Optional. A list of arguments that should be passed to the patch tool. If you are using a git patch file, be sure to include `-p1`. |
58-
| `cmds` | Optional. A list of Bash commands (Mac/Linux) to be applied after patches are applied. |
59-
| `win_cmds` | Optional. A list of Powershell commands (Windows) to applied after patches are applied. |
60-
| `tool` | Optional. The tool to use to apply the patch. |
61-
54+
| YAML Field | Description |
55+
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------- |
56+
| `files` | A list of patch files to apply. |
57+
| `args` | Optional. A list of arguments that should be passed to the patch tool. If you are using a git patch file, be sure to include `-p1`. |
58+
| `cmds` | Optional. A list of Bash commands (Mac/Linux) to be applied after patches are applied. |
59+
| `win_cmds` | Optional. A list of Powershell commands (Windows) to applied after patches are applied. |
60+
| `tool` | Optional. The tool to use to apply the patch. |
6261

6362
_REMINDER: If you are using bzlmod, use `@@` as the prefix for your patch files. Otherwise, use
6463
`@`._
6564

65+
<!-- TODO: Remove swift_update_pkgs stuff and update doc. -->
66+
6667
## Update the `swift_update_packages` Declaration
6768

6869
Next, update the `swift_update_packages` declaration in the `BUILD.bazel` file at the root of your

docs/rules_and_macros_overview.md

+13-26
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,25 @@ The rules and macros described below are used to define Gazelle targets to aid i
77

88
On this page:
99

10-
* [swift_update_packages](#swift_update_packages)
10+
* [swift_deps_index](#swift_deps_index)
1111

1212

13-
<a id="swift_update_packages"></a>
13+
<a id="swift_deps_index"></a>
1414

15-
## swift_update_packages
15+
## swift_deps_index
1616

1717
<pre>
18-
swift_update_packages(<a href="#swift_update_packages-name">name</a>, <a href="#swift_update_packages-gazelle">gazelle</a>, <a href="#swift_update_packages-package_manifest">package_manifest</a>, <a href="#swift_update_packages-swift_deps">swift_deps</a>, <a href="#swift_update_packages-swift_deps_fn">swift_deps_fn</a>, <a href="#swift_update_packages-swift_deps_index">swift_deps_index</a>,
19-
<a href="#swift_update_packages-update_bzlmod_use_repo_names">update_bzlmod_use_repo_names</a>, <a href="#swift_update_packages-print_bzlmod_stanzas">print_bzlmod_stanzas</a>, <a href="#swift_update_packages-update_bzlmod_stanzas">update_bzlmod_stanzas</a>,
20-
<a href="#swift_update_packages-bazel_module">bazel_module</a>, <a href="#swift_update_packages-generate_swift_deps_for_workspace">generate_swift_deps_for_workspace</a>, <a href="#swift_update_packages-patches_yaml">patches_yaml</a>, <a href="#swift_update_packages-kwargs">kwargs</a>)
18+
swift_deps_index(<a href="#swift_deps_index-name">name</a>, <a href="#swift_deps_index-direct_dep_pkg_infos">direct_dep_pkg_infos</a>)
2119
</pre>
2220

23-
Defines gazelle update-repos targets that are used to resolve and update Swift package dependencies.
24-
25-
**PARAMETERS**
26-
27-
28-
| Name | Description | Default Value |
29-
| :------------- | :------------- | :------------- |
30-
| <a id="swift_update_packages-name"></a>name | The name of the <code>resolve</code> target as a <code>string</code>. The target name for the <code>update</code> target is derived from this value by appending <code>_to_latest</code>. | none |
31-
| <a id="swift_update_packages-gazelle"></a>gazelle | The label to <code>gazelle_binary</code> that includes the <code>rules_swift_package_manager</code> Gazelle extension. | none |
32-
| <a id="swift_update_packages-package_manifest"></a>package_manifest | Optional. The name of the Swift package manifest file as a <code>string</code>. | <code>"Package.swift"</code> |
33-
| <a id="swift_update_packages-swift_deps"></a>swift_deps | Optional. The name of the Starlark file that should be updated with the Swift package dependencies as a <code>string</code>. | <code>"swift_deps.bzl"</code> |
34-
| <a id="swift_update_packages-swift_deps_fn"></a>swift_deps_fn | Optional. The name of the Starlark function in the <code>swift_deps</code> file that should be updated with the Swift package dependencies as a <code>string</code>. | <code>"swift_dependencies"</code> |
35-
| <a id="swift_update_packages-swift_deps_index"></a>swift_deps_index | Optional. The relative path to the Swift dependencies index JSON file. This path is relative to the repository root, not the location of this declaration. | <code>"swift_deps_index.json"</code> |
36-
| <a id="swift_update_packages-update_bzlmod_use_repo_names"></a>update_bzlmod_use_repo_names | Optional. Determines whether the Gazelle extension updates the use_repo names to MODULE.bazel. | <code>False</code> |
37-
| <a id="swift_update_packages-print_bzlmod_stanzas"></a>print_bzlmod_stanzas | Optional. Determines whether the Gazelle extension prints out bzlmod Starlark code that can be pasted into your <code>MODULE.bazel</code>. | <code>False</code> |
38-
| <a id="swift_update_packages-update_bzlmod_stanzas"></a>update_bzlmod_stanzas | Optional. Determines whether the Gazelle extension adds/updates the bzlmod Starlark code to MODULE.bazel. | <code>False</code> |
39-
| <a id="swift_update_packages-bazel_module"></a>bazel_module | Optional. The relative path to the <code>MODULE.bazel</code> file. | <code>"MODULE.bazel"</code> |
40-
| <a id="swift_update_packages-generate_swift_deps_for_workspace"></a>generate_swift_deps_for_workspace | Optional. Determines whether to generate the swift dependencies for clients using legacy/WORKSPACE loaded dependencies. | <code>True</code> |
41-
| <a id="swift_update_packages-patches_yaml"></a>patches_yaml | Optional. The path to a YAML file with patch information for the Swift packages. The keys are the Swift package identity and the values are the patch parameters (see <code>gazelle/internal/swift/patch.go</code> for details on the fields). | <code>None</code> |
42-
| <a id="swift_update_packages-kwargs"></a>kwargs | Attributes that are passed along to the gazelle declarations. | none |
21+
Generates a Swift dependencies index file that is used by other tooling (e.g., Swift Gazelle plugin).
22+
23+
**ATTRIBUTES**
24+
25+
26+
| Name | Description | Type | Mandatory | Default |
27+
| :------------- | :------------- | :------------- | :------------- | :------------- |
28+
| <a id="swift_deps_index-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
29+
| <a id="swift_deps_index-direct_dep_pkg_infos"></a>direct_dep_pkg_infos | The <code>pkg_info.json</code> files for the direct dependencies. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
4330

4431

examples/firebase_example/BUILD.bazel

-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
22
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
3-
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
43

54
tidy(
65
name = "tidy",
76
targets = [
8-
":swift_update_pkgs",
97
":update_build_files",
108
],
119
)
@@ -27,10 +25,3 @@ gazelle(
2725
name = "update_build_files",
2826
gazelle = ":gazelle_bin",
2927
)
30-
31-
swift_update_packages(
32-
name = "swift_update_pkgs",
33-
gazelle = ":gazelle_bin",
34-
generate_swift_deps_for_workspace = False,
35-
update_bzlmod_stanzas = True,
36-
)

examples/grpc_example/BUILD.bazel

-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
22
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
3-
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
43

54
tidy(
65
name = "tidy",
76
targets = [
8-
":swift_update_pkgs",
97
":update_build_files",
108
],
119
)
@@ -34,10 +32,3 @@ gazelle(
3432
name = "update_build_files",
3533
gazelle = ":gazelle_bin",
3634
)
37-
38-
swift_update_packages(
39-
name = "swift_update_pkgs",
40-
gazelle = ":gazelle_bin",
41-
generate_swift_deps_for_workspace = False,
42-
update_bzlmod_stanzas = True,
43-
)

examples/grpc_package_example/BUILD.bazel

-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
22
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
3-
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
43

54
tidy(
65
name = "tidy",
76
targets = [
8-
":swift_update_pkgs",
97
":update_build_files",
108
],
119
)
@@ -33,10 +31,3 @@ gazelle(
3331
name = "update_build_files",
3432
gazelle = ":gazelle_bin",
3533
)
36-
37-
swift_update_packages(
38-
name = "swift_update_pkgs",
39-
gazelle = ":gazelle_bin",
40-
generate_swift_deps_for_workspace = False,
41-
update_bzlmod_stanzas = True,
42-
)

examples/interesting_deps/BUILD.bazel

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
22
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_binary")
33
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
4-
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
54

65
tidy(
76
name = "tidy",
87
targets = [
9-
":swift_update_pkgs",
108
":update_build_files",
119
],
1210
)
@@ -29,13 +27,6 @@ gazelle(
2927
gazelle = ":gazelle_bin",
3028
)
3129

32-
swift_update_packages(
33-
name = "swift_update_pkgs",
34-
gazelle = ":gazelle_bin",
35-
generate_swift_deps_for_workspace = False,
36-
update_bzlmod_stanzas = True,
37-
)
38-
3930
swift_binary(
4031
name = "print",
4132
srcs = ["main.swift"],

examples/interesting_deps/set_up_clean_test

-9
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ cat > "${script_dir}/BUILD.bazel" <<-EOF
1818
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
1919
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_binary")
2020
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
21-
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
2221
2322
tidy(
2423
name = "tidy",
2524
targets = [
26-
":swift_update_pkgs",
2725
":update_build_files",
2826
],
2927
)
@@ -46,13 +44,6 @@ gazelle(
4644
gazelle = ":gazelle_bin",
4745
)
4846
49-
swift_update_packages(
50-
name = "swift_update_pkgs",
51-
gazelle = ":gazelle_bin",
52-
generate_swift_deps_for_workspace = False,
53-
update_bzlmod_stanzas = True,
54-
)
55-
5647
swift_binary(
5748
name = "print",
5849
srcs = ["main.swift"],

examples/ios_sim/BUILD.bazel

-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
22
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
3-
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
43
load(
54
"@rules_xcodeproj//xcodeproj:defs.bzl",
65
"xcodeproj",
@@ -9,7 +8,6 @@ load(
98
tidy(
109
name = "tidy",
1110
targets = [
12-
":swift_update_pkgs",
1311
":update_build_files",
1412
],
1513
)
@@ -32,14 +30,6 @@ gazelle(
3230
gazelle = ":gazelle_bin",
3331
)
3432

35-
swift_update_packages(
36-
name = "swift_update_pkgs",
37-
gazelle = ":gazelle_bin",
38-
generate_swift_deps_for_workspace = False,
39-
patches_yaml = "swift_pkg_patches.yaml",
40-
update_bzlmod_stanzas = True,
41-
)
42-
4333
# Xcodeproj
4434

4535
xcodeproj(

examples/lottie_ios_example/BUILD.bazel

-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
22
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
3-
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
43

54
tidy(
65
name = "tidy",
76
targets = [
8-
":swift_update_pkgs",
97
":update_build_files",
108
],
119
)
@@ -27,10 +25,3 @@ gazelle(
2725
name = "update_build_files",
2826
gazelle = ":gazelle_bin",
2927
)
30-
31-
swift_update_packages(
32-
name = "swift_update_pkgs",
33-
gazelle = ":gazelle_bin",
34-
generate_swift_deps_for_workspace = False,
35-
update_bzlmod_stanzas = True,
36-
)

0 commit comments

Comments
 (0)