Skip to content
Draft
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
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ bazel_dep(name = "score_crates", version = "0.0.4", repo_name = "crate_index")
# Temporary: Use latest GitHub main with regenerated BUILD file including paste and arrayvec
git_override(
module_name = "score_crates",
commit = "636a5add5ffd53177fd0fdf70b672043ac2664c4",
commit = "dcbc6a4d36c9293549397893650c3a7068b0682d",
remote = "https://github.com/eclipse-score/score-crates.git",
)

Expand Down
4 changes: 4 additions & 0 deletions score/mw/com/example/com-api-example/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test")
rust_binary(
name = "com-api-example",
srcs = ["basic-consumer-producer.rs"],
crate_features = select({
"//score/mw/com/flags:use_iceoryx_flag": ["iceoryx"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
"//score/mw/com/example/com-api-example/com-api-gen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ fn run_with_runtime<R: Runtime>(name: &str, runtime: &R) {
println!("=== {} runtime completed ===\n", name);
}

#[cfg(feature = "iceoryx")]
fn main() {
let iceoryx_runtime_builder = IceoryxRuntimeBuilderImpl::new();
let iceoryx_runtime = Builder::<IceoryxRuntimeImpl>::build(iceoryx_runtime_builder).unwrap();
run_with_runtime("Iceoryx", &iceoryx_runtime);
}

#[cfg(not(feature = "iceoryx"))]
fn main() {
let mock_runtime_builder = MockRuntimeBuilderImpl::new();
let mock_runtime = Builder::<MockRuntimeImpl>::build(mock_runtime_builder).unwrap();
Expand Down
12 changes: 9 additions & 3 deletions score/mw/com/example/com-api-example/com-api-gen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ rust_library(
name = "com-api-gen",
srcs = ["com_api_gen.rs"],
crate_name = "com_api_gen",
crate_features = select({
"//score/mw/com/flags:use_iceoryx_flag": ["iceoryx"],
"//conditions:default": [],
}),
visibility = [
"//visibility:public", # platform_only
],
deps = [
"//score/mw/com/impl/rust/com-api/com-api",
],
deps = ["//score/mw/com/impl/rust/com-api/com-api",] +
select({
"//score/mw/com/flags:use_iceoryx_flag": ["@crate_index//:iceoryx2_qnx8",],
"//conditions:default": [],
}),
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#[cfg(feature = "iceoryx")]
use iceoryx2_qnx8::prelude::ZeroCopySend;

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

#[derive(Debug)]
pub struct Exhaust {}
unsafe impl Reloc for Exhaust {}
#[cfg(feature = "iceoryx")]
unsafe impl ZeroCopySend for Exhaust {}

#[derive(Debug)]
pub struct VehicleInterface {}

/// Generic
Expand Down
15 changes: 14 additions & 1 deletion score/mw/com/flags/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@bazel_skylib//rules:common_settings.bzl", "string_flag", "bool_flag")

string_flag(
name = "tracing_library",
Expand All @@ -37,3 +37,16 @@ config_setting(
"//score/mw/com/impl/tracing:__subpackages__",
],
)

bool_flag(
name = "use_iceoryx",
build_setting_default = False,
)

config_setting(
name = "use_iceoryx_flag",
flag_values = {
":use_iceoryx": "True",
},
visibility = ["//visibility:public"],
)
16 changes: 15 additions & 1 deletion score/mw/com/impl/rust/com-api/com-api-concept/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,21 @@ rust_library(
visibility = [
"//visibility:public", # platform_only
],
deps = [],
)

rust_library(
name = "com-api-concept-iceoryx",
srcs = [
"com_api_concept.rs",
"reloc.rs",
],
crate_features = ["iceoryx"],
crate_name = "com_api_concept",
crate_root = "com_api_concept.rs",
visibility = [
"//visibility:public", # platform_only
],
deps = ["@crate_index//:iceoryx2_qnx8"],
)

rust_test(
Expand Down
15 changes: 15 additions & 0 deletions score/mw/com/impl/rust/com-api/com-api-concept/com_api_concept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,15 @@ pub trait Builder<Output> {
/// the implementation.
pub trait Runtime {
/// ServiceDiscovery<I> types for Discovers available service instances of a specific interface
#[cfg(feature = "iceoryx")]
type ServiceDiscovery<I: Interface + Debug>: ServiceDiscovery<I, Self>;
#[cfg(not(feature = "iceoryx"))]
type ServiceDiscovery<I: Interface>: ServiceDiscovery<I, Self>;

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

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

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

/// ProviderInfo types for Configuration data for service producers instances
Expand All @@ -123,6 +132,12 @@ pub trait Runtime {
///
/// # Returns
/// Service discovery handle for querying available instances
#[cfg(feature = "iceoryx")]
fn find_service<I: Interface + Debug>(
&self,
instance_specifier: FindServiceSpecifier,
) -> Self::ServiceDiscovery<I>;
#[cfg(not(feature = "iceoryx"))]
fn find_service<I: Interface>(
&self,
instance_specifier: FindServiceSpecifier,
Expand Down
10 changes: 10 additions & 0 deletions score/mw/com/impl/rust/com-api/com-api-concept/reloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#[cfg(feature = "iceoryx")]
use iceoryx2_qnx8::prelude::ZeroCopySend;

#[cfg(feature = "iceoryx")]
pub unsafe trait Reloc: ZeroCopySend {}
#[cfg(not(feature = "iceoryx"))]
pub unsafe trait Reloc {}

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

// Tuples (up to 5 elements)
#[cfg(not(feature = "iceoryx"))]
unsafe impl<T1: Reloc> Reloc for (T1,) {}
#[cfg(not(feature = "iceoryx"))]
unsafe impl<T1: Reloc, T2: Reloc> Reloc for (T1, T2) {}
#[cfg(not(feature = "iceoryx"))]
unsafe impl<T1: Reloc, T2: Reloc, T3: Reloc> Reloc for (T1, T2, T3) {}
#[cfg(not(feature = "iceoryx"))]
unsafe impl<T1: Reloc, T2: Reloc, T3: Reloc, T4: Reloc> Reloc for (T1, T2, T3, T4) {}
#[cfg(not(feature = "iceoryx"))]
unsafe impl<T1: Reloc, T2: Reloc, T3: Reloc, T4: Reloc, T5: Reloc> Reloc for (T1, T2, T3, T4, T5) {}
30 changes: 30 additions & 0 deletions score/mw/com/impl/rust/com-api/com-api-runtime-iceoryx/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_rust//rust:defs.bzl", "rust_library")

rust_library(
name = "com-api-runtime-iceoryx",
srcs = ["runtime.rs"],
crate_features = select({
"//score/mw/com/flags:use_iceoryx_flag": ["iceoryx"],
"//conditions:default": [],
}),
visibility = [
"//visibility:public", # platform_only
],
deps = [
"//score/mw/com/impl/rust/com-api/com-api-concept:com-api-concept-iceoryx",
"@crate_index//:futures",
"@crate_index//:iceoryx2_qnx8",
],
)
Loading