Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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" }
12 changes: 10 additions & 2 deletions example-utils/hello-world-protos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion up-transport-vsomeip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions vsomeip-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
90 changes: 47 additions & 43 deletions vsomeip-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -100,35 +105,54 @@ mod build {
use std::path::{Path, PathBuf};
use std::process::Command;

use crate::copy_dir_all;

pub fn build() {
let submodule_folder = "vsomeip";

let crate_root = env::var("CARGO_MANIFEST_DIR")
.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");
Expand All @@ -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")
Expand All @@ -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 {
Expand Down Expand Up @@ -347,3 +336,18 @@ mod bindings {
fixed_line
}
}

#[cfg(feature = "bundled")]
fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> 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(())
}