Skip to content

Commit e77a08b

Browse files
committed
fix local repository
1 parent e388a10 commit e77a08b

File tree

3 files changed

+55
-56
lines changed

3 files changed

+55
-56
lines changed

src/main/starlark/core/repositories/initialize.release.bzl

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -64,107 +64,90 @@ def kotlin_repositories(
6464
strip_version = ksp_compiler_release.version,
6565
)
6666

67-
maybe(
67+
versions.use_repository(
6868
http_file,
6969
name = "com_github_pinterest_ktlint",
70-
sha256 = versions.PINTEREST_KTLINT.sha256,
71-
urls = [url.format(version = versions.PINTEREST_KTLINT.version) for url in versions.PINTEREST_KTLINT.url_templates],
70+
version = versions.PINTEREST_KTLINT,
7271
executable = True,
7372
)
7473

7574
maybe(
7675
http_jar,
7776
name = "kotlinx_serialization_core_jvm",
78-
sha256 = versions.KOTLINX_SERIALIZATION_CORE_JVM.sha256,
79-
urls = [url.format(version = versions.KOTLINX_SERIALIZATION_CORE_JVM.version) for url in versions.KOTLINX_SERIALIZATION_CORE_JVM.url_templates],
77+
version = versions.KOTLINX_SERIALIZATION_CORE_JVM,
8078
)
8179

82-
maybe(
80+
versions.use_repository(
8381
http_jar,
8482
name = "kotlinx_serialization_json",
85-
sha256 = versions.KOTLINX_SERIALIZATION_JSON.sha256,
86-
urls = [url.format(version = versions.KOTLINX_SERIALIZATION_JSON.version) for url in versions.KOTLINX_SERIALIZATION_JSON.url_templates],
83+
version = versions.KOTLINX_SERIALIZATION_JSON,
8784
)
8885

89-
maybe(
86+
versions.use_repository(
9087
http_jar,
9188
name = "kotlinx_serialization_json_jvm",
92-
sha256 = versions.KOTLINX_SERIALIZATION_JSON_JVM.sha256,
93-
urls = [url.format(version = versions.KOTLINX_SERIALIZATION_JSON_JVM.version) for url in versions.KOTLINX_SERIALIZATION_JSON_JVM.url_templates],
89+
version = versions.KOTLINX_SERIALIZATION_JSON_JVM,
9490
)
9591

96-
maybe(
92+
versions.use_repository(
9793
http_jar,
9894
name = "kotlin_build_tools_impl",
99-
sha256 = versions.KOTLIN_BUILD_TOOLS_IMPL.sha256,
100-
urls = [url.format(version = versions.KOTLIN_BUILD_TOOLS_IMPL.version) for url in versions.KOTLIN_BUILD_TOOLS_IMPL.url_templates],
95+
version = versions.KOTLIN_BUILD_TOOLS_IMPL,
10196
)
10297

10398
if is_bzlmod:
10499
return
105100

106-
maybe(
101+
versions.use_repository(
107102
http_archive,
108103
name = "py_absl",
109-
sha256 = "8a3d0830e4eb4f66c4fa907c06edf6ce1c719ced811a12e26d9d3162f8471758",
110-
urls = [
111-
"https://github.com/abseil/abseil-py/archive/refs/tags/v2.1.0.tar.gz",
112-
],
113-
strip_prefix = "abseil-py-2.1.0",
104+
version = versions.PY_ABSL,
114105
)
115106

116-
maybe(
107+
versions.use_repository(
117108
http_archive,
118-
name = "rules_cc",
119-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"],
120-
sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df",
121-
strip_prefix = "rules_cc-0.0.16",
109+
name = "py_absl",
110+
version = versions.PY_ABSL,
122111
)
123112

124-
maybe(
113+
versions.use_repository(
114+
http_archive,
115+
name = "rules_cc",
116+
version = versions.RULES_CC,
117+
)
118+
versions.use_repository(
125119
http_archive,
126120
name = "rules_license",
127-
sha256 = versions.RULES_LICENSE.sha256,
128-
urls = [url.format(version = versions.RULES_LICENSE.version) for url in versions.RULES_LICENSE.url_templates],
121+
version = versions.RULES_LICENSE,
129122
)
130-
131-
maybe(
123+
versions.use_repository(
132124
http_archive,
133125
name = "rules_android",
134-
sha256 = versions.RULES_ANDROID.sha256,
135-
strip_prefix = versions.RULES_ANDROID.strip_prefix_template.format(version = versions.RULES_ANDROID.version),
136-
urls = [url.format(version = versions.RULES_ANDROID.version) for url in versions.RULES_ANDROID.url_templates],
126+
version = versions.RULES_ANDROID,
137127
)
138128

139-
maybe(
129+
versions.use_repository(
140130
http_archive,
141131
name = "rules_java",
142-
sha256 = versions.RULES_JAVA.sha256,
143-
urls = [url.format(version = versions.RULES_JAVA.version) for url in versions.RULES_JAVA.url_templates],
132+
version = versions.RULES_JAVA,
144133
)
145134

146135
# See note in versions.bzl before updating bazel_skylib
147-
maybe(
136+
versions.use_repository(
148137
http_archive,
149138
name = "bazel_skylib",
150-
sha256 = versions.BAZEL_SKYLIB.sha256,
151-
urls = [url.format(version = versions.BAZEL_SKYLIB.version) for url in versions.BAZEL_SKYLIB.url_templates],
139+
version = versions.BAZEL_SKYLIB,
152140
)
153141

154-
maybe(
142+
versions.use_repository(
155143
http_archive,
156144
name = "com_google_protobuf",
157-
sha256 = versions.COM_GOOGLE_PROTOBUF.sha256,
158-
strip_prefix = versions.COM_GOOGLE_PROTOBUF.strip_prefix_template.format(version = versions.COM_GOOGLE_PROTOBUF.version),
159-
urls = [url.format(version = versions.COM_GOOGLE_PROTOBUF.version) for url in versions.COM_GOOGLE_PROTOBUF.url_templates],
145+
version = versions.COM_GOOGLE_PROTOBUF,
160146
)
161-
162-
maybe(
147+
versions.use_repository(
163148
http_archive,
164149
name = "rules_proto",
165-
sha256 = versions.RULES_PROTO.sha256,
166-
strip_prefix = versions.RULES_PROTO.strip_prefix_template.format(version = versions.RULES_PROTO.version),
167-
urls = [url.format(version = versions.RULES_PROTO.version) for url in versions.RULES_PROTO.url_templates],
150+
version = versions.RULES_PROTO,
168151
)
169152

170153
def kotlinc_version(release, sha256):

src/main/starlark/core/repositories/versions.bzl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ version = provider(
1010
},
1111
)
1212

13-
def _use_repository(name, version, rule, **kwargs):
14-
http_archive_arguments = dict(kwargs)
15-
http_archive_arguments["sha256"] = version.sha256
16-
http_archive_arguments["urls"] = [u.format(version = version.version) for u in version.url_templates]
13+
def _use_repository(rule, name, version, **kwargs):
14+
rule_arguments = dict(kwargs)
15+
rule_arguments["sha256"] = version.sha256
16+
rule_arguments["urls"] = [u.format(version = version.version) for u in version.url_templates]
1717
if (hasattr(version, "strip_prefix_template")):
18-
http_archive_arguments["strip_prefix"] = version.strip_prefix_template.format(version = version.version)
18+
rule_arguments["strip_prefix"] = version.strip_prefix_template.format(version = version.version)
1919

20-
maybe(rule, name = name, **http_archive_arguments)
20+
maybe(rule, name = name, **rule_arguments)
2121

2222
versions = struct(
2323
# IMPORTANT! rules_kotlin does not use the bazel_skylib unittest in production
@@ -138,5 +138,19 @@ versions = struct(
138138
],
139139
sha256 = "8769e5647557e3700919c32d508f5c5dad53c5d8234cd10846354fbcff14aa24",
140140
),
141+
PY_ABSL = version(
142+
version = "2.1.0",
143+
sha256 = "8a3d0830e4eb4f66c4fa907c06edf6ce1c719ced811a12e26d9d3162f8471758",
144+
url_templates = [
145+
"https://github.com/abseil/abseil-py/archive/refs/tags/v{version}.tar.gz",
146+
],
147+
strip_prefix_template = "abseil-py-{version}",
148+
),
149+
RULES_CC = version(
150+
version = "0.0.16",
151+
url_templates = ["https://github.com/bazelbuild/rules_cc/releases/download/{version}/rules_cc-{version}.tar.gz"],
152+
sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df",
153+
strip_prefix_template = "rules_cc-{version}",
154+
),
141155
use_repository = _use_repository,
142156
)

src/main/starlark/release_archive/repository.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
23
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
34

45
versions = struct(
@@ -189,15 +190,16 @@ def archive_repository(
189190
source_repository_name = source_repository_name or ("%s_head" % name)
190191
if remote_source_archive:
191192
maybe(
192-
http_archive,
193+
http_repository,
194+
type = "archive",
193195
name = source_repository_name,
194196
sha256 = remote_source_archive.sha256,
195197
strip_prefix = remote_source_archive.prefix,
196198
urls = remote_source_archive.urls,
197199
)
198200
else:
199201
maybe(
200-
native.local_repository,
202+
local_repository,
201203
name = source_repository_name,
202204
path = local_path,
203205
)

0 commit comments

Comments
 (0)