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
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ coverage --test_env=LLVM_PROFILE_CONTINUOUS_MODE=1
coverage --cxxopt -mllvm
coverage --cxxopt -runtime-counter-relocation

# Clippy linting (enabled by default)
build --aspects=@score_rust_policies//clippy:linters.bzl%clippy_strict
build --output_groups=+rules_lint_human
build:lint --@aspect_rules_lint//lint:fail_on_violation=true

# Clang-tidy configuration
# Run clang-tidy on all C++ targets with: bazel test --config=clang-tidy //...
test:clang-tidy --aspects=//:tools/lint/linters.bzl%clang_tidy_aspect
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# *******************************************************************************
# 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
# *******************************************************************************
name: Bazel Clippy

on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- main
merge_group:
types: [checks_requested]

jobs:
bazel-clippy:
uses: eclipse-score/cicd-workflows/.github/workflows/static-analysis.yml@dcalavrezo_clippy_1
with:
bazel-targets: "//..."
bazel-config: "lint"
3 changes: 2 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ download_file(
urls = ["https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-2da3e7b/clang-format-19_linux-amd64"],
)

bazel_dep(name = "aspect_rules_lint", version = "1.13.0")
bazel_dep(name = "aspect_rules_lint", version = "2.0.0")
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
bazel_dep(name = "google_benchmark", version = "1.9.4")
bazel_dep(name = "rules_rust", version = "0.61.0")
bazel_dep(name = "score_rust_policies", version = "0.0.5", dev_dependency = True)
bazel_dep(name = "score_toolchains_rust", version = "0.2.0", dev_dependency = True)

git_override(
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ bazel test //...
bazel build //score/mw/com:all
```

## Clippy

- Clippy runs by default via `.bazelrc` when building Rust targets (rules_lint aspect).
- Use `bazel build //score/mw/com/...` (or any Rust target pattern) while developing.
- Use `bazel build --config=lint //score/mw/com/...` to enable lint config, including `--@aspect_rules_lint//lint:fail_on_violation=true`.
- The Clippy config comes from `@score_rust_policies//clippy/strict:clippy.toml`.

## Project Structure

```
Expand Down
27 changes: 15 additions & 12 deletions score/mw/com/impl/rust/com-api/com-api-runtime-lola/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,12 @@ impl<'a, T> SampleMaybeUninit<'a, T>
where
T: CommData,
{
fn get_allocatee_data_ptr(&self) -> Option<&mut core::mem::MaybeUninit<T>> {
fn get_allocatee_data_ptr(&mut self) -> Option<&mut core::mem::MaybeUninit<T>> {
//SAFETY: allocatee_ptr is valid which is created using get_allocatee_ptr() and
// it will be again type casted to T type pointer in cpp side so valid to send as void pointer
let data_ptr = unsafe {
generic_bridge_ffi_rs::get_allocatee_data_ptr(
std::ptr::from_ref(self.allocatee_ptr.as_ref()) as *const std::ffi::c_void,
std::ptr::from_mut(&mut (*self.allocatee_ptr.inner)) as *mut std::ffi::c_void,
T::ID,
) as *mut core::mem::MaybeUninit<T>
};
Expand All @@ -378,17 +378,20 @@ where
type SampleMut = SampleMut<'a, T>;

fn write(self, val: T) -> SampleMut<'a, T> {
let data_ptr = self
.get_allocatee_data_ptr()
.expect("Allocatee data pointer is null");

//It is safe to write the value because data_ptr is valid
// and we are writing the value of type T which is same as allocatee_ptr type
data_ptr.write(val);
let mut this = self;
{
let data_ptr = this
.get_allocatee_data_ptr()
.expect("Allocatee data pointer is null");

//It is safe to write the value because data_ptr is valid
// and we are writing the value of type T which is same as allocatee_ptr type
data_ptr.write(val);
}

SampleMut {
skeleton_event: self.skeleton_event,
allocatee_ptr: self.allocatee_ptr,
skeleton_event: this.skeleton_event,
allocatee_ptr: this.allocatee_ptr,
lifetime: PhantomData,
}
}
Expand Down Expand Up @@ -958,7 +961,7 @@ pub struct RuntimeBuilderImpl {

impl Builder<LolaRuntimeImpl> for RuntimeBuilderImpl {
fn build(self) -> com_api_concept::Result<LolaRuntimeImpl> {
proxy_bridge_rs::initialize(self.config_path.as_ref().map(PathBuf::as_path));
proxy_bridge_rs::initialize(self.config_path.as_deref());
Ok(LolaRuntimeImpl {})
}
}
Expand Down
Loading