Skip to content

Commit 6a08ad2

Browse files
committed
fix local repository
1 parent eb2322e commit 6a08ad2

File tree

3 files changed

+56
-58
lines changed

3 files changed

+56
-58
lines changed

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

Lines changed: 32 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ load(
2020
"http_file",
2121
"http_jar",
2222
)
23-
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
2423
load(
2524
"//kotlin/internal:defs.bzl",
2625
_KSP_COMPILER_PLUGIN_REPO = "KSP_COMPILER_PLUGIN_REPO",
@@ -64,107 +63,90 @@ def kotlin_repositories(
6463
strip_version = ksp_compiler_release.version,
6564
)
6665

67-
maybe(
66+
versions.use_repository(
6867
http_file,
6968
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],
69+
version = versions.PINTEREST_KTLINT,
7270
executable = True,
7371
)
7472

75-
maybe(
73+
versions.use_repository(
7674
http_jar,
7775
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],
76+
version = versions.KOTLINX_SERIALIZATION_CORE_JVM,
8077
)
8178

82-
maybe(
79+
versions.use_repository(
8380
http_jar,
8481
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],
82+
version = versions.KOTLINX_SERIALIZATION_JSON,
8783
)
8884

89-
maybe(
85+
versions.use_repository(
9086
http_jar,
9187
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],
88+
version = versions.KOTLINX_SERIALIZATION_JSON_JVM,
9489
)
9590

96-
maybe(
91+
versions.use_repository(
9792
http_jar,
9893
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],
94+
version = versions.KOTLIN_BUILD_TOOLS_IMPL,
10195
)
10296

10397
if is_bzlmod:
10498
return
10599

106-
maybe(
100+
versions.use_repository(
107101
http_archive,
108102
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",
103+
version = versions.PY_ABSL,
114104
)
115105

116-
maybe(
106+
versions.use_repository(
117107
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",
108+
name = "py_absl",
109+
version = versions.PY_ABSL,
122110
)
123111

124-
maybe(
112+
versions.use_repository(
113+
http_archive,
114+
name = "rules_cc",
115+
version = versions.RULES_CC,
116+
)
117+
versions.use_repository(
125118
http_archive,
126119
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],
120+
version = versions.RULES_LICENSE,
129121
)
130-
131-
maybe(
122+
versions.use_repository(
132123
http_archive,
133124
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],
125+
version = versions.RULES_ANDROID,
137126
)
138127

139-
maybe(
128+
versions.use_repository(
140129
http_archive,
141130
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],
131+
version = versions.RULES_JAVA,
144132
)
145133

146134
# See note in versions.bzl before updating bazel_skylib
147-
maybe(
135+
versions.use_repository(
148136
http_archive,
149137
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],
138+
version = versions.BAZEL_SKYLIB,
152139
)
153140

154-
maybe(
141+
versions.use_repository(
155142
http_archive,
156143
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],
144+
version = versions.COM_GOOGLE_PROTOBUF,
160145
)
161-
162-
maybe(
146+
versions.use_repository(
163147
http_archive,
164148
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],
149+
version = versions.RULES_PROTO,
168150
)
169151

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