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
48 changes: 48 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
BasedOnStyle: Google
AccessModifierOffset: -2
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
# Empty is required in AllowShortFunctionsOnASingleLine over Inline because Inline contradicts with AUTOSAR rule A7-1-7
# Such rule is no longer existing in MISRA C++:2023, once we are fully migrated to MISRA C++:2023, switching to Inline
# could be reconsidered
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakBeforeBraces: Custom
ColumnLimit: 120
DerivePointerAlignment: false
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^(<|")(assert|complex|ctype|errno|fenv|float|inttypes|iso646|limits|locale|math|setjmp|signal|stdalign|stdargh|stdatomic|stdbool|stddef|stdint|stdio|stdlib|stdnoreturn|string|tgmath|threads|time|uchar|wchar|wctype)\.h(>|")$'
Priority: 2
- Regex: '^(<|")(cstdlib|csignal|csetjmp|cstdarg|typeinfo|typeindex|type_traits|bitset|functional|utility|ctime|chrono|cstddef|initializer_list|tuple|any|optional|variant|new|memory|scoped_allocator|memory_resource|climits|cfloat|cstdint|cinttypes|limits|exception|stdexcept|cassert|system_error|cerrno|cctype|cwctype|cstring|cwchar|cuchar|string|string_view|array|vector|deque|list|forward_list|set|map|unordered_set|unordered_map|stack|queue|algorithm|execution|teratorslibrary|iterator|cmath|complex|valarray|random|numeric|ratio|cfenv|iosfwd|ios|istream|ostream|iostream|fstream|sstream|strstream|iomanip|streambuf|cstdio|locale|clocale|codecvt|regex|atomic|thread|mutex|shared_mutex|future|condition_variable|filesystem|ciso646|ccomplex|ctgmath|cstdalign|cstdbool)(>|")$'
Priority: 3
- Regex: '^(<|").*(>|")$'
Priority: 1
IndentWidth: 4
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: true
QualifierAlignment: Left
CommentPragmas: '^.*A2Lfactory:'
---
# Make sure language specific settings are below the generic settings to be compatible to all languages.
Language: Cpp
Standard: c++17
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ tests/**/*.html
tests/**/*.xml

# IDE Code files
.vscode*
*.orig
.venv_docs
MODULE.lock.bazel
Expand Down
17 changes: 16 additions & 1 deletion .vscode/settings.json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I'm not against committing editor config files into repo, but this makes sense if we all use the same editor.

Maybe this file should be on the git ignore list?

Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,20 @@
"rust-analyzer.check.command": "clippy",
"rust-analyzer.rustfmt.overrideCommand": [
"${workspaceFolder}/.vscode/rustfmt.sh"
]
],
"clangd.arguments": [
"--header-insertion=never",
"--compile-commands-dir=${workspaceFolder}/",
"--query-driver=**",
"--clang-tidy",
"--fallback-style=None"
],
"[cpp]": {
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd",
"editor.formatOnSave": true
},
"[c]": {
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd",
"editor.formatOnSave": true
},
}
23 changes: 19 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "flatbuffers", version = "25.9.23")
bazel_dep(name = "download_utils", version = "1.0.1")
bazel_dep(name = "googletest", version = "1.17.0.bcr.1")

# S-CORE process rules
bazel_dep(name = "score_bazel_platforms", version = "0.0.3")
bazel_dep(name = "score_docs_as_code", version = "2.2.0")
bazel_dep(name = "score_docs_as_code", version = "2.3.0")
bazel_dep(name = "score_tooling", version = "1.0.5")
bazel_dep(name = "score_rust_policies", version = "0.0.3")
bazel_dep(name = "score_baselibs", version = "0.2.2")

bazel_dep(name = "score_process", version = "1.4.0", dev_dependency = True)
bazel_dep(name = "score_platform", version = "0.5.1", dev_dependency = True)
Expand All @@ -41,8 +41,6 @@ bazel_dep(name = "score_toolchains_qnx", version = "0.0.6", dev_dependency = Tru
bazel_dep(name = "rust_qnx8_toolchain", version = "1.2.0", dev_dependency = True)
bazel_dep(name = "score_toolchains_rust", version = "0.1.1", dev_dependency = True)

bazel_dep(name = "googletest", version = "1.17.0.bcr.1")

# S-CORE crates
bazel_dep(name = "score_crates", version = "0.0.6")

Expand Down Expand Up @@ -106,3 +104,20 @@ use_repo(toolchains_qnx, "toolchains_qnx_qcc")
use_repo(toolchains_qnx, "toolchains_qnx_ifs")

bazel_dep(name = "score_baselibs_rust", version = "0.0.3")
bazel_dep(name = "score_baselibs", version = "0.2.2")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why moved here?

# git_override(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary?

# module_name = "score_baselibs",
# commit = "9925dba1fd2ca7f2d33300cd2c01e6af022024cd",
# remote = "https://github.com/eclipse-score/baselibs.git",
# )

# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
commit = "0e990032f3c5a866e72615cf67e5ce22186dcb97",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
# Replace the commit hash (above) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main).
# Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
)
50 changes: 49 additions & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ bazel build --cxxopt=-DLC_LOG_SCORE_MW_LOG //...

You can also use the config `--config=x86_64-linux` to build for linux.

## IDE support

### C++

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend markdownlint for Markdown linting.

  • Missing newline after section.
  • Prefer single sentence per line.

Use Visual Studio Code with `clangd`. Make sure you don't have the MS C++ IntelliSense extension installed as this is likely to clash with `clangd`.
Then you need to call `./scripts/generate_cpp_compile_commands.sh` to generate compilation DB for clangd and restart it in VS Code. Indexing shall work.

### Rust


### QNX

#### Envionment Setup
Expand Down
3 changes: 3 additions & 0 deletions scripts/generate_cpp_compile_commands.sh

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing empty line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I've been using the cli tool bazel-compile-commands and works better for me. It's also mentioned in the official bazel docs https://bazel.build/install/ide#c_language_family_c_c_objective-c_objective-c_and_cuda

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

bazel run @hedron_compile_commands//:refresh_all
54 changes: 53 additions & 1 deletion src/health_monitoring_lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_static_library", "rust_test")
load("@score_baselibs//:bazel/unit_tests.bzl", "cc_gtest_unit_test", "cc_unit_test_suites_for_host_and_qnx")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused "cc_unit_test_suites_for_host_and_qnx".


rust_library(
name = "health_monitoring_lib",
Expand All @@ -26,10 +27,61 @@ rust_library(
],
)

rust_static_library(
name = "health_monitoring_lib_ffi",
srcs = glob(["src/**/*.rs"]),
crate_name = "health_monitoring_lib",
proc_macro_deps = [
"@score_baselibs_rust//src/testing_macros:score_testing_macros",
],
visibility = ["//visibility:public"],
deps = [
"@score_baselibs_rust//src/log/score_log",
],
)

rust_test(
name = "tests",
crate = ":health_monitoring_lib",
deps = [
"@score_baselibs_rust//src/log/stdout_logger",
],
)

cc_library(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing load.

name = "health_monitoring_lib_cc",
srcs = [
"cpp/common.cpp",
"cpp/deadline/deadline_monitor.cpp",
"cpp/ffi_helpers.h",
"cpp/health_monitor.cpp",
],
hdrs = [
"cpp/include/score/hm/common.h",
"cpp/include/score/hm/deadline/deadline_monitor.h",
"cpp/include/score/hm/health_monitor.h",
],
copts = [
"-Isrc/health_monitoring_lib/cpp", # private include path

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't they already included in srcs?

],
strip_include_prefix = "cpp/include",
visibility = ["//visibility:public"],
deps = [
":health_monitoring_lib_ffi",
"@score_baselibs//score/result",
],
)

cc_gtest_unit_test(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the expectations are but the score module template is placing all tests in /tests, maybe this should be discussed what convention is used in weekly sync

name = "cpp_tests",
srcs = [
"cpp/tests/health_monitor_test.cpp",
],
linkopts = select({
"@platforms//os:qnx": ["-lsocket"],
"//conditions:default": [],
}),
deps = [
":health_monitoring_lib_cc",
],
)
81 changes: 81 additions & 0 deletions src/health_monitoring_lib/cpp/common.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/********************************************************************************
* Copyright (c) 2026 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
********************************************************************************/
#include <score/hm/common.h>

namespace score::hm::internal
{

DroppableFFIHandle::DroppableFFIHandle(FFIHandle handle, DropFn drop_fn) : handle_(handle), drop_fn_(drop_fn) {}

DroppableFFIHandle::DroppableFFIHandle(DroppableFFIHandle&& other) noexcept
: handle_(other.handle_), drop_fn_(other.drop_fn_)
{
other.handle_ = nullptr;
other.drop_fn_ = nullptr;
}

DroppableFFIHandle& DroppableFFIHandle::operator=(DroppableFFIHandle&& other) noexcept
{
if (this != &other)
{
// Clean up existing resources
if (drop_fn_)
{
drop_fn_(handle_);
}

// Move resources from other
handle_ = other.handle_;
drop_fn_ = other.drop_fn_;

// Nullify other's resources
other.handle_ = nullptr;
other.drop_fn_ = nullptr;
}
return *this;
}

::score::cpp::optional<FFIHandle> DroppableFFIHandle::as_rust_handle() const
{
if (handle_ == nullptr)
{
return ::score::cpp::nullopt;
}

return handle_;
}

::score::cpp::optional<FFIHandle> DroppableFFIHandle::drop_by_rust()
{
if (handle_ == nullptr)
{
return ::score::cpp::nullopt;
}

FFIHandle temp = handle_;
handle_ = nullptr;
drop_fn_ = nullptr;

return temp;
}

DroppableFFIHandle::~DroppableFFIHandle()
{
// Clean up resources associated with the FFI handle
if (drop_fn_)
{
drop_fn_(handle_);
}
}

} // namespace score::hm::internal
Loading
Loading