From f3bc0dca48d1d2751cfe389db939607ac6e576a6 Mon Sep 17 00:00:00 2001 From: blackanger Date: Thu, 28 May 2020 15:26:55 +0800 Subject: [PATCH 01/10] add derive serde for gen message --- rosrust/Cargo.toml | 3 +++ rosrust_codegen/Cargo.toml | 3 +++ rosrust_codegen/src/msg.rs | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/rosrust/Cargo.toml b/rosrust/Cargo.toml index 2d4fa4c..e889c04 100644 --- a/rosrust/Cargo.toml +++ b/rosrust/Cargo.toml @@ -29,6 +29,9 @@ regex = "1.3.1" criterion = "0.3.0" env_logger = "0.7.1" +[features] +derive-serde = ["rosrust_codegen/derive-serde"] + [[bench]] name = "benchmarks" harness = false diff --git a/rosrust_codegen/Cargo.toml b/rosrust_codegen/Cargo.toml index 04bc520..dbf42f5 100644 --- a/rosrust_codegen/Cargo.toml +++ b/rosrust_codegen/Cargo.toml @@ -19,5 +19,8 @@ digest = "0.8.1" md-5 = "0.8.0" hex = "0.4.0" +[features] +derive-serde = [] + [lib] proc-macro = true diff --git a/rosrust_codegen/src/msg.rs b/rosrust_codegen/src/msg.rs index 8686d5f..5aea33b 100644 --- a/rosrust_codegen/src/msg.rs +++ b/rosrust_codegen/src/msg.rs @@ -64,8 +64,16 @@ impl Msg { .iter() .map(|v| v.const_token_stream(crate_prefix)) .collect::>(); + + let serde_derives = if cfg!(feature = "derive-serde") { + quote! { #[derive(::serde::Serialize, ::serde::Deserialize)] } + } else { + quote! {} + }; + quote! { #[allow(dead_code, non_camel_case_types, non_snake_case)] + #serde_derives #[derive(Clone)] pub struct #name { #(#fields)* From f72d9bd02215b092143ceda9d04f5976cd571688 Mon Sep 17 00:00:00 2001 From: blackanger Date: Thu, 28 May 2020 15:38:38 +0800 Subject: [PATCH 02/10] add serde derive --- rosrust_codegen/src/output_layout.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rosrust_codegen/src/output_layout.rs b/rosrust_codegen/src/output_layout.rs index ff88491..960d3ca 100644 --- a/rosrust_codegen/src/output_layout.rs +++ b/rosrust_codegen/src/output_layout.rs @@ -130,8 +130,15 @@ impl Service { let req_ident = Ident::new(&format!("{}Req", name), Span::call_site()); let res_ident = Ident::new(&format!("{}Res", name), Span::call_site()); + let serde_derives = if cfg!(feature = "derive-serde") { + quote! { #[derive(::serde::Serialize, ::serde::Deserialize)] } + } else { + quote! {} + }; + quote! { #[allow(dead_code,non_camel_case_types,non_snake_case)] + #serde_derives #[derive(Clone, Debug, Default, PartialEq)] pub struct #name_ident; From 7e41f02c8be772be2e3c775510d759366b1fe4de Mon Sep 17 00:00:00 2001 From: blackanger Date: Thu, 28 May 2020 15:50:20 +0800 Subject: [PATCH 03/10] add serde derive --- rosrust_codegen/src/msg.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rosrust_codegen/src/msg.rs b/rosrust_codegen/src/msg.rs index 5aea33b..4c0b02e 100644 --- a/rosrust_codegen/src/msg.rs +++ b/rosrust_codegen/src/msg.rs @@ -395,6 +395,7 @@ fn match_lines(data: &str) -> Result> { .chain_err(|| "Failed to parse line in data string") } +#[cfg_attr(feature = "derive-serde", derive(::serde::Serialize, ::serde::Deserialize))] #[derive(Debug, PartialEq)] struct FieldLine { field_type: String, From 40184a5138b7257668151af767b18b7aca69ee66 Mon Sep 17 00:00:00 2001 From: blackanger Date: Thu, 28 May 2020 15:52:25 +0800 Subject: [PATCH 04/10] add serde derive --- rosrust/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosrust/Cargo.toml b/rosrust/Cargo.toml index e889c04..0bf1854 100644 --- a/rosrust/Cargo.toml +++ b/rosrust/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT" name = "rosrust" readme = "../README.md" repository = "https://github.com/adnanademovic/rosrust" -version = "0.9.4" +version = "0.9.5" [dependencies] byteorder = "1.3.2" From 98e93059fc8176bc014ff44b874101ac98cac8ba Mon Sep 17 00:00:00 2001 From: blackanger Date: Thu, 28 May 2020 15:56:53 +0800 Subject: [PATCH 05/10] modify --- rosrust/Cargo.toml | 2 +- rosrust_codegen/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rosrust/Cargo.toml b/rosrust/Cargo.toml index 0bf1854..b234067 100644 --- a/rosrust/Cargo.toml +++ b/rosrust/Cargo.toml @@ -15,7 +15,7 @@ error-chain = "0.12.1" lazy_static = "1.4.0" log = "0.4.8" nix = "0.15.0" -rosrust_codegen = "0.9.2" +rosrust_codegen = {path="../rosrust_codegen"} serde = "1.0.102" serde_derive = "1.0.102" xml-rpc = "0.0.12" diff --git a/rosrust_codegen/Cargo.toml b/rosrust_codegen/Cargo.toml index dbf42f5..c296cd0 100644 --- a/rosrust_codegen/Cargo.toml +++ b/rosrust_codegen/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT" name = "rosrust_codegen" readme = "README.md" repository = "https://github.com/adnanademovic/rosrust" -version = "0.9.2" +version = "0.9.3" [dependencies] error-chain = "0.12.1" From f6cc82a2cf9ffbd0f7d112d9b8d27cf332605f9f Mon Sep 17 00:00:00 2001 From: blackanger Date: Thu, 28 May 2020 16:02:23 +0800 Subject: [PATCH 06/10] modify --- rosrust_msg/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosrust_msg/Cargo.toml b/rosrust_msg/Cargo.toml index a09e4e0..a3727e2 100644 --- a/rosrust_msg/Cargo.toml +++ b/rosrust_msg/Cargo.toml @@ -10,4 +10,4 @@ version = "0.1.0" build = "build.rs" [dependencies] -rosrust = "0.9.4" +rosrust = {path="../rosrust"} From 2ce2802ee79acd93269e3c789e166413029298fa Mon Sep 17 00:00:00 2001 From: blackanger Date: Thu, 28 May 2020 16:17:19 +0800 Subject: [PATCH 07/10] modify --- rosrust_codegen/Cargo.toml | 9 +++++++-- rosrust_codegen/src/lib.rs | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rosrust_codegen/Cargo.toml b/rosrust_codegen/Cargo.toml index c296cd0..8b3a1cc 100644 --- a/rosrust_codegen/Cargo.toml +++ b/rosrust_codegen/Cargo.toml @@ -8,6 +8,9 @@ readme = "README.md" repository = "https://github.com/adnanademovic/rosrust" version = "0.9.3" +[features] +derive-serde = ["serde"] + [dependencies] error-chain = "0.12.1" lazy_static = "1.4.0" @@ -19,8 +22,10 @@ digest = "0.8.1" md-5 = "0.8.0" hex = "0.4.0" -[features] -derive-serde = [] +[dependencies.serde] +serde = "1.0" + + [lib] proc-macro = true diff --git a/rosrust_codegen/src/lib.rs b/rosrust_codegen/src/lib.rs index 4cfebe2..250788e 100644 --- a/rosrust_codegen/src/lib.rs +++ b/rosrust_codegen/src/lib.rs @@ -2,6 +2,9 @@ extern crate proc_macro; +#[cfg(feature="derive-serde")] +use serde; + mod error; mod genmsg; mod helpers; From 9ff369ba2f02689e774bbbf1f1ec78549fcb18ed Mon Sep 17 00:00:00 2001 From: blackanger Date: Fri, 29 May 2020 21:42:17 +0800 Subject: [PATCH 08/10] modify version --- rosrust/Cargo.toml | 2 +- rosrust_msg/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rosrust/Cargo.toml b/rosrust/Cargo.toml index b234067..3157d19 100644 --- a/rosrust/Cargo.toml +++ b/rosrust/Cargo.toml @@ -15,7 +15,7 @@ error-chain = "0.12.1" lazy_static = "1.4.0" log = "0.4.8" nix = "0.15.0" -rosrust_codegen = {path="../rosrust_codegen"} +rosrust_codegen = 0.9.3 serde = "1.0.102" serde_derive = "1.0.102" xml-rpc = "0.0.12" diff --git a/rosrust_msg/Cargo.toml b/rosrust_msg/Cargo.toml index a3727e2..a09e4e0 100644 --- a/rosrust_msg/Cargo.toml +++ b/rosrust_msg/Cargo.toml @@ -10,4 +10,4 @@ version = "0.1.0" build = "build.rs" [dependencies] -rosrust = {path="../rosrust"} +rosrust = "0.9.4" From 3816545b83cd241bd4cce450a4bc1b1ad2f96f8a Mon Sep 17 00:00:00 2001 From: blackanger Date: Fri, 29 May 2020 22:02:12 +0800 Subject: [PATCH 09/10] modify rosrust version to 0.9.5 --- rosrust_msg/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosrust_msg/Cargo.toml b/rosrust_msg/Cargo.toml index a09e4e0..3d0aee4 100644 --- a/rosrust_msg/Cargo.toml +++ b/rosrust_msg/Cargo.toml @@ -10,4 +10,4 @@ version = "0.1.0" build = "build.rs" [dependencies] -rosrust = "0.9.4" +rosrust = "0.9.5" From e7d2021f3a9730e29cd0a1c71734d786044f9b2d Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 12 Jul 2020 15:49:53 +0800 Subject: [PATCH 10/10] Update Cargo.toml --- rosrust/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosrust/Cargo.toml b/rosrust/Cargo.toml index 3157d19..7d29d25 100644 --- a/rosrust/Cargo.toml +++ b/rosrust/Cargo.toml @@ -15,7 +15,7 @@ error-chain = "0.12.1" lazy_static = "1.4.0" log = "0.4.8" nix = "0.15.0" -rosrust_codegen = 0.9.3 +rosrust_codegen = "0.9.3" serde = "1.0.102" serde_derive = "1.0.102" xml-rpc = "0.0.12"