diff --git a/Cargo.toml b/Cargo.toml index 0c9b0f7c..840db40a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,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" } @@ -51,9 +51,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 a5c15aa8..e81a561e 100644 --- a/up-transport-vsomeip/Cargo.toml +++ b/up-transport-vsomeip/Cargo.toml @@ -13,9 +13,9 @@ [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 diff --git a/vsomeip-sys/Cargo.toml b/vsomeip-sys/Cargo.toml index 085f7ac2..50e1f442 100644 --- a/vsomeip-sys/Cargo.toml +++ b/vsomeip-sys/Cargo.toml @@ -13,6 +13,7 @@ [package] name = "vsomeip-sys" +description = "Somewhat low level unsafe wrapper around vsomeip" documentation.workspace = true edition.workspace = true exclude.workspace = true diff --git a/vsomeip-sys/build.rs b/vsomeip-sys/build.rs index 2afc5721..0a06d692 100644 --- a/vsomeip-sys/build.rs +++ b/vsomeip-sys/build.rs @@ -14,6 +14,11 @@ 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 { let crate_root = @@ -100,6 +105,8 @@ mod build { use std::path::{Path, PathBuf}; use std::process::Command; + use crate::copy_dir_all; + pub fn build() { let submodule_folder = "vsomeip"; @@ -107,28 +114,45 @@ 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 out_dir = env::var_os("OUT_DIR").unwrap(); + 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!( + "debug: copying vsomeip to output directory to build: {:?}", + copy_res + ); + + println!( + "debug: trying to apply patch to: {}", + vsomeip_build_dir.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(&vsomeip_build_dir) + .arg("-p1") + .arg("-i") .arg(disable_test_patch_str) .output() .expect("Failed to apply patch"); @@ -145,15 +169,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") @@ -163,40 +186,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 output: {:?}", stash_output); - - if !stash_output.status.success() { - panic!( - "Failed to stash changes: {}", - 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: stash output: {:?}", stash_output); - - if !stash_output.status.success() { - panic!( - "Failed to stash changes: {}", - String::from_utf8_lossy(&stash_output.stderr) - ); - } } } mod bindings { @@ -347,3 +336,18 @@ mod bindings { fixed_line } } + +#[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)? { + 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(()) +}