The `cxx_build` crate does not support proc macro output (see https://github.com/dtolnay/cxx/issues/808), so we have to generate a standard Rust source file instead.tags/v0.3.3-rc1
| @@ -1697,12 +1697,14 @@ version = "0.1.0" | |||||
| dependencies = [ | dependencies = [ | ||||
| "array-init", | "array-init", | ||||
| "cxx", | "cxx", | ||||
| "cxx-build", | |||||
| "dora-daemon", | "dora-daemon", | ||||
| "dora-ros2-bridge-msg-gen-macro", | |||||
| "dora-ros2-bridge-msg-gen", | |||||
| "eyre", | "eyre", | ||||
| "futures", | "futures", | ||||
| "rand", | "rand", | ||||
| "ros2-client", | "ros2-client", | ||||
| "rust-format", | |||||
| "rustdds", | "rustdds", | ||||
| "serde", | "serde", | ||||
| "serde-big-array", | "serde-big-array", | ||||
| @@ -1726,21 +1728,6 @@ dependencies = [ | |||||
| "thiserror", | "thiserror", | ||||
| ] | ] | ||||
| [[package]] | |||||
| name = "dora-ros2-bridge-msg-gen-macro" | |||||
| version = "0.1.0" | |||||
| dependencies = [ | |||||
| "anyhow", | |||||
| "dora-ros2-bridge-msg-gen", | |||||
| "heck 0.3.3", | |||||
| "nom", | |||||
| "proc-macro2", | |||||
| "quote", | |||||
| "regex", | |||||
| "syn 2.0.41", | |||||
| "thiserror", | |||||
| ] | |||||
| [[package]] | [[package]] | ||||
| name = "dora-ros2-bridge-python" | name = "dora-ros2-bridge-python" | ||||
| version = "0.1.0" | version = "0.1.0" | ||||
| @@ -4679,6 +4666,17 @@ dependencies = [ | |||||
| "eyre", | "eyre", | ||||
| ] | ] | ||||
| [[package]] | |||||
| name = "rust-format" | |||||
| version = "0.3.4" | |||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | |||||
| checksum = "60e7c00b6c3bf5e38a880eec01d7e829d12ca682079f8238a464def3c4b31627" | |||||
| dependencies = [ | |||||
| "prettyplease", | |||||
| "proc-macro2", | |||||
| "syn 1.0.109", | |||||
| ] | |||||
| [[package]] | [[package]] | ||||
| name = "rust-ros2-dataflow-example-node" | name = "rust-ros2-dataflow-example-node" | ||||
| version = "0.3.0" | version = "0.3.0" | ||||
| @@ -27,7 +27,6 @@ members = [ | |||||
| "libraries/extensions/dora-record", | "libraries/extensions/dora-record", | ||||
| "libraries/extensions/ros2-bridge", | "libraries/extensions/ros2-bridge", | ||||
| "libraries/extensions/ros2-bridge/msg-gen", | "libraries/extensions/ros2-bridge/msg-gen", | ||||
| "libraries/extensions/ros2-bridge/msg-gen-macro", | |||||
| "libraries/extensions/ros2-bridge/python", | "libraries/extensions/ros2-bridge/python", | ||||
| ] | ] | ||||
| @@ -5,10 +5,12 @@ use dora_node_api::{ | |||||
| DoraNode, Event, | DoraNode, Event, | ||||
| }; | }; | ||||
| use dora_ros2_bridge::{ | use dora_ros2_bridge::{ | ||||
| geometry_msgs::msg::{Twist, Vector3}, | |||||
| messages::{ | |||||
| geometry_msgs::msg::{Twist, Vector3}, | |||||
| turtlesim::msg::Pose, | |||||
| }, | |||||
| ros2_client::{self, ros2, NodeOptions}, | ros2_client::{self, ros2, NodeOptions}, | ||||
| rustdds::{self, policy}, | rustdds::{self, policy}, | ||||
| turtlesim::msg::Pose, | |||||
| }; | }; | ||||
| use eyre::{eyre, Context}; | use eyre::{eyre, Context}; | ||||
| @@ -7,14 +7,13 @@ edition = "2021" | |||||
| [features] | [features] | ||||
| default = ["generate-messages"] | default = ["generate-messages"] | ||||
| generate-messages = ["dep:dora-ros2-bridge-msg-gen-macro"] | |||||
| cxx-bridge = ["dep:cxx"] | |||||
| generate-messages = ["dep:dora-ros2-bridge-msg-gen", "dep:rust-format"] | |||||
| cxx-bridge = ["dep:cxx", "dep:cxx-build"] | |||||
| # enables examples that depend on a sourced ROS2 installation | # enables examples that depend on a sourced ROS2 installation | ||||
| ros2-examples = ["eyre", "tokio", "dora-daemon"] | ros2-examples = ["eyre", "tokio", "dora-daemon"] | ||||
| [dependencies] | [dependencies] | ||||
| array-init = "2.1.0" | array-init = "2.1.0" | ||||
| dora-ros2-bridge-msg-gen-macro = { path = "msg-gen-macro", optional = true } | |||||
| serde = { version = "1.0.164", features = ["derive"] } | serde = { version = "1.0.164", features = ["derive"] } | ||||
| serde-big-array = "0.5.1" | serde-big-array = "0.5.1" | ||||
| widestring = "1.0.2" | widestring = "1.0.2" | ||||
| @@ -30,3 +29,10 @@ cxx = { version = "1.0", optional = true } | |||||
| [dev-dependencies] | [dev-dependencies] | ||||
| rand = "0.8.5" | rand = "0.8.5" | ||||
| futures = { version = "0.3.28", default-features = false } | futures = { version = "0.3.28", default-features = false } | ||||
| [build-dependencies] | |||||
| dora-ros2-bridge-msg-gen = { path = "msg-gen", optional = true } | |||||
| rust-format = { version = "0.3.4", features = [ | |||||
| "pretty_please", | |||||
| ], optional = true } | |||||
| cxx-build = { version = "1.0.73", optional = true } | |||||
| @@ -0,0 +1,42 @@ | |||||
| use rust_format::Formatter; | |||||
| use std::path::PathBuf; | |||||
| fn main() { | |||||
| let create_cxx_bridge = cfg!(feature = "cxx-bridge"); | |||||
| let paths = ament_prefix_paths(); | |||||
| let generated = dora_ros2_bridge_msg_gen::gen(paths.as_slice(), create_cxx_bridge); | |||||
| let generated_string = rust_format::PrettyPlease::default() | |||||
| .format_tokens(generated) | |||||
| .unwrap(); | |||||
| let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); | |||||
| let target_file = out_dir.join("generated.rs"); | |||||
| std::fs::write(&target_file, generated_string).unwrap(); | |||||
| println!("cargo:rustc-env=GENERATED_PATH={}", target_file.display()); | |||||
| #[cfg(feature = "cxx-bridge")] | |||||
| let _build = cxx_build::bridge(&target_file); | |||||
| } | |||||
| fn ament_prefix_paths() -> Vec<PathBuf> { | |||||
| let ament_prefix_path: String = match std::env::var("AMENT_PREFIX_PATH") { | |||||
| Ok(path) => path, | |||||
| Err(std::env::VarError::NotPresent) => { | |||||
| println!("cargo:warning='AMENT_PREFIX_PATH not set'"); | |||||
| String::new() | |||||
| } | |||||
| Err(std::env::VarError::NotUnicode(s)) => { | |||||
| panic!( | |||||
| "AMENT_PREFIX_PATH is not valid unicode: `{}`", | |||||
| s.to_string_lossy() | |||||
| ); | |||||
| } | |||||
| }; | |||||
| println!("cargo:rerun-if-env-changed=AMENT_PREFIX_PATH"); | |||||
| let paths: Vec<_> = ament_prefix_path.split(':').map(PathBuf::from).collect(); | |||||
| for path in &paths { | |||||
| println!("cargo:rerun-if-changed={}", path.display()); | |||||
| } | |||||
| paths | |||||
| } | |||||
| @@ -1,20 +0,0 @@ | |||||
| [package] | |||||
| name = "dora-ros2-bridge-msg-gen-macro" | |||||
| version = "0.1.0" | |||||
| edition = "2021" | |||||
| authors = ["Yuma Hiramatsu <yuma.hiramatsu@gmail.com>"] | |||||
| license = "Apache-2.0" | |||||
| [dependencies] | |||||
| anyhow = "1.0" | |||||
| heck = "0.3" | |||||
| nom = "7" | |||||
| proc-macro2 = "1.0" | |||||
| quote = "1.0" | |||||
| regex = "1" | |||||
| syn = { version = "2.0.41", features = ["parsing"] } | |||||
| thiserror = "1.0" | |||||
| dora-ros2-bridge-msg-gen = { path = "../msg-gen" } | |||||
| [lib] | |||||
| proc-macro = true | |||||
| @@ -1,25 +0,0 @@ | |||||
| use std::path::Path; | |||||
| fn main() { | |||||
| let ament_prefix_path = match std::env::var("AMENT_PREFIX_PATH") { | |||||
| Ok(path) => path, | |||||
| Err(std::env::VarError::NotPresent) => { | |||||
| println!("cargo:warning='AMENT_PREFIX_PATH not set'"); | |||||
| String::new() | |||||
| } | |||||
| Err(std::env::VarError::NotUnicode(s)) => { | |||||
| panic!( | |||||
| "AMENT_PREFIX_PATH is not valid unicode: `{}`", | |||||
| s.to_string_lossy() | |||||
| ); | |||||
| } | |||||
| }; | |||||
| println!("cargo:rerun-if-env-changed=AMENT_PREFIX_PATH"); | |||||
| let paths = ament_prefix_path.split(':').map(Path::new); | |||||
| for path in paths { | |||||
| println!("cargo:rerun-if-changed={}", path.display()); | |||||
| } | |||||
| println!("cargo:rustc-env=DETECTED_AMENT_PREFIX_PATH={ament_prefix_path}"); | |||||
| } | |||||
| @@ -1,68 +0,0 @@ | |||||
| // Based on https://github.com/rclrust/rclrust/tree/3a48dbb8f23a3d67d3031351da3ed236a354f039/rclrust-msg-gen | |||||
| #![warn( | |||||
| rust_2018_idioms, | |||||
| elided_lifetimes_in_paths, | |||||
| clippy::all, | |||||
| clippy::nursery | |||||
| )] | |||||
| use std::path::Path; | |||||
| use dora_ros2_bridge_msg_gen::get_packages; | |||||
| use proc_macro::TokenStream; | |||||
| use quote::quote; | |||||
| use syn::{punctuated::Punctuated, MetaNameValue, Token}; | |||||
| struct Config { | |||||
| create_cxx_bridge: bool, | |||||
| } | |||||
| impl syn::parse::Parse for Config { | |||||
| fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> { | |||||
| let punctuated = Punctuated::<MetaNameValue, Token![,]>::parse_terminated(input)?; | |||||
| let mut config = Self { | |||||
| create_cxx_bridge: false, | |||||
| }; | |||||
| for item in &punctuated { | |||||
| let ident = item.path.require_ident()?; | |||||
| if ident == "cxx_bridge" { | |||||
| let syn::Expr::Lit(lit) = &item.value else { | |||||
| return Err(syn::Error::new_spanned(&item.value, "invalid value, expected bool")); | |||||
| }; | |||||
| let syn::Lit::Bool(b) = &lit.lit else { | |||||
| return Err(syn::Error::new_spanned(&lit.lit, "invalid value, expected bool")); | |||||
| }; | |||||
| config.create_cxx_bridge = b.value; | |||||
| } else { | |||||
| return Err(syn::Error::new_spanned(&item.path, "invalid argument")); | |||||
| } | |||||
| } | |||||
| Ok(config) | |||||
| } | |||||
| } | |||||
| #[proc_macro] | |||||
| pub fn msg_include_all(input: TokenStream) -> TokenStream { | |||||
| let config = syn::parse_macro_input!(input as Config); | |||||
| let ament_prefix_path = std::env!("DETECTED_AMENT_PREFIX_PATH").trim(); | |||||
| if ament_prefix_path.is_empty() { | |||||
| quote! { | |||||
| /// **No messages are available because the `AMENT_PREFIX_PATH` environment variable | |||||
| /// was not set during build.** | |||||
| pub const AMENT_PREFIX_PATH_NOT_SET: () = (); | |||||
| } | |||||
| .into() | |||||
| } else { | |||||
| let paths = ament_prefix_path | |||||
| .split(':') | |||||
| .map(Path::new) | |||||
| .collect::<Vec<_>>(); | |||||
| dora_ros2_bridge_msg_gen::gen(&paths, config.create_cxx_bridge).into() | |||||
| } | |||||
| } | |||||
| @@ -1,8 +0,0 @@ | |||||
| #goal definition | |||||
| int32 order | |||||
| --- | |||||
| #result definition | |||||
| int32[] sequence | |||||
| --- | |||||
| #feedback | |||||
| int32[] sequence | |||||
| @@ -1,34 +0,0 @@ | |||||
| # Arrays of different types | |||||
| bool[3] bool_values | |||||
| byte[3] byte_values | |||||
| char[3] char_values | |||||
| float32[3] float32_values | |||||
| float64[3] float64_values | |||||
| int8[3] int8_values | |||||
| uint8[3] uint8_values | |||||
| int16[3] int16_values | |||||
| uint16[3] uint16_values | |||||
| int32[3] int32_values | |||||
| uint32[3] uint32_values | |||||
| int64[3] int64_values | |||||
| uint64[3] uint64_values | |||||
| string[3] string_values | |||||
| BasicTypes[3] basic_types_values | |||||
| Constants[3] constants_values | |||||
| Defaults[3] defaults_values | |||||
| bool[3] bool_values_default [false, true, false] | |||||
| byte[3] byte_values_default [0, 1, 255] | |||||
| char[3] char_values_default [0, 1, 127] | |||||
| float32[3] float32_values_default [1.125, 0.0, -1.125] | |||||
| float64[3] float64_values_default [3.1415, 0.0, -3.1415] | |||||
| int8[3] int8_values_default [0, 127, -128] | |||||
| uint8[3] uint8_values_default [0, 1, 255] | |||||
| int16[3] int16_values_default [0, 32767, -32768] | |||||
| uint16[3] uint16_values_default [0, 1, 65535] | |||||
| int32[3] int32_values_default [0, 2147483647, -2147483648] | |||||
| uint32[3] uint32_values_default [0, 1, 4294967295] | |||||
| int64[3] int64_values_default [0, 9223372036854775807, -9223372036854775808] | |||||
| uint64[3] uint64_values_default [0, 1, 18446744073709551615] | |||||
| string[3] string_values_default ["", "max value", "min value"] | |||||
| # Regression test: check alignment of basic field after an array field is correct | |||||
| int32 alignment_check | |||||
| @@ -1,13 +0,0 @@ | |||||
| bool bool_value | |||||
| byte byte_value | |||||
| char char_value | |||||
| float32 float32_value | |||||
| float64 float64_value | |||||
| int8 int8_value | |||||
| uint8 uint8_value | |||||
| int16 int16_value | |||||
| uint16 uint16_value | |||||
| int32 int32_value | |||||
| uint32 uint32_value | |||||
| int64 int64_value | |||||
| uint64 uint64_value | |||||
| @@ -1,34 +0,0 @@ | |||||
| # Bounded sequences of different types | |||||
| bool[<=3] bool_values | |||||
| byte[<=3] byte_values | |||||
| char[<=3] char_values | |||||
| float32[<=3] float32_values | |||||
| float64[<=3] float64_values | |||||
| int8[<=3] int8_values | |||||
| uint8[<=3] uint8_values | |||||
| int16[<=3] int16_values | |||||
| uint16[<=3] uint16_values | |||||
| int32[<=3] int32_values | |||||
| uint32[<=3] uint32_values | |||||
| int64[<=3] int64_values | |||||
| uint64[<=3] uint64_values | |||||
| string[<=3] string_values | |||||
| BasicTypes[<=3] basic_types_values | |||||
| Constants[<=3] constants_values | |||||
| Defaults[<=3] defaults_values | |||||
| bool[<=3] bool_values_default [false, true, false] | |||||
| byte[<=3] byte_values_default [0, 1, 255] | |||||
| char[<=3] char_values_default [0, 1, 127] | |||||
| float32[<=3] float32_values_default [1.125, 0.0, -1.125] | |||||
| float64[<=3] float64_values_default [3.1415, 0.0, -3.1415] | |||||
| int8[<=3] int8_values_default [0, 127, -128] | |||||
| uint8[<=3] uint8_values_default [0, 1, 255] | |||||
| int16[<=3] int16_values_default [0, 32767, -32768] | |||||
| uint16[<=3] uint16_values_default [0, 1, 65535] | |||||
| int32[<=3] int32_values_default [0, 2147483647, -2147483648] | |||||
| uint32[<=3] uint32_values_default [0, 1, 4294967295] | |||||
| int64[<=3] int64_values_default [0, 9223372036854775807, -9223372036854775808] | |||||
| uint64[<=3] uint64_values_default [0, 1, 18446744073709551615] | |||||
| string[<=3] string_values_default ["", "max value", "min value"] | |||||
| # Regression test: check alignment of basic field after a sequence field is correct | |||||
| int32 alignment_check | |||||
| @@ -1,13 +0,0 @@ | |||||
| bool BOOL_CONST=true | |||||
| byte BYTE_CONST=50 | |||||
| char CHAR_CONST=100 | |||||
| float32 FLOAT32_CONST=1.125 | |||||
| float64 FLOAT64_CONST=1.125 | |||||
| int8 INT8_CONST=-50 | |||||
| uint8 UINT8_CONST=200 | |||||
| int16 INT16_CONST=-1000 | |||||
| uint16 UINT16_CONST=2000 | |||||
| int32 INT32_CONST=-30000 | |||||
| uint32 UINT32_CONST=60000 | |||||
| int64 INT64_CONST=-40000000 | |||||
| uint64 UINT64_CONST=50000000 | |||||
| @@ -1,13 +0,0 @@ | |||||
| bool bool_value true | |||||
| byte byte_value 50 | |||||
| char char_value 100 | |||||
| float32 float32_value 1.125 | |||||
| float64 float64_value 1.125 | |||||
| int8 int8_value -50 | |||||
| uint8 uint8_value 200 | |||||
| int16 int16_value -1000 | |||||
| uint16 uint16_value 2000 | |||||
| int32 int32_value -30000 | |||||
| uint32 uint32_value 60000 | |||||
| int64 int64_value -40000000 | |||||
| uint64 uint64_value 50000000 | |||||
| @@ -1,10 +0,0 @@ | |||||
| # Mulitple levels of nested messages | |||||
| Arrays[3] array_of_arrays | |||||
| BoundedSequences[3] array_of_bounded_sequences | |||||
| UnboundedSequences[3] array_of_unbounded_sequences | |||||
| Arrays[<=3] bounded_sequence_of_arrays | |||||
| BoundedSequences[<=3] bounded_sequence_of_bounded_sequences | |||||
| UnboundedSequences[<=3] bounded_sequence_of_unbounded_sequences | |||||
| Arrays[] unbounded_sequence_of_arrays | |||||
| BoundedSequences[] unbounded_sequence_of_bounded_sequences | |||||
| UnboundedSequences[] unbounded_sequence_of_unbounded_sequences | |||||
| @@ -1 +0,0 @@ | |||||
| BasicTypes basic_types_value | |||||
| @@ -1,13 +0,0 @@ | |||||
| string string_value | |||||
| string string_value_default1 "Hello world!" | |||||
| string string_value_default2 "Hello'world!" | |||||
| string string_value_default3 'Hello"world!' | |||||
| string string_value_default4 'Hello\'world!' | |||||
| string string_value_default5 "Hello\"world!" | |||||
| string STRING_CONST="Hello world!" | |||||
| string<=22 bounded_string_value | |||||
| string<=22 bounded_string_value_default1 "Hello world!" | |||||
| string<=22 bounded_string_value_default2 "Hello'world!" | |||||
| string<=22 bounded_string_value_default3 'Hello"world!' | |||||
| string<=22 bounded_string_value_default4 'Hello\'world!' | |||||
| string<=22 bounded_string_value_default5 "Hello\"world!" | |||||
| @@ -1,34 +0,0 @@ | |||||
| # Unbounded sequences of different types | |||||
| bool[] bool_values | |||||
| byte[] byte_values | |||||
| char[] char_values | |||||
| float32[] float32_values | |||||
| float64[] float64_values | |||||
| int8[] int8_values | |||||
| uint8[] uint8_values | |||||
| int16[] int16_values | |||||
| uint16[] uint16_values | |||||
| int32[] int32_values | |||||
| uint32[] uint32_values | |||||
| int64[] int64_values | |||||
| uint64[] uint64_values | |||||
| string[] string_values | |||||
| BasicTypes[] basic_types_values | |||||
| Constants[] constants_values | |||||
| Defaults[] defaults_values | |||||
| bool[] bool_values_default [false, true, false] | |||||
| byte[] byte_values_default [0, 1, 255] | |||||
| char[] char_values_default [0, 1, 127] | |||||
| float32[] float32_values_default [1.125, 0.0, -1.125] | |||||
| float64[] float64_values_default [3.1415, 0.0, -3.1415] | |||||
| int8[] int8_values_default [0, 127, -128] | |||||
| uint8[] uint8_values_default [0, 1, 255] | |||||
| int16[] int16_values_default [0, 32767, -32768] | |||||
| uint16[] uint16_values_default [0, 1, 65535] | |||||
| int32[] int32_values_default [0, 2147483647, -2147483648] | |||||
| uint32[] uint32_values_default [0, 1, 4294967295] | |||||
| int64[] int64_values_default [0, 9223372036854775807, -9223372036854775808] | |||||
| uint64[] uint64_values_default [0, 1, 18446744073709551615] | |||||
| string[] string_values_default ["", "max value", "min value"] | |||||
| # Regression test: check alignment of basic field after a sequence field is correct | |||||
| int32 alignment_check | |||||
| @@ -1,10 +0,0 @@ | |||||
| wstring wstring_value | |||||
| wstring wstring_value_default1 "Hello world!" | |||||
| wstring wstring_value_default2 "Hellö wörld!" | |||||
| wstring wstring_value_default3 "ハローワールド" | |||||
| #wstring WSTRING_CONST="Hello world!" | |||||
| #wstring<=22 bounded_wstring_value | |||||
| #wstring<=22 bounded_wstring_value_default1 "Hello world!" | |||||
| wstring[3] array_of_wstrings | |||||
| wstring[<=3] bounded_sequence_of_wstrings | |||||
| wstring[] unbounded_sequence_of_wstrings | |||||
| @@ -1,63 +0,0 @@ | |||||
| bool[3] bool_values | |||||
| byte[3] byte_values | |||||
| char[3] char_values | |||||
| float32[3] float32_values | |||||
| float64[3] float64_values | |||||
| int8[3] int8_values | |||||
| uint8[3] uint8_values | |||||
| int16[3] int16_values | |||||
| uint16[3] uint16_values | |||||
| int32[3] int32_values | |||||
| uint32[3] uint32_values | |||||
| int64[3] int64_values | |||||
| uint64[3] uint64_values | |||||
| string[3] string_values | |||||
| BasicTypes[3] basic_types_values | |||||
| Constants[3] constants_values | |||||
| Defaults[3] defaults_values | |||||
| bool[3] bool_values_default [false, true, false] | |||||
| byte[3] byte_values_default [0, 1, 255] | |||||
| char[3] char_values_default [0, 1, 127] | |||||
| float32[3] float32_values_default [1.125, 0.0, -1.125] | |||||
| float64[3] float64_values_default [3.1415, 0.0, -3.1415] | |||||
| int8[3] int8_values_default [0, 127, -128] | |||||
| uint8[3] uint8_values_default [0, 1, 255] | |||||
| int16[3] int16_values_default [0, 32767, -32768] | |||||
| uint16[3] uint16_values_default [0, 1, 65535] | |||||
| int32[3] int32_values_default [0, 2147483647, -2147483648] | |||||
| uint32[3] uint32_values_default [0, 1, 4294967295] | |||||
| int64[3] int64_values_default [0, 9223372036854775807, -9223372036854775808] | |||||
| uint64[3] uint64_values_default [0, 1, 18446744073709551615] | |||||
| string[3] string_values_default ["", "max value", "min value"] | |||||
| --- | |||||
| bool[3] bool_values | |||||
| byte[3] byte_values | |||||
| char[3] char_values | |||||
| float32[3] float32_values | |||||
| float64[3] float64_values | |||||
| int8[3] int8_values | |||||
| uint8[3] uint8_values | |||||
| int16[3] int16_values | |||||
| uint16[3] uint16_values | |||||
| int32[3] int32_values | |||||
| uint32[3] uint32_values | |||||
| int64[3] int64_values | |||||
| uint64[3] uint64_values | |||||
| string[3] string_values | |||||
| BasicTypes[3] basic_types_values | |||||
| Constants[3] constants_values | |||||
| Defaults[3] defaults_values | |||||
| bool[3] bool_values_default [false, true, false] | |||||
| byte[3] byte_values_default [0, 1, 255] | |||||
| char[3] char_values_default [0, 1, 127] | |||||
| float32[3] float32_values_default [1.125, 0.0, -1.125] | |||||
| float64[3] float64_values_default [3.1415, 0.0, -3.1415] | |||||
| int8[3] int8_values_default [0, 127, -128] | |||||
| uint8[3] uint8_values_default [0, 1, 255] | |||||
| int16[3] int16_values_default [0, 32767, -32768] | |||||
| uint16[3] uint16_values_default [0, 1, 65535] | |||||
| int32[3] int32_values_default [0, 2147483647, -2147483648] | |||||
| uint32[3] uint32_values_default [0, 1, 4294967295] | |||||
| int64[3] int64_values_default [0, 9223372036854775807, -9223372036854775808] | |||||
| uint64[3] uint64_values_default [0, 1, 18446744073709551615] | |||||
| string[3] string_values_default ["", "max value", "min value"] | |||||
| @@ -1,29 +0,0 @@ | |||||
| bool bool_value | |||||
| byte byte_value | |||||
| char char_value | |||||
| float32 float32_value | |||||
| float64 float64_value | |||||
| int8 int8_value | |||||
| uint8 uint8_value | |||||
| int16 int16_value | |||||
| uint16 uint16_value | |||||
| int32 int32_value | |||||
| uint32 uint32_value | |||||
| int64 int64_value | |||||
| uint64 uint64_value | |||||
| string string_value | |||||
| --- | |||||
| bool bool_value | |||||
| byte byte_value | |||||
| char char_value | |||||
| float32 float32_value | |||||
| float64 float64_value | |||||
| int8 int8_value | |||||
| uint8 uint8_value | |||||
| int16 int16_value | |||||
| uint16 uint16_value | |||||
| int32 int32_value | |||||
| uint32 uint32_value | |||||
| int64 int64_value | |||||
| uint64 uint64_value | |||||
| string string_value | |||||
| @@ -1 +0,0 @@ | |||||
| --- | |||||
| @@ -16,8 +16,11 @@ pub mod types; | |||||
| pub use crate::parser::get_packages; | pub use crate::parser::get_packages; | ||||
| pub fn gen(paths: &[&Path], create_cxx_bridge: bool) -> proc_macro2::TokenStream { | |||||
| let message_structs = get_packages(&paths) | |||||
| pub fn gen<P>(paths: &[P], create_cxx_bridge: bool) -> proc_macro2::TokenStream | |||||
| where | |||||
| P: AsRef<Path>, | |||||
| { | |||||
| let message_structs = get_packages(paths) | |||||
| .unwrap() | .unwrap() | ||||
| .iter() | .iter() | ||||
| .map(|v| v.message_structs(create_cxx_bridge)) | .map(|v| v.message_structs(create_cxx_bridge)) | ||||
| @@ -25,12 +28,12 @@ pub fn gen(paths: &[&Path], create_cxx_bridge: bool) -> proc_macro2::TokenStream | |||||
| let message_struct_defs = message_structs.iter().map(|(s, _)| s); | let message_struct_defs = message_structs.iter().map(|(s, _)| s); | ||||
| let message_struct_impls = message_structs.iter().map(|(_, i)| i); | let message_struct_impls = message_structs.iter().map(|(_, i)| i); | ||||
| let aliases = get_packages(&paths) | |||||
| let aliases = get_packages(paths) | |||||
| .unwrap() | .unwrap() | ||||
| .iter() | .iter() | ||||
| .map(|v| v.aliases_token_stream()) | .map(|v| v.aliases_token_stream()) | ||||
| .collect::<Vec<_>>(); | .collect::<Vec<_>>(); | ||||
| let packages = get_packages(&paths) | |||||
| let packages = get_packages(paths) | |||||
| .unwrap() | .unwrap() | ||||
| .iter() | .iter() | ||||
| .map(|v| v.token_stream(create_cxx_bridge)) | .map(|v| v.token_stream(create_cxx_bridge)) | ||||
| @@ -47,9 +50,9 @@ pub fn gen(paths: &[&Path], create_cxx_bridge: bool) -> proc_macro2::TokenStream | |||||
| ) | ) | ||||
| }; | }; | ||||
| (quote! { | |||||
| quote! { | |||||
| #attributes | #attributes | ||||
| pub mod ffi { | |||||
| mod ffi { | |||||
| #imports | #imports | ||||
| #[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)] | #[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||||
| @@ -73,6 +76,5 @@ pub fn gen(paths: &[&Path], create_cxx_bridge: bool) -> proc_macro2::TokenStream | |||||
| // #(#packages)* | // #(#packages)* | ||||
| }) | |||||
| .into() | |||||
| } | |||||
| } | } | ||||
| @@ -92,10 +92,13 @@ fn get_ros_msgs_each_package<P: AsRef<Path>>(root_dir: P) -> Result<Vec<Package> | |||||
| Ok(packages) | Ok(packages) | ||||
| } | } | ||||
| pub fn get_packages(paths: &[&Path]) -> Result<Vec<Package>> { | |||||
| pub fn get_packages<P>(paths: &[P]) -> Result<Vec<Package>> | |||||
| where | |||||
| P: AsRef<Path>, | |||||
| { | |||||
| let mut packages = paths | let mut packages = paths | ||||
| .iter() | .iter() | ||||
| .map(|&path| get_ros_msgs_each_package(path)) | |||||
| .map(get_ros_msgs_each_package) | |||||
| .collect::<Result<Vec<_>>>()? | .collect::<Result<Vec<_>>>()? | ||||
| .into_iter() | .into_iter() | ||||
| .flatten() | .flatten() | ||||
| @@ -1,10 +1,8 @@ | |||||
| pub use ros2_client; | pub use ros2_client; | ||||
| pub use rustdds; | pub use rustdds; | ||||
| #[cfg(all(feature = "generate-messages", feature = "cxx-bridge"))] | |||||
| dora_ros2_bridge_msg_gen_macro::msg_include_all!(cxx_bridge = true); | |||||
| #[cfg(all(feature = "generate-messages", not(feature = "cxx-bridge")))] | |||||
| dora_ros2_bridge_msg_gen_macro::msg_include_all!(); | |||||
| pub mod messages { | |||||
| include!(env!("GENERATED_PATH")); | |||||
| } | |||||
| pub mod _core; | pub mod _core; | ||||