Skip to content

Commit 74d30cb

Browse files
authored
Merge branch 'main' into rustup
2 parents c09b28d + fa96218 commit 74d30cb

7 files changed

Lines changed: 36 additions & 11 deletions

File tree

crate_universe/extensions.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ There are some more examples of using crate_universe with bzlmod in the [example
373373

374374
load("@bazel_features//:features.bzl", "bazel_features")
375375
load("@bazel_skylib//lib:structs.bzl", "structs")
376-
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
376+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
377377
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
378378
load(
379379
"//crate_universe/private:common_utils.bzl",
@@ -758,7 +758,7 @@ def _generate_hub_and_spokes(
758758
kwargs["commit"] = v
759759
else:
760760
kwargs[k.lower()] = v
761-
new_git_repository(
761+
git_repository(
762762
name = crate_repo_name,
763763
init_submodules = True,
764764
patch_args = repo.get("patch_args", None),

crate_universe/private/crates_repository.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ def _crates_repository_impl(repository_ctx):
4949
# Locate the lockfiles
5050
lockfiles = get_lockfiles(repository_ctx)
5151

52+
# Watch lockfiles and manifests for changes.
53+
repository_ctx.watch(lockfiles.cargo)
54+
if lockfiles.bazel:
55+
repository_ctx.watch(lockfiles.bazel)
56+
for m in repository_ctx.attr.manifests:
57+
repository_ctx.watch(repository_ctx.path(m))
58+
5259
# Locate Rust tools (cargo, rustc)
5360
tools = get_rust_tools(repository_ctx, host_triple)
5461
cargo_path = repository_ctx.path(tools.cargo)

crate_universe/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ pub(crate) struct CrateAnnotations {
345345
pub(crate) additive_build_file_content: Option<String>,
346346

347347
/// For git sourced crates, this is a the
348-
/// [git_repository::shallow_since](https://docs.bazel.build/versions/main/repo/git.html#new_git_repository-shallow_since) attribute.
348+
/// [git_repository::shallow_since](https://docs.bazel.build/versions/main/repo/git.html#git_repository-shallow_since) attribute.
349349
pub(crate) shallow_since: Option<String>,
350350

351351
/// The `patch_args` attribute of a Bazel repository rule. See

crate_universe/src/rendering/templates/module_bzl.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Expected length = 6 lines
1414

1515
"""
1616

17-
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
17+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
1818
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1919
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
2020
load("@bazel_skylib//lib:selects.bzl", "selects")

crate_universe/src/rendering/templates/partials/module/repo_git.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
maybe(
2-
new_git_repository,
2+
git_repository,
33
name = "{{ crate_repository(name = crate.name, version = crate.version) }}",
44
{%- for type, commitish in attrs.commitish %}
55
{%- if type in ["Rev"] %}

rust/platform/triple_mappings.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ _SYSTEM_TO_STATICLIB_EXT = {
210210
"nixos": ".a",
211211
"none": ".a",
212212
"nto": ".a",
213-
"threads": "",
213+
"threads": ".a",
214214
"uefi": ".lib",
215-
"unknown": "",
216-
"wasi": "",
217-
"wasip1": "",
218-
"wasip2": "",
215+
"unknown": ".a",
216+
"wasi": ".a",
217+
"wasip1": ".a",
218+
"wasip2": ".a",
219219
"windows": ".lib",
220220
}
221221

test/unit/platform_triple/platform_triple_test.bzl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
44
load("//rust/platform:triple.bzl", "triple")
5-
load("//rust/platform:triple_mappings.bzl", "SUPPORTED_PLATFORM_TRIPLES")
5+
load("//rust/platform:triple_mappings.bzl", "SUPPORTED_PLATFORM_TRIPLES", "system_to_staticlib_ext")
66

77
def _construct_platform_triple_test_impl(ctx):
88
env = unittest.begin(ctx)
@@ -152,10 +152,24 @@ def _construct_known_triples_test_impl(ctx):
152152

153153
return unittest.end(env)
154154

155+
def _wasm_staticlib_ext_test_impl(ctx):
156+
env = unittest.begin(ctx)
157+
158+
for system in ["threads", "unknown", "wasi", "wasip1", "wasip2"]:
159+
asserts.equals(
160+
env,
161+
".a",
162+
system_to_staticlib_ext(system),
163+
"{} should use a static archive extension".format(system),
164+
)
165+
166+
return unittest.end(env)
167+
155168
construct_platform_triple_test = unittest.make(_construct_platform_triple_test_impl)
156169
construct_minimal_platform_triple_test = unittest.make(_construct_minimal_platform_triple_test_impl)
157170
supported_platform_triples_test = unittest.make(_supported_platform_triples_test_impl)
158171
construct_known_triples_test = unittest.make(_construct_known_triples_test_impl)
172+
wasm_staticlib_ext_test = unittest.make(_wasm_staticlib_ext_test_impl)
159173

160174
def platform_triple_test_suite(name, **kwargs):
161175
"""Define a test suite for testing the `triple` constructor
@@ -176,6 +190,9 @@ def platform_triple_test_suite(name, **kwargs):
176190
construct_known_triples_test(
177191
name = "construct_known_triples_test",
178192
)
193+
wasm_staticlib_ext_test(
194+
name = "wasm_staticlib_ext_test",
195+
)
179196

180197
native.test_suite(
181198
name = name,
@@ -184,6 +201,7 @@ def platform_triple_test_suite(name, **kwargs):
184201
":construct_minimal_platform_triple_test",
185202
":supported_platform_triples_test",
186203
":construct_known_triples_test",
204+
":wasm_staticlib_ext_test",
187205
],
188206
**kwargs
189207
)

0 commit comments

Comments
 (0)