Skip to content

Commit c9c115a

Browse files
Initial iceoryx integration
1 parent 0a9553b commit c9c115a

File tree

13 files changed

+791
-15
lines changed

13 files changed

+791
-15
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ bazel_dep(name = "score_crates", version = "0.0.4", repo_name = "crate_index")
9898
# Temporary: Use latest GitHub main with regenerated BUILD file including paste and arrayvec
9999
git_override(
100100
module_name = "score_crates",
101-
commit = "636a5add5ffd53177fd0fdf70b672043ac2664c4",
101+
commit = "dcbc6a4d36c9293549397893650c3a7068b0682d",
102102
remote = "https://github.com/eclipse-score/score-crates.git",
103103
)
104104

score/mw/com/example/com-api-example/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test")
1616
rust_binary(
1717
name = "com-api-example",
1818
srcs = ["basic-consumer-producer.rs"],
19+
crate_features = select({
20+
"//score/mw/com/flags:use_iceoryx_flag": ["iceoryx"],
21+
"//conditions:default": [],
22+
}),
1923
visibility = ["//visibility:public"],
2024
deps = [
2125
"//score/mw/com/example/com-api-example/com-api-gen",

score/mw/com/example/com-api-example/basic-consumer-producer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ fn run_with_runtime<R: Runtime>(name: &str, runtime: &R) {
9292
println!("=== {} runtime completed ===\n", name);
9393
}
9494

95+
#[cfg(feature = "iceoryx")]
96+
fn main() {
97+
let iceoryx_runtime_builder = IceoryxRuntimeBuilderImpl::new();
98+
let iceoryx_runtime = Builder::<IceoryxRuntimeImpl>::build(iceoryx_runtime_builder).unwrap();
99+
run_with_runtime("Iceoryx", &iceoryx_runtime);
100+
}
101+
102+
#[cfg(not(feature = "iceoryx"))]
95103
fn main() {
96104
let mock_runtime_builder = MockRuntimeBuilderImpl::new();
97105
let mock_runtime = Builder::<MockRuntimeImpl>::build(mock_runtime_builder).unwrap();

score/mw/com/example/com-api-example/com-api-gen/BUILD

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ rust_library(
1616
name = "com-api-gen",
1717
srcs = ["com_api_gen.rs"],
1818
crate_name = "com_api_gen",
19+
crate_features = select({
20+
"//score/mw/com/flags:use_iceoryx_flag": ["iceoryx"],
21+
"//conditions:default": [],
22+
}),
1923
visibility = [
2024
"//visibility:public", # platform_only
2125
],
22-
deps = [
23-
"//score/mw/com/impl/rust/com-api/com-api",
24-
],
26+
deps = ["//score/mw/com/impl/rust/com-api/com-api",] +
27+
select({
28+
"//score/mw/com/flags:use_iceoryx_flag": ["@crate_index//:iceoryx2_qnx8",],
29+
"//conditions:default": [],
30+
}),
2531
)

score/mw/com/example/com-api-example/com-api-gen/com_api_gen.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*
1111
* SPDX-License-Identifier: Apache-2.0
1212
********************************************************************************/
13+
#[cfg(feature = "iceoryx")]
14+
use iceoryx2_qnx8::prelude::ZeroCopySend;
1315

1416
use com_api::{
1517
Consumer, Interface, OfferedProducer, Producer, Publisher, Reloc, Runtime, Subscriber,
@@ -18,11 +20,16 @@ use com_api::{
1820
#[derive(Debug)]
1921
pub struct Tire {}
2022
unsafe impl Reloc for Tire {}
23+
#[cfg(feature = "iceoryx")]
24+
unsafe impl ZeroCopySend for Tire {}
2125

2226
#[derive(Debug)]
2327
pub struct Exhaust {}
2428
unsafe impl Reloc for Exhaust {}
29+
#[cfg(feature = "iceoryx")]
30+
unsafe impl ZeroCopySend for Exhaust {}
2531

32+
#[derive(Debug)]
2633
pub struct VehicleInterface {}
2734

2835
/// Generic

score/mw/com/flags/BUILD

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# SPDX-License-Identifier: Apache-2.0
1212
# *******************************************************************************
1313

14-
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
14+
load("@bazel_skylib//rules:common_settings.bzl", "string_flag", "bool_flag")
1515

1616
string_flag(
1717
name = "tracing_library",
@@ -37,3 +37,16 @@ config_setting(
3737
"//score/mw/com/impl/tracing:__subpackages__",
3838
],
3939
)
40+
41+
bool_flag(
42+
name = "use_iceoryx",
43+
build_setting_default = False,
44+
)
45+
46+
config_setting(
47+
name = "use_iceoryx_flag",
48+
flag_values = {
49+
":use_iceoryx": "True",
50+
},
51+
visibility = ["//visibility:public"],
52+
)

score/mw/com/impl/rust/com-api/com-api-concept/BUILD

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,21 @@ rust_library(
2222
visibility = [
2323
"//visibility:public", # platform_only
2424
],
25-
deps = [],
25+
)
26+
27+
rust_library(
28+
name = "com-api-concept-iceoryx",
29+
srcs = [
30+
"com_api_concept.rs",
31+
"reloc.rs",
32+
],
33+
crate_features = ["iceoryx"],
34+
crate_name = "com_api_concept",
35+
crate_root = "com_api_concept.rs",
36+
visibility = [
37+
"//visibility:public", # platform_only
38+
],
39+
deps = ["@crate_index//:iceoryx2_qnx8"],
2640
)
2741

2842
rust_test(

score/mw/com/impl/rust/com-api/com-api-concept/com_api_concept.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,15 @@ pub trait Builder<Output> {
9090
/// the implementation.
9191
pub trait Runtime {
9292
/// ServiceDiscovery<I> types for Discovers available service instances of a specific interface
93+
#[cfg(feature = "iceoryx")]
94+
type ServiceDiscovery<I: Interface + Debug>: ServiceDiscovery<I, Self>;
95+
#[cfg(not(feature = "iceoryx"))]
9396
type ServiceDiscovery<I: Interface>: ServiceDiscovery<I, Self>;
9497

9598
/// Subscriber<T> types for Manages subscriptions to event notifications
99+
#[cfg(feature = "iceoryx")]
100+
type Subscriber<T: Reloc + Send + Debug + 'static>: Subscriber<T, Self>;
101+
#[cfg(not(feature = "iceoryx"))]
96102
type Subscriber<T: Reloc + Send + Debug>: Subscriber<T, Self>;
97103

98104
/// ProducerBuilder<I, P> types for Constructs producer instances for offering services
@@ -103,6 +109,9 @@ pub trait Runtime {
103109
>;
104110

105111
/// Publisher<T> types for Publishes event data to subscribers
112+
#[cfg(feature = "iceoryx")]
113+
type Publisher<T: Reloc + Send + Debug + 'static>: Publisher<T, Self>;
114+
#[cfg(not(feature = "iceoryx"))]
106115
type Publisher<T: Reloc + Send + Debug>: Publisher<T, Self>;
107116

108117
/// ProviderInfo types for Configuration data for service producers instances
@@ -123,6 +132,12 @@ pub trait Runtime {
123132
///
124133
/// # Returns
125134
/// Service discovery handle for querying available instances
135+
#[cfg(feature = "iceoryx")]
136+
fn find_service<I: Interface + Debug>(
137+
&self,
138+
instance_specifier: FindServiceSpecifier,
139+
) -> Self::ServiceDiscovery<I>;
140+
#[cfg(not(feature = "iceoryx"))]
126141
fn find_service<I: Interface>(
127142
&self,
128143
instance_specifier: FindServiceSpecifier,

score/mw/com/impl/rust/com-api/com-api-concept/reloc.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
*
1111
* SPDX-License-Identifier: Apache-2.0
1212
********************************************************************************/
13+
#[cfg(feature = "iceoryx")]
14+
use iceoryx2_qnx8::prelude::ZeroCopySend;
1315

16+
#[cfg(feature = "iceoryx")]
17+
pub unsafe trait Reloc: ZeroCopySend {}
18+
#[cfg(not(feature = "iceoryx"))]
1419
pub unsafe trait Reloc {}
1520

1621
unsafe impl Reloc for () {}
@@ -38,8 +43,13 @@ unsafe impl<T: Reloc, const N: usize> Reloc for [T; N] {}
3843
unsafe impl<T: Reloc> Reloc for core::mem::MaybeUninit<T> {}
3944

4045
// Tuples (up to 5 elements)
46+
#[cfg(not(feature = "iceoryx"))]
4147
unsafe impl<T1: Reloc> Reloc for (T1,) {}
48+
#[cfg(not(feature = "iceoryx"))]
4249
unsafe impl<T1: Reloc, T2: Reloc> Reloc for (T1, T2) {}
50+
#[cfg(not(feature = "iceoryx"))]
4351
unsafe impl<T1: Reloc, T2: Reloc, T3: Reloc> Reloc for (T1, T2, T3) {}
52+
#[cfg(not(feature = "iceoryx"))]
4453
unsafe impl<T1: Reloc, T2: Reloc, T3: Reloc, T4: Reloc> Reloc for (T1, T2, T3, T4) {}
54+
#[cfg(not(feature = "iceoryx"))]
4555
unsafe impl<T1: Reloc, T2: Reloc, T3: Reloc, T4: Reloc, T5: Reloc> Reloc for (T1, T2, T3, T4, T5) {}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
load("@rules_rust//rust:defs.bzl", "rust_library")
14+
15+
rust_library(
16+
name = "com-api-runtime-iceoryx",
17+
srcs = ["runtime.rs"],
18+
crate_features = select({
19+
"//score/mw/com/flags:use_iceoryx_flag": ["iceoryx"],
20+
"//conditions:default": [],
21+
}),
22+
visibility = [
23+
"//visibility:public", # platform_only
24+
],
25+
deps = [
26+
"//score/mw/com/impl/rust/com-api/com-api-concept:com-api-concept-iceoryx",
27+
"@crate_index//:futures",
28+
"@crate_index//:iceoryx2_qnx8",
29+
],
30+
)

0 commit comments

Comments
 (0)