Skip to content

Commit 0e2b09c

Browse files
authored
Upgraded bazel-starlib to 0.6.0 and addressed a number of lint issues. (#53)
1 parent 9ff33a2 commit 0e2b09c

16 files changed

+58
-52
lines changed

WORKSPACE

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,22 @@ swift_rules_extra_dependencies()
3939

4040
# MARK: - Buildifier
4141

42-
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
42+
load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")
4343

44-
go_rules_dependencies()
44+
buildifier_prebuilt_deps()
4545

46-
go_register_toolchains(version = "1.17.2")
46+
load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")
4747

48-
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
49-
50-
gazelle_dependencies()
51-
52-
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
53-
54-
protobuf_deps()
48+
buildifier_prebuilt_register_toolchains()
5549

5650
# MARK: - Integration Testing
5751

5852
load("@cgrindel_rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
5953

6054
bazel_integration_test_rules_dependencies()
6155

62-
load("//:bazel_versions.bzl", "SUPPORTED_BAZEL_VERSIONS")
6356
load("@cgrindel_rules_bazel_integration_test//bazel_integration_test:defs.bzl", "bazel_binaries")
57+
load("//:bazel_versions.bzl", "SUPPORTED_BAZEL_VERSIONS")
6458

6559
bazel_binaries(versions = SUPPORTED_BAZEL_VERSIONS)
6660

bazel_versions.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Tested/Supported Bazel Versions"""
2+
13
CURRENT_BAZEL_VERSION = "5.0.0"
24

35
OTHER_BAZEL_VERSIONS = [

doc/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg")
21
load(
32
"@cgrindel_bazel_starlib//bazeldoc:defs.bzl",
43
"doc_for_provs",
54
"write_file_list",
65
"write_header",
76
doc_providers = "providers",
87
)
8+
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg")
99

1010
# MARK: - Documentation Providers
1111

doc/rules_and_macros_overview.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ NOTE: Any labels detected in the `srcs` will be ignored.
109109
| <a id="swiftformat_pkg-srcs"></a>srcs | Optional. The Swift source files that should be formatted. | <code>None</code> |
110110
| <a id="swiftformat_pkg-config"></a>config | Optional. The swiftformat YAML configuration file. | <code>None</code> |
111111

112-
**RETURNS**
113-
114-
None.
115-
116112

117113
<a id="#swiftformat_test"></a>
118114

swiftformat/defs.bzl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
"""Public API for rules_swiftformat."""
2+
13
load(
2-
"//swiftformat/internal:swiftformat_pkg.bzl",
3-
_swiftformat_pkg = "swiftformat_pkg",
4+
"//swiftformat/internal:src_utils.bzl",
5+
_src_utils = "src_utils",
6+
)
7+
load(
8+
"//swiftformat/internal:swiftformat_binary.bzl",
9+
_swiftformat_binary = "swiftformat_binary",
410
)
511
load(
612
"//swiftformat/internal:swiftformat_format.bzl",
@@ -11,17 +17,13 @@ load(
1117
_swiftformat_library = "swiftformat_library",
1218
)
1319
load(
14-
"//swiftformat/internal:swiftformat_binary.bzl",
15-
_swiftformat_binary = "swiftformat_binary",
20+
"//swiftformat/internal:swiftformat_pkg.bzl",
21+
_swiftformat_pkg = "swiftformat_pkg",
1622
)
1723
load(
1824
"//swiftformat/internal:swiftformat_test.bzl",
1925
_swiftformat_test = "swiftformat_test",
2026
)
21-
load(
22-
"//swiftformat/internal:src_utils.bzl",
23-
_src_utils = "src_utils",
24-
)
2527

2628
# Macros
2729
swiftformat_pkg = _swiftformat_pkg

swiftformat/deps.bzl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Dependencies for rules_swiftformat."""
2+
13
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
24
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
35

@@ -16,10 +18,10 @@ def swiftformat_rules_dependencies():
1618
maybe(
1719
http_archive,
1820
name = "cgrindel_bazel_starlib",
19-
sha256 = "9e054e423bb7674e02052e52725b41288369dd94efff963479f76fe269b5177f",
20-
strip_prefix = "bazel-starlib-0.3.1",
21+
sha256 = "8ac3e45dc237121283d70506497ec39feb5092af9a57bfe34f7abf4a6bd2ebaa",
22+
strip_prefix = "bazel-starlib-0.6.0",
2123
urls = [
22-
"http://github.com/cgrindel/bazel-starlib/archive/v0.3.1.tar.gz",
24+
"http://github.com/cgrindel/bazel-starlib/archive/v0.6.0.tar.gz",
2325
],
2426
)
2527

swiftformat/internal/src_utils.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Definition for src_utils module."""
2+
13
def _is_label(src):
24
"""Determines whether the provided string is a label.
35

swiftformat/internal/swiftformat_binary.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Definition for swiftformat_binary macro."""
2+
13
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_binary")
24
load(":swiftformat_pkg.bzl", "swiftformat_pkg")
35

swiftformat/internal/swiftformat_format.bzl

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
load("@bazel_skylib//lib:paths.bzl", "paths")
1+
"""A build rule that formats Swift source files. """
2+
23
load(
34
"@cgrindel_bazel_starlib//updatesrc:defs.bzl",
45
"UpdateSrcsInfo",
56
"update_srcs",
67
)
78

8-
"""A build rule that formats Swift source files.
9-
"""
10-
119
def _swiftformat_format_impl(ctx):
1210
updsrcs = []
1311
for src in ctx.files.srcs:
@@ -48,6 +46,15 @@ def _swiftformat_format_impl(ctx):
4846
swiftformat_format = rule(
4947
implementation = _swiftformat_format_impl,
5048
attrs = {
49+
"config": attr.label(
50+
allow_single_file = True,
51+
doc = "A swiftformat config file.",
52+
default = "@//:.swiftformat",
53+
),
54+
"output_suffix": attr.string(
55+
default = "_formatted",
56+
doc = "The suffix to add to the output filename.",
57+
),
5158
"srcs": attr.label_list(
5259
allow_files = True,
5360
mandatory = True,
@@ -59,15 +66,6 @@ The Swift version to be used by `swiftformat`. You probably want to add this \
5966
to your config file instead of adding it here.\
6067
""",
6168
),
62-
"config": attr.label(
63-
allow_single_file = True,
64-
doc = "A swiftformat config file.",
65-
default = "@//:.swiftformat",
66-
),
67-
"output_suffix": attr.string(
68-
default = "_formatted",
69-
doc = "The suffix to add to the output filename.",
70-
),
7169
"_swiftformat": attr.label(
7270
default = "@swiftformat_repos//SwiftFormat:swiftformat",
7371
executable = True,

swiftformat/internal/swiftformat_library.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Definition for swiftformat_library macro."""
2+
13
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
24
load(":swiftformat_pkg.bzl", "swiftformat_pkg")
35

0 commit comments

Comments
 (0)