Skip to content

Commit

Permalink
Impl Rust msg serde (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvukov authored Sep 29, 2024
1 parent 859fb2a commit b599d6a
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 3 deletions.
4 changes: 4 additions & 0 deletions repositories/ros2_rust.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ load("@rules_rust//rust:defs.bzl", "rust_library")
rust_library(
name = "rosidl_runtime_rs",
srcs = glob(["rosidl_runtime_rs/src/**/*.rs"]),
crate_features = ["serde"],
edition = "2021",
visibility = ["//visibility:public"],
deps = [
"@rules_ros2_crate_index//:serde",
],
)

cc_library(
Expand Down
226 changes: 225 additions & 1 deletion repositories/rust/Cargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "ceb872808bc19dea7e2bf3a800912471a769fb8aee7fbea69782a3c2d397541b",
"checksum": "b775f30e6fbf62d0a7d15de9feaf871608d6ca3f5c1520a3464f5af0e21a0aef",
"crates": {
"autocfg 1.3.0": {
"name": "autocfg",
Expand Down Expand Up @@ -74,6 +74,14 @@
"id": "serde 1.0.201",
"target": "serde"
},
{
"id": "serde-big-array 0.5.1",
"target": "serde_big_array"
},
{
"id": "serde_json 1.0.128",
"target": "serde_json"
},
{
"id": "signal-hook 0.3.17",
"target": "signal_hook"
Expand Down Expand Up @@ -640,6 +648,45 @@
],
"license_file": "LICENSE-APACHE"
},
"itoa 1.0.11": {
"name": "itoa",
"version": "1.0.11",
"package_url": "https://github.com/dtolnay/itoa",
"repository": {
"Http": {
"url": "https://static.crates.io/crates/itoa/1.0.11/download",
"sha256": "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
}
},
"targets": [
{
"Library": {
"crate_name": "itoa",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": true,
"include": [
"**/*.rs"
]
}
}
}
],
"library_target_name": "itoa",
"common_attrs": {
"compile_data_glob": [
"**"
],
"edition": "2018",
"version": "1.0.11"
},
"license": "MIT OR Apache-2.0",
"license_ids": [
"Apache-2.0",
"MIT"
],
"license_file": "LICENSE-APACHE"
},
"libc 0.2.155": {
"name": "libc",
"version": "0.2.155",
Expand Down Expand Up @@ -968,6 +1015,45 @@
],
"license_file": "LICENSE-APACHE"
},
"ryu 1.0.18": {
"name": "ryu",
"version": "1.0.18",
"package_url": "https://github.com/dtolnay/ryu",
"repository": {
"Http": {
"url": "https://static.crates.io/crates/ryu/1.0.18/download",
"sha256": "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
}
},
"targets": [
{
"Library": {
"crate_name": "ryu",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": true,
"include": [
"**/*.rs"
]
}
}
}
],
"library_target_name": "ryu",
"common_attrs": {
"compile_data_glob": [
"**"
],
"edition": "2018",
"version": "1.0.18"
},
"license": "Apache-2.0 OR BSL-1.0",
"license_ids": [
"Apache-2.0",
"BSL-1.0"
],
"license_file": "LICENSE-APACHE"
},
"serde 1.0.201": {
"name": "serde",
"version": "1.0.201",
Expand Down Expand Up @@ -1051,6 +1137,54 @@
],
"license_file": "LICENSE-APACHE"
},
"serde-big-array 0.5.1": {
"name": "serde-big-array",
"version": "0.5.1",
"package_url": "https://github.com/est31/serde-big-array",
"repository": {
"Http": {
"url": "https://static.crates.io/crates/serde-big-array/0.5.1/download",
"sha256": "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f"
}
},
"targets": [
{
"Library": {
"crate_name": "serde_big_array",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": true,
"include": [
"**/*.rs"
]
}
}
}
],
"library_target_name": "serde_big_array",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "serde 1.0.201",
"target": "serde"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.5.1"
},
"license": "MIT OR Apache-2.0",
"license_ids": [
"Apache-2.0",
"MIT"
],
"license_file": "LICENSE-APACHE"
},
"serde_derive 1.0.201": {
"name": "serde_derive",
"version": "1.0.201",
Expand Down Expand Up @@ -1113,6 +1247,94 @@
],
"license_file": "LICENSE-APACHE"
},
"serde_json 1.0.128": {
"name": "serde_json",
"version": "1.0.128",
"package_url": "https://github.com/serde-rs/json",
"repository": {
"Http": {
"url": "https://static.crates.io/crates/serde_json/1.0.128/download",
"sha256": "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8"
}
},
"targets": [
{
"Library": {
"crate_name": "serde_json",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": true,
"include": [
"**/*.rs"
]
}
}
},
{
"BuildScript": {
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": {
"allow_empty": true,
"include": [
"**/*.rs"
]
}
}
}
],
"library_target_name": "serde_json",
"common_attrs": {
"compile_data_glob": [
"**"
],
"crate_features": {
"common": [
"default",
"std"
],
"selects": {}
},
"deps": {
"common": [
{
"id": "itoa 1.0.11",
"target": "itoa"
},
{
"id": "memchr 2.7.2",
"target": "memchr"
},
{
"id": "ryu 1.0.18",
"target": "ryu"
},
{
"id": "serde 1.0.201",
"target": "serde"
},
{
"id": "serde_json 1.0.128",
"target": "build_script_build"
}
],
"selects": {}
},
"edition": "2021",
"version": "1.0.128"
},
"build_script_attrs": {
"data_glob": [
"**"
]
},
"license": "MIT OR Apache-2.0",
"license_ids": [
"Apache-2.0",
"MIT"
],
"license_file": "LICENSE-APACHE"
},
"signal-hook 0.3.17": {
"name": "signal-hook",
"version": "0.3.17",
Expand Down Expand Up @@ -1542,6 +1764,8 @@
"direct_deps": [
"futures 0.3.30",
"serde 1.0.201",
"serde-big-array 0.5.1",
"serde_json 1.0.128",
"signal-hook 0.3.17"
],
"direct_dev_deps": []
Expand Down
35 changes: 35 additions & 0 deletions repositories/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions repositories/rust_setup_stage_3.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def rust_setup_stage_3(**kwargs):
features = ["derive"],
version = "1",
),
"serde-big-array": crate.spec(
version = "0.5",
),
# Not used by rclrs, used for testing.
"serde_json": crate.spec(
version = "1",
),
# Not used by rclrs, but handy to have.
"signal-hook": crate.spec(
version = "0.3",
Expand Down
6 changes: 5 additions & 1 deletion ros2/rust_interfaces.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ def _compile_rust_code(ctx, label, crate_name, srcs, deps):
)
rustc_rmeta_output = generate_output_diagnostics(ctx, rust_metadata)

attr = ctx.rule.attr + struct(crate_features = [
"serde",
])
providers = rustc_compile_action(
ctx = ctx,
attr = ctx.rule.attr,
attr = attr,
toolchain = toolchain,
output_hash = output_hash,
crate_info_dict = dict(
Expand Down Expand Up @@ -199,6 +202,7 @@ rust_generator_aspect = aspect(
default = [
"@ros2_rust//:rosidl_runtime_rs",
"@rules_ros2_crate_index//:serde",
"@rules_ros2_crate_index//:serde-big-array",
],
),
"_cc_toolchain": attr.label(
Expand Down
Loading

0 comments on commit b599d6a

Please sign in to comment.