Skip to content

Commit 3902162

Browse files
authored
Merge branch 'bazelbuild:main' into toolchain-platform
2 parents c067415 + e961dfc commit 3902162

File tree

12 files changed

+92
-25
lines changed

12 files changed

+92
-25
lines changed

.bcr/metadata.template.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@
22
"homepage": "https://github.com/bazelbuild/rules_rust",
33
"maintainers": [
44
{
5-
"email": "[email protected]",
6-
"github": "UebelAndre",
7-
"name": "UebelAndre"
5+
"email": "[email protected]",
6+
"github": "UebelAndre",
7+
"github_user_id": "26427366",
8+
"name": "UebelAndre"
89
},
910
{
1011
"email": "[email protected]",
1112
"github": "illicitonion",
13+
"github_user_id": "1131704",
1214
"name": "Daniel Wagner-Hall"
1315
},
1416
{
1517
"email": "[email protected]",
1618
"github": "scentini",
19+
"github_user_id": "11149636",
1720
"name": "Rosica Dejanovska"
1821
}
1922
],
20-
"repository": ["github:bazelbuild/rules_rust"],
23+
"repository": [
24+
"github:bazelbuild/rules_rust"
25+
],
2126
"versions": [],
2227
"yanked_versions": {}
2328
}

.github/workflows/release.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
name: Release
33
on:
44
workflow_dispatch:
5-
merge_group:
65
pull_request:
76
branches:
87
- main
@@ -28,7 +27,7 @@ jobs:
2827
steps:
2928
- uses: actions/checkout@v4
3029
- name: Ensure release does not already exist
31-
if: startsWith(github.ref, 'refs/heads/main') == false
30+
if: startsWith(github.ref, 'refs/heads/main')
3231
run: |
3332
git fetch origin &> /dev/null
3433
version="$(grep 'VERSION =' ${{ github.workspace }}/version.bzl | sed 's/VERSION = "//' | sed 's/"//')"
@@ -46,12 +45,15 @@ jobs:
4645
matrix:
4746
# Create a job for each target triple
4847
include:
49-
- os: macOS-13
48+
- os: macOS-14
5049
env:
5150
TARGET: "aarch64-apple-darwin"
5251
- os: ubuntu-22.04
5352
env:
5453
TARGET: "aarch64-unknown-linux-gnu"
54+
- os: ubuntu-22.04
55+
env:
56+
TARGET: "aarch64-unknown-linux-musl"
5557
- os: windows-2022
5658
env:
5759
TARGET: "aarch64-pc-windows-msvc"

crate_universe/extensions.bzl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -779,19 +779,19 @@ def _package_to_json(p):
779779
if v or k == "default_features"
780780
})
781781

782-
def _get_generator(module_ctx):
782+
def _get_generator(module_ctx, host_triple):
783783
"""Query Network Resources to local a `cargo-bazel` binary.
784784
785785
Based off get_generator in crates_universe/private/generate_utils.bzl
786786
787787
Args:
788-
module_ctx (module_ctx): The rules context object
788+
module_ctx (module_ctx): The rules context object
789+
host_triple (struct): A triple struct that represents the host.
789790
790791
Returns:
791792
tuple(path, dict) The path to a 'cargo-bazel' binary. The pairing (dict)
792793
may be `None` if there is not need to update the attribute
793794
"""
794-
host_triple = get_host_triple(module_ctx)
795795
use_environ = False
796796
for var in GENERATOR_ENV_VARS:
797797
if var in module_ctx.os.environ:
@@ -858,8 +858,11 @@ def _get_host_cargo_rustc(module_ctx, host_triple, host_tools_repo):
858858

859859
def _crate_impl(module_ctx):
860860
reproducible = True
861-
generator = _get_generator(module_ctx)
862-
host_triple = get_host_triple(module_ctx)
861+
host_triple = get_host_triple(module_ctx, abi = {
862+
"aarch64-unknown-linux": "musl",
863+
"x86_64-unknown-linux": "musl",
864+
})
865+
generator = _get_generator(module_ctx, host_triple)
863866

864867
all_repos = []
865868

crate_universe/private/crate.bzl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,12 @@ def _annotation(
135135
build_script_data_glob (list, optional): A list of glob patterns to add to a crate's `cargo_build_script::data`
136136
attribute.
137137
build_script_deps (list, optional): A list of labels to add to a crate's `cargo_build_script::deps` attribute.
138-
build_script_env (dict, optional): Additional environment variables to set on a crate's
139-
`cargo_build_script::env` attribute.
138+
build_script_env (dict, optional): Additional environment variables to set when running the crate's `cargo_build_script` - sets that target's `build_script_env` attribute.
140139
build_script_link_deps: A list of labels to add to a crate's `cargo_build_script::link_deps` attribute.
141140
build_script_proc_macro_deps (list, optional): A list of labels to add to a crate's
142141
`cargo_build_script::proc_macro_deps` attribute.
143142
build_script_rundir (str, optional): An override for the build script's rundir attribute.
144-
build_script_rustc_env (dict, optional): Additional environment variables to set on a crate's
145-
`cargo_build_script::env` attribute.
143+
build_script_rustc_env (dict, optional): Additional environment variables to set when compiling the crate's `cargo_build_script` - sets that target's `rustc_env` attribute.
146144
build_script_toolchains (list, optional): A list of labels to set on a crates's `cargo_build_script::toolchains` attribute.
147145
build_script_use_default_shell_env (int, optional): Whether or not to include the default shell environment for the build
148146
script action.

rust/platform/triple.bzl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _validate_cpu_architecture(arch, expected_archs):
8686
expected_archs,
8787
))
8888

89-
def get_host_triple(repository_ctx, abi = None):
89+
def get_host_triple(repository_ctx, abi = {}):
9090
"""Query host information for the appropriate triple to use with load_arbitrary_tool or the crate_universe resolver
9191
9292
Example:
@@ -110,8 +110,9 @@ def get_host_triple(repository_ctx, abi = None):
110110
111111
Args:
112112
repository_ctx (repository_ctx): The repository_rule's context object
113-
abi (str): Since there's no consistent way to check for ABI, this info
114-
may be explicitly provided
113+
abi (dict): A mapping of platform triple prefixes to desired abi. This
114+
is useful since there's no consistent way to check for ABI, this info
115+
may be explicitly provided.
115116
116117
Returns:
117118
struct: A triple struct; see the `triple` function in this module
@@ -134,9 +135,10 @@ def get_host_triple(repository_ctx, abi = None):
134135

135136
if "linux" in repository_ctx.os.name:
136137
_validate_cpu_architecture(arch, supported_architectures["linux"])
137-
return triple("{}-unknown-linux-{}".format(
138-
arch,
139-
abi or "gnu",
138+
prefix = "{}-unknown-linux".format(arch)
139+
return triple("{}-{}".format(
140+
prefix,
141+
abi.get(prefix, "gnu"),
140142
))
141143

142144
if "mac" in repository_ctx.os.name:
@@ -145,9 +147,10 @@ def get_host_triple(repository_ctx, abi = None):
145147

146148
if "win" in repository_ctx.os.name:
147149
_validate_cpu_architecture(arch, supported_architectures["windows"])
148-
return triple("{}-pc-windows-{}".format(
149-
arch,
150-
abi or "msvc",
150+
prefix = "{}-pc-windows".format(arch)
151+
return triple("{}-{}".format(
152+
prefix,
153+
abi.get(prefix, "msvc"),
151154
))
152155

153156
fail("Unhandled host os: {}", repository_ctx.os.name)

rust/rust_binary.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""rust_binary"""
2+
3+
load(
4+
"//rust/private:rust.bzl",
5+
_rust_binary = "rust_binary",
6+
)
7+
8+
rust_binary = _rust_binary

rust/rust_library.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""rust_library"""
2+
3+
load(
4+
"//rust/private:rust.bzl",
5+
_rust_library = "rust_library",
6+
)
7+
8+
rust_library = _rust_library

rust/rust_library_group.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""rust_library_group"""
2+
3+
load(
4+
"//rust/private:rust.bzl",
5+
_rust_library_group = "rust_library_group",
6+
)
7+
8+
rust_library_group = _rust_library_group

rust/rust_proc_macro.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""rust_proc_macro"""
2+
3+
load(
4+
"//rust/private:rust.bzl",
5+
_rust_proc_macro = "rust_proc_macro",
6+
)
7+
8+
rust_proc_macro = _rust_proc_macro

rust/rust_shared_library.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""rust_shared_library"""
2+
3+
load(
4+
"//rust/private:rust.bzl",
5+
_rust_shared_library = "rust_shared_library",
6+
)
7+
8+
rust_shared_library = _rust_shared_library

rust/rust_static_library.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""rust_static_library"""
2+
3+
load(
4+
"//rust/private:rust.bzl",
5+
_rust_static_library = "rust_static_library",
6+
)
7+
8+
rust_static_library = _rust_static_library

rust/rust_test.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""rust_test"""
2+
3+
load(
4+
"//rust/private:rust.bzl",
5+
_rust_test = "rust_test",
6+
)
7+
8+
rust_test = _rust_test

0 commit comments

Comments
 (0)