From ce4aac5429fa5b384ae4b80e40af909e5fbcb50b Mon Sep 17 00:00:00 2001 From: Peter LeVasseur Date: Wed, 8 Jan 2025 12:09:55 -0500 Subject: [PATCH 1/3] Update to up-rust 0.3.0 --- Cargo.toml | 10 +++---- example-utils/hello-world-protos/Cargo.toml | 12 ++++++-- up-transport-vsomeip/Cargo.toml | 4 +-- vsomeip-proc-macro/Cargo.toml | 11 +++++-- vsomeip-sys/Cargo.toml | 9 +++++- vsomeip-sys/build.rs | 33 +++++++++++++-------- 6 files changed, 54 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fcf27b22..2bb4b555 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ license = "Apache-2.0" readme = "README.md" repository = "https://github.com/eclipse-uprotocol/up-transport-vsomeip-rust" rust-version = "1.76" -version = "0.3.0" +version = "0.4.0" [workspace.dependencies] async-trait = { version = "0.1" } @@ -50,9 +50,7 @@ regex = { version = "1.10" } serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } tokio = { version = "1.35.1", features = ["rt", "rt-multi-thread", "macros", "sync", "time", "tracing"] } -up-rust = { version = "0.2.0" } -vsomeip-proc-macro = { path = "vsomeip-proc-macro" } -vsomeip-sys = { path = "vsomeip-sys", default-features = false } +up-rust = { version = "0.3.0" } +vsomeip-proc-macro = { version = "0.4.0", path = "vsomeip-proc-macro" } +vsomeip-sys = { version = "0.4.0", path = "vsomeip-sys", default-features = false } -[workspace.dev-dependencies] -test-case = { version = "3.3" } diff --git a/example-utils/hello-world-protos/Cargo.toml b/example-utils/hello-world-protos/Cargo.toml index 91559b0a..ec18605d 100644 --- a/example-utils/hello-world-protos/Cargo.toml +++ b/example-utils/hello-world-protos/Cargo.toml @@ -11,8 +11,16 @@ [package] name = "hello-world-protos" -version = "0.1.0" -edition = "2021" +description = "Useful protos to be used when doing tests" +documentation.workspace = true +edition.workspace = true +exclude.workspace = true +keywords.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true +publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/up-transport-vsomeip/Cargo.toml b/up-transport-vsomeip/Cargo.toml index 1a4e7c52..e81a561e 100644 --- a/up-transport-vsomeip/Cargo.toml +++ b/up-transport-vsomeip/Cargo.toml @@ -13,15 +13,15 @@ [package] name = "up-transport-vsomeip" +description = "Layer-1 uTransport implementation for vsomeip (SOME/IP)" documentation.workspace = true edition.workspace = true -exclude.workspace = true keywords.workspace = true license.workspace = true repository.workspace = true rust-version.workspace = true version.workspace = true -readme = "README.md" +readme = "../README.md" [features] default = ["bundled"] diff --git a/vsomeip-proc-macro/Cargo.toml b/vsomeip-proc-macro/Cargo.toml index 1f0bfe0e..70953957 100644 --- a/vsomeip-proc-macro/Cargo.toml +++ b/vsomeip-proc-macro/Cargo.toml @@ -13,8 +13,15 @@ [package] name = "vsomeip-proc-macro" -version = "0.1.0" -edition = "2021" +description = "Useful proc macros for interfacing with vsomeip" +documentation.workspace = true +edition.workspace = true +exclude.workspace = true +keywords.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/vsomeip-sys/Cargo.toml b/vsomeip-sys/Cargo.toml index b5a96a28..9c3781d4 100644 --- a/vsomeip-sys/Cargo.toml +++ b/vsomeip-sys/Cargo.toml @@ -13,8 +13,15 @@ [package] name = "vsomeip-sys" -version.workspace = true +description = "Somewhat low level unsafe wrapper around vsomeip" +documentation.workspace = true edition.workspace = true +exclude.workspace = true +keywords.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/vsomeip-sys/build.rs b/vsomeip-sys/build.rs index 2afc5721..cce717a7 100644 --- a/vsomeip-sys/build.rs +++ b/vsomeip-sys/build.rs @@ -107,28 +107,37 @@ mod build { .expect("CARGO_MANIFEST_DIR environment variable is not set"); let patch_folder = PathBuf::from(&crate_root).join("patches"); + println!("debug: patch_folder: {}", patch_folder.display()); let submodule_git = PathBuf::from(&crate_root).join(format!("{}/.git", submodule_folder)); println!("debug: submodule_git: {:?}", submodule_git); // Make sure that the Git submodule is checked out if !Path::new(&submodule_git).exists() { - let _ = Command::new("git") + let submodule_checkout = Command::new("git") .arg("-C") .arg(submodule_folder) .arg("submodule") .arg("update") .arg("--init") .status(); + + println!("debug: submodule_checkout: {:?}", submodule_checkout); } - println!("debug: trying to apply patch"); + let submodule_to_patch = PathBuf::from(&crate_root).join(format!("{}", submodule_folder)); + println!( + "debug: trying to apply patch to: {}", + submodule_to_patch.display() + ); let disable_test_patch = patch_folder.join("disable_tests.patch"); let disable_test_patch_str = format!("{}", disable_test_patch.display()); - let output = Command::new("git") - .arg("-C") - .arg(submodule_folder) - .arg("apply") + println!("disable_test_patch_str: {}", disable_test_patch_str); + let output = Command::new("patch") + .arg("-d") + .arg(&submodule_to_patch) + .arg("-p1") + .arg("-i") .arg(disable_test_patch_str) .output() .expect("Failed to apply patch"); @@ -171,11 +180,11 @@ mod build { .arg("stash") .output() .expect("Failed to stash changes"); - println!("debug: stash output: {:?}", stash_output); + println!("debug: stash changes output: {:?}", stash_output); if !stash_output.status.success() { - panic!( - "Failed to stash changes: {}", + println!( + "Failed to stash changes, maybe you're running a publish: {}", String::from_utf8_lossy(&stash_output.stderr) ); } @@ -189,11 +198,11 @@ mod build { .arg("stash@{0}") .output() .expect("Failed to stash changes"); - println!("debug: stash output: {:?}", stash_output); + println!("debug: remove stash output: {:?}", stash_output); if !stash_output.status.success() { - panic!( - "Failed to stash changes: {}", + println!( + "Failed to stash changes, maybe you're running a publish: {}", String::from_utf8_lossy(&stash_output.stderr) ); } From f3e61baa50abb467331cead4f372b7631ff63f7c Mon Sep 17 00:00:00 2001 From: Peter LeVasseur Date: Tue, 21 Jan 2025 11:33:14 -0500 Subject: [PATCH 2/3] Trying to make a dedicated OUT_DIR for modifying the vsomeip CMakeLists.txt --- vsomeip-sys/build.rs | 71 +++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/vsomeip-sys/build.rs b/vsomeip-sys/build.rs index cce717a7..22d9c399 100644 --- a/vsomeip-sys/build.rs +++ b/vsomeip-sys/build.rs @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -use std::env; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; +use std::{env, fs, io}; #[cfg(feature = "bundled")] fn vsomeip_includes() -> PathBuf { @@ -100,6 +100,8 @@ mod build { use std::path::{Path, PathBuf}; use std::process::Command; + use crate::copy_dir_all; + pub fn build() { let submodule_folder = "vsomeip"; @@ -125,17 +127,25 @@ mod build { println!("debug: submodule_checkout: {:?}", submodule_checkout); } + let out_dir = env::var_os("OUT_DIR").unwrap(); let submodule_to_patch = PathBuf::from(&crate_root).join(format!("{}", submodule_folder)); + let vsomeip_build_dir = PathBuf::from(out_dir).join("vsomeip").join("vsomeip_build"); + let copy_res = copy_dir_all(&submodule_to_patch, &vsomeip_build_dir); + println!( + "debug: copying vsomeip to output directory to build: {:?}", + copy_res + ); + println!( "debug: trying to apply patch to: {}", - submodule_to_patch.display() + vsomeip_build_dir.display() ); let disable_test_patch = patch_folder.join("disable_tests.patch"); let disable_test_patch_str = format!("{}", disable_test_patch.display()); println!("disable_test_patch_str: {}", disable_test_patch_str); let output = Command::new("patch") .arg("-d") - .arg(&submodule_to_patch) + .arg(&vsomeip_build_dir) .arg("-p1") .arg("-i") .arg(disable_test_patch_str) @@ -154,15 +164,14 @@ mod build { let vsomeip_install_path = env::var("VSOMEIP_INSTALL_PATH").unwrap_or(vsomeip_install_path_default); - let vsomeip_project_root = PathBuf::from(&crate_root).join("vsomeip"); println!("debug: vsomeip_project_root set"); println!( "debug: vsomeip_project_root: {}", - vsomeip_project_root.display() + vsomeip_build_dir.display() ); println!("debug: vsomeip_install_path: {}", vsomeip_install_path); - let vsomeip_cmake_build = Config::new(vsomeip_project_root) + let vsomeip_cmake_build = Config::new(vsomeip_build_dir) .define("CMAKE_INSTALL_PREFIX", vsomeip_install_path.clone()) .define("ENABLE_SIGNAL_HANDLING", "1") .build_target("install") @@ -172,40 +181,6 @@ mod build { "debug: vsomeip_cmake_build: {}", vsomeip_cmake_build.display() ); - - // Remove the changes made - let stash_output = Command::new("git") - .arg("-C") - .arg(submodule_folder) - .arg("stash") - .output() - .expect("Failed to stash changes"); - println!("debug: stash changes output: {:?}", stash_output); - - if !stash_output.status.success() { - println!( - "Failed to stash changes, maybe you're running a publish: {}", - String::from_utf8_lossy(&stash_output.stderr) - ); - } - - // Remove the stash entry - let stash_output = Command::new("git") - .arg("-C") - .arg(submodule_folder) - .arg("stash") - .arg("drop") - .arg("stash@{0}") - .output() - .expect("Failed to stash changes"); - println!("debug: remove stash output: {:?}", stash_output); - - if !stash_output.status.success() { - println!( - "Failed to stash changes, maybe you're running a publish: {}", - String::from_utf8_lossy(&stash_output.stderr) - ); - } } } mod bindings { @@ -356,3 +331,17 @@ mod bindings { fixed_line } } + +fn copy_dir_all(src: impl AsRef, dst: impl AsRef) -> io::Result<()> { + fs::create_dir_all(&dst)?; + for entry in fs::read_dir(src)? { + let entry = entry?; + let ty = entry.file_type()?; + if ty.is_dir() { + copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?; + } else { + fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?; + } + } + Ok(()) +} From 97553f6b9e17ecfc49c51145c282f99913854ad3 Mon Sep 17 00:00:00 2001 From: Peter LeVasseur Date: Wed, 22 Jan 2025 23:20:38 -0500 Subject: [PATCH 3/3] cargo fmt --- vsomeip-sys/build.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vsomeip-sys/build.rs b/vsomeip-sys/build.rs index 22d9c399..0a06d692 100644 --- a/vsomeip-sys/build.rs +++ b/vsomeip-sys/build.rs @@ -11,8 +11,13 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -use std::path::{Path, PathBuf}; -use std::{env, fs, io}; +use std::env; +use std::path::PathBuf; + +#[cfg(feature = "bundled")] +use std::path::Path; +#[cfg(feature = "bundled")] +use std::{fs, io}; #[cfg(feature = "bundled")] fn vsomeip_includes() -> PathBuf { @@ -128,7 +133,7 @@ mod build { } let out_dir = env::var_os("OUT_DIR").unwrap(); - let submodule_to_patch = PathBuf::from(&crate_root).join(format!("{}", submodule_folder)); + let submodule_to_patch = PathBuf::from(&crate_root).join(submodule_folder); let vsomeip_build_dir = PathBuf::from(out_dir).join("vsomeip").join("vsomeip_build"); let copy_res = copy_dir_all(&submodule_to_patch, &vsomeip_build_dir); println!( @@ -332,6 +337,7 @@ mod bindings { } } +#[cfg(feature = "bundled")] fn copy_dir_all(src: impl AsRef, dst: impl AsRef) -> io::Result<()> { fs::create_dir_all(&dst)?; for entry in fs::read_dir(src)? {