Skip to content

Commit 5d8aeb1

Browse files
committed
fix local repository
1 parent e388a10 commit 5d8aeb1

File tree

4 files changed

+58
-57
lines changed

4 files changed

+58
-57
lines changed

src/main/starlark/core/repositories/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ release_archive(
2323
"bzlmod_impl.bzl",
2424
"compiler.bzl",
2525
"ksp.bzl",
26+
"utils.bzl",
2627
"versions.bzl",
2728
],
2829
src_map = {

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

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -64,107 +64,91 @@ 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(
90-
http_jar,
86+
versions.use_repository(
87+
http_repository,
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,
90+
type = "jar",
9491
)
9592

96-
maybe(
93+
versions.use_repository(
9794
http_jar,
9895
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],
96+
version = versions.KOTLIN_BUILD_TOOLS_IMPL,
10197
)
10298

10399
if is_bzlmod:
104100
return
105101

106-
maybe(
102+
versions.use_repository(
107103
http_archive,
108104
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",
105+
version = versions.PY_ABSL,
114106
)
115107

116-
maybe(
108+
versions.use_repository(
117109
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",
110+
name = "py_absl",
111+
version = versions.PY_ABSL,
122112
)
123113

124-
maybe(
114+
versions.use_repository(
115+
http_archive,
116+
name = "rules_cc",
117+
version = versions.RULES_CC,
118+
)
119+
versions.use_repository(
125120
http_archive,
126121
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],
122+
version = versions.RULES_LICENSE,
129123
)
130-
131-
maybe(
124+
versions.use_repository(
132125
http_archive,
133126
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],
127+
version = versions.RULES_ANDROID,
137128
)
138129

139-
maybe(
130+
versions.use_repository(
140131
http_archive,
141132
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],
133+
version = versions.RULES_JAVA,
144134
)
145135

146136
# See note in versions.bzl before updating bazel_skylib
147-
maybe(
137+
versions.use_repository(
148138
http_archive,
149139
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],
140+
version = versions.BAZEL_SKYLIB,
152141
)
153142

154-
maybe(
143+
versions.use_repository(
155144
http_archive,
156145
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],
146+
version = versions.COM_GOOGLE_PROTOBUF,
160147
)
161-
162-
maybe(
148+
versions.use_repository(
163149
http_archive,
164150
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],
151+
version = versions.RULES_PROTO,
168152
)
169153

170154
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)