Skip to content

Commit 9cafc04

Browse files
authored
Merge pull request #39 from PLeVasseur/feature/update-up-rust-0.3.0-relayer
Update to up-rust 0.3.0
2 parents fb7f5c5 + 1b40568 commit 9cafc04

6 files changed

Lines changed: 73 additions & 60 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ license = "Apache-2.0"
3535
readme = "README.md"
3636
repository = "https://github.com/eclipse-uprotocol/up-transport-vsomeip-rust"
3737
rust-version = "1.76"
38-
version = "0.3.0"
38+
version = "0.4.1"
3939

4040
[workspace.dependencies]
4141
async-trait = { version = "0.1" }
@@ -51,9 +51,7 @@ regex = { version = "1.10" }
5151
serde = { version = "1.0", features = ["derive"] }
5252
serde_json = { version = "1.0" }
5353
tokio = { version = "1.35.1", features = ["rt", "rt-multi-thread", "macros", "sync", "time", "tracing"] }
54-
up-rust = { version = "0.2.0" }
55-
vsomeip-proc-macro = { path = "vsomeip-proc-macro" }
56-
vsomeip-sys = { path = "vsomeip-sys", default-features = false }
54+
up-rust = { version = "0.3.0" }
55+
vsomeip-proc-macro = { version = "0.4.0", path = "vsomeip-proc-macro" }
56+
vsomeip-sys = { version = "0.4.0", path = "vsomeip-sys", default-features = false }
5757

58-
[workspace.dev-dependencies]
59-
test-case = { version = "3.3" }

example-utils/hello-world-protos/Cargo.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@
1111

1212
[package]
1313
name = "hello-world-protos"
14-
version = "0.1.0"
15-
edition = "2021"
14+
description = "Useful protos to be used when doing tests"
15+
documentation.workspace = true
16+
edition.workspace = true
17+
exclude.workspace = true
18+
keywords.workspace = true
19+
license.workspace = true
20+
repository.workspace = true
21+
rust-version.workspace = true
22+
version.workspace = true
23+
publish = false
1624

1725
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1826

up-transport-vsomeip/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
[package]
1515
name = "up-transport-vsomeip"
16+
description = "Layer-1 uTransport implementation for vsomeip (SOME/IP)"
1617
documentation.workspace = true
1718
edition.workspace = true
18-
exclude.workspace = true
1919
keywords.workspace = true
2020
license.workspace = true
2121
repository.workspace = true

up-transport-vsomeip/src/determine_message_type.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ pub fn determine_type(
3434
trace!("source_filter: {source_filter:?}");
3535
trace!("sink_filter: {sink_filter:?}");
3636
let streamer_use_case = {
37-
source_filter.authority_name == "*"
38-
&& source_filter.ue_id == 0x0000_FFFF
39-
&& source_filter.ue_version_major == 0xFF
40-
&& source_filter.resource_id == 0xFFFF
41-
&& sink_filter.authority_name != "*"
42-
&& sink_filter.ue_id == 0x0000_FFFF
43-
&& sink_filter.ue_version_major == 0xFF
44-
&& sink_filter.resource_id == 0xFFFF
37+
source_filter.has_wildcard_authority()
38+
&& source_filter.has_wildcard_entity_type()
39+
&& source_filter.has_wildcard_entity_instance()
40+
&& source_filter.has_wildcard_version()
41+
&& source_filter.has_wildcard_resource_id()
42+
&& !sink_filter.has_wildcard_authority()
43+
&& sink_filter.has_wildcard_entity_type()
44+
&& sink_filter.has_wildcard_entity_instance()
45+
&& sink_filter.has_wildcard_version()
46+
&& sink_filter.has_wildcard_resource_id()
4547
};
4648

4749
if streamer_use_case {

vsomeip-sys/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
[package]
1515
name = "vsomeip-sys"
16+
description = "Somewhat low level unsafe wrapper around vsomeip"
1617
documentation.workspace = true
1718
edition.workspace = true
1819
exclude.workspace = true

vsomeip-sys/build.rs

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
use std::env;
1515
use std::path::PathBuf;
1616

17+
#[cfg(feature = "bundled")]
18+
use std::path::Path;
19+
#[cfg(feature = "bundled")]
20+
use std::{fs, io};
21+
1722
#[cfg(feature = "bundled")]
1823
fn vsomeip_includes() -> PathBuf {
1924
let crate_root =
@@ -100,35 +105,54 @@ mod build {
100105
use std::path::{Path, PathBuf};
101106
use std::process::Command;
102107

108+
use crate::copy_dir_all;
109+
103110
pub fn build() {
104111
let submodule_folder = "vsomeip";
105112

106113
let crate_root = env::var("CARGO_MANIFEST_DIR")
107114
.expect("CARGO_MANIFEST_DIR environment variable is not set");
108115

109116
let patch_folder = PathBuf::from(&crate_root).join("patches");
117+
println!("debug: patch_folder: {}", patch_folder.display());
110118

111119
let submodule_git = PathBuf::from(&crate_root).join(format!("{}/.git", submodule_folder));
112120
println!("debug: submodule_git: {:?}", submodule_git);
113121

114122
// Make sure that the Git submodule is checked out
115123
if !Path::new(&submodule_git).exists() {
116-
let _ = Command::new("git")
124+
let submodule_checkout = Command::new("git")
117125
.arg("-C")
118126
.arg(submodule_folder)
119127
.arg("submodule")
120128
.arg("update")
121129
.arg("--init")
122130
.status();
131+
132+
println!("debug: submodule_checkout: {:?}", submodule_checkout);
123133
}
124134

125-
println!("debug: trying to apply patch");
135+
let out_dir = env::var_os("OUT_DIR").unwrap();
136+
let submodule_to_patch = PathBuf::from(&crate_root).join(submodule_folder);
137+
let vsomeip_build_dir = PathBuf::from(out_dir).join("vsomeip").join("vsomeip_build");
138+
let copy_res = copy_dir_all(&submodule_to_patch, &vsomeip_build_dir);
139+
println!(
140+
"debug: copying vsomeip to output directory to build: {:?}",
141+
copy_res
142+
);
143+
144+
println!(
145+
"debug: trying to apply patch to: {}",
146+
vsomeip_build_dir.display()
147+
);
126148
let disable_test_patch = patch_folder.join("disable_tests.patch");
127149
let disable_test_patch_str = format!("{}", disable_test_patch.display());
128-
let output = Command::new("git")
129-
.arg("-C")
130-
.arg(submodule_folder)
131-
.arg("apply")
150+
println!("disable_test_patch_str: {}", disable_test_patch_str);
151+
let output = Command::new("patch")
152+
.arg("-d")
153+
.arg(&vsomeip_build_dir)
154+
.arg("-p1")
155+
.arg("-i")
132156
.arg(disable_test_patch_str)
133157
.output()
134158
.expect("Failed to apply patch");
@@ -145,15 +169,14 @@ mod build {
145169
let vsomeip_install_path =
146170
env::var("VSOMEIP_INSTALL_PATH").unwrap_or(vsomeip_install_path_default);
147171

148-
let vsomeip_project_root = PathBuf::from(&crate_root).join("vsomeip");
149172
println!("debug: vsomeip_project_root set");
150173
println!(
151174
"debug: vsomeip_project_root: {}",
152-
vsomeip_project_root.display()
175+
vsomeip_build_dir.display()
153176
);
154177
println!("debug: vsomeip_install_path: {}", vsomeip_install_path);
155178

156-
let vsomeip_cmake_build = Config::new(vsomeip_project_root)
179+
let vsomeip_cmake_build = Config::new(vsomeip_build_dir)
157180
.define("CMAKE_INSTALL_PREFIX", vsomeip_install_path.clone())
158181
.define("ENABLE_SIGNAL_HANDLING", "1")
159182
.build_target("install")
@@ -163,40 +186,6 @@ mod build {
163186
"debug: vsomeip_cmake_build: {}",
164187
vsomeip_cmake_build.display()
165188
);
166-
167-
// Remove the changes made
168-
let stash_output = Command::new("git")
169-
.arg("-C")
170-
.arg(submodule_folder)
171-
.arg("stash")
172-
.output()
173-
.expect("Failed to stash changes");
174-
println!("debug: stash output: {:?}", stash_output);
175-
176-
if !stash_output.status.success() {
177-
panic!(
178-
"Failed to stash changes: {}",
179-
String::from_utf8_lossy(&stash_output.stderr)
180-
);
181-
}
182-
183-
// Remove the stash entry
184-
let stash_output = Command::new("git")
185-
.arg("-C")
186-
.arg(submodule_folder)
187-
.arg("stash")
188-
.arg("drop")
189-
.arg("stash@{0}")
190-
.output()
191-
.expect("Failed to stash changes");
192-
println!("debug: stash output: {:?}", stash_output);
193-
194-
if !stash_output.status.success() {
195-
panic!(
196-
"Failed to stash changes: {}",
197-
String::from_utf8_lossy(&stash_output.stderr)
198-
);
199-
}
200189
}
201190
}
202191
mod bindings {
@@ -347,3 +336,18 @@ mod bindings {
347336
fixed_line
348337
}
349338
}
339+
340+
#[cfg(feature = "bundled")]
341+
fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
342+
fs::create_dir_all(&dst)?;
343+
for entry in fs::read_dir(src)? {
344+
let entry = entry?;
345+
let ty = entry.file_type()?;
346+
if ty.is_dir() {
347+
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
348+
} else {
349+
fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
350+
}
351+
}
352+
Ok(())
353+
}

0 commit comments

Comments
 (0)