diff --git a/.bazelrc b/.bazelrc index 51cac5a..d330956 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,9 +1,58 @@ -build --java_language_version=17 -build --tool_java_language_version=17 -build --java_runtime_version=remotejdk_17 -build --tool_java_runtime_version=remotejdk_17 +# ******************************************************************************* +# 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 +# ******************************************************************************* test --test_output=errors common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ common --registry=https://bcr.bazel.build +common --@score_logging//score/mw/log/flags:KRemote_Logging=False + +build --@score_baselibs//score/json:base_library=nlohmann +build --credential_helper="*.qnx.com=%workspace%/.github/tools/qnx_credential_helper.py" + +# ------------------------------------------------------------------------------- +# Shared configuration for simple test execution +# ------------------------------------------------------------------------------- +build:time_shared --incompatible_strict_action_env +build:time_shared --sandbox_writable_path=/var/tmp +build:time_shared --host_platform=@score_bazel_platforms//:x86_64-linux + +# ------------------------------------------------------------------------------- +# Config dedicated to host platform CPU:x86_64 and OS:Linux +# ------------------------------------------------------------------------------- +build:time-x86_64-linux --config=time_shared +build:time-x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix +build:time-x86_64-linux --extra_toolchains=@score_gcc_x86_64_toolchain//:x86_64-linux-gcc_12.2.0-posix +# ------------------------------------------------------------------------------- +# Config dedicated to target platform CPU:x86_64 and OS:QNX +# ------------------------------------------------------------------------------- +build:time-x86_64-qnx --config=time_shared +build:time-x86_64-qnx --platforms=@score_bazel_platforms//:x86_64-qnx-sdp_8.0.0-posix +build:time-x86_64-qnx --extra_toolchains=@score_qcc_x86_64_toolchain//:x86_64-qnx-sdp_8.0.0-posix + +# ------------------------------------------------------------------------------- +# Config dedicated to target platform CPU:arm64 and OS:QNX +# ------------------------------------------------------------------------------- +build:time-arm64-qnx --config=time_shared +build:time-arm64-qnx --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix +build:time-arm64-qnx --extra_toolchains=@score_qcc_aarch64_toolchain//:aarch64-qnx-sdp_8.0.0-posix + +# ------------------------------------------------------------------------------- +# Import local user workspace file, if exists +# ------------------------------------------------------------------------------- +try-import %workspace%/user.bazelrc + +# Coverage configuration for C++ +coverage --features=coverage +coverage --combined_report=lcov +coverage --cache_test_results=no diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..900517a --- /dev/null +++ b/.clang-format @@ -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 diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml new file mode 100644 index 0000000..8860ed3 --- /dev/null +++ b/.github/workflows/build_linux.yml @@ -0,0 +1,38 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* +name: Bazel Build (Linux) +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - main + merge_group: + types: [checks_requested] + workflow_call: +jobs: + linux-build: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.18.0 + with: + bazelisk-cache: true + disk-cache: ${{ github.job }} + repository-cache: true + cache-save: ${{ github.event_name == 'push' }} + - name: Bazel Build + run: | + bazel build --config time-x86_64-linux -- //score/... //examples/... diff --git a/.github/workflows/build_qnx8.yml b/.github/workflows/build_qnx8.yml new file mode 100644 index 0000000..74f3b62 --- /dev/null +++ b/.github/workflows/build_qnx8.yml @@ -0,0 +1,41 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +name: Bazel Build (QNX8) +on: + pull_request_target: + types: [opened, reopened, synchronize] + merge_group: + types: [checks_requested] + push: + branches: + - main +jobs: + qnx-build: + uses: eclipse-score/cicd-workflows/.github/workflows/qnx-build.yml@main + permissions: + contents: read + pull-requests: read + strategy: + matrix: + config: ['time-x86_64-qnx', 'time-arm64-qnx'] + with: + bazel-target: '//score/... //examples/...' + bazel-config: ${{ matrix.config }} + credential-helper: 'tools/qnx_credential_helper.py' + environment-name: 'workflow-approval' + bazel-disk-cache: ${{ github.workflow }}-${{ github.job }}-${{ matrix.config }} + secrets: + score-qnx-license: ${{ secrets.SCORE_QNX_LICENSE }} + score-qnx-user: ${{ secrets.SCORE_QNX_USER }} + score-qnx-password: ${{ secrets.SCORE_QNX_PASSWORD }} diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml new file mode 100644 index 0000000..3c7a949 --- /dev/null +++ b/.github/workflows/code_coverage.yml @@ -0,0 +1,34 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* +name: Code Coverage (>85%) +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - main + merge_group: + types: [checks_requested] + release: + types: [created] + +jobs: + code-coverage: + uses: eclipse-score/cicd-workflows/.github/workflows/cpp-coverage.yml@main + with: + bazel-target: "//score/..." + bazel-config: "time-x86_64-linux" + extra-bazel-flags: "--test_output=errors --nocache_test_results" + artifact-name-suffix: "_cpp" + retention-days: 10 + min-coverage: 85 diff --git a/.github/workflows/comp_tests.yml b/.github/workflows/comp_tests.yml new file mode 100644 index 0000000..772c44c --- /dev/null +++ b/.github/workflows/comp_tests.yml @@ -0,0 +1,42 @@ +# ******************************************************************************* +# 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: Component Tests execution (Linux) + +permissions: + contents: write + pages: write + pull-requests: write + id-token: write + +on: + pull_request: + types: [opened, reopened, synchronize] # Allows forks to trigger the docs build + push: + branches: + - main + merge_group: + types: [checks_requested] + release: + types: [created] + +jobs: + run-comp-tests: + uses: eclipse-score/cicd-workflows/.github/workflows/tests.yml@main + permissions: + contents: read + pull-requests: read + with: + bazel-target: 'test --config=time-x86_64-linux //score/...' + upload-name: 'bazel-testlogs' + packages: 'fakechroot' diff --git a/.github/workflows/copyright.yml b/.github/workflows/copyright.yml index 08ef376..f8cf49d 100644 --- a/.github/workflows/copyright.yml +++ b/.github/workflows/copyright.yml @@ -20,5 +20,3 @@ on: jobs: copyright-check: uses: eclipse-score/cicd-workflows/.github/workflows/copyright.yml@main - with: - bazel-target: "run //:copyright.check" diff --git a/.github/workflows/docs-cleanup.yml b/.github/workflows/docs-cleanup.yml index cfa4ae2..b72c72b 100644 --- a/.github/workflows/docs-cleanup.yml +++ b/.github/workflows/docs-cleanup.yml @@ -1,5 +1,5 @@ # ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation +# Copyright (c) 2026 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 24bd399..a9cf6a8 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,5 +1,5 @@ # ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation +# Copyright (c) 2026 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -29,14 +29,22 @@ on: types: [checks_requested] jobs: - build-docs: + docs-verify: + uses: eclipse-score/cicd-workflows/.github/workflows/docs-verify.yml@main + permissions: + pull-requests: write + contents: read + with: + bazel-docs-verify-target: "//:docs_check" + + docs-build: + needs: docs-verify uses: eclipse-score/cicd-workflows/.github/workflows/docs.yml@main permissions: contents: write pages: write pull-requests: write id-token: write - with: # the bazel-target depends on your repo specific docs_targets configuration (e.g. "suffix") bazel-target: "//:docs -- --github_user=${{ github.repository_owner }} --github_repo=${{ github.event.repository.name }}" diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 620d697..4977c5a 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -12,15 +12,11 @@ # ******************************************************************************* name: Formatting checks - on: pull_request: types: [opened, reopened, synchronize] merge_group: types: [checks_requested] - jobs: formatting-check: uses: eclipse-score/cicd-workflows/.github/workflows/format.yml@main - with: - bazel-target: "test //:format.check" # optional, this is the default diff --git a/.github/workflows/license_check.yml b/.github/workflows/license_check.yml index aba7f99..2cf115b 100644 --- a/.github/workflows/license_check.yml +++ b/.github/workflows/license_check.yml @@ -1,5 +1,5 @@ # ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation +# Copyright (c) 2026 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -11,7 +11,7 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -name: License check preparation +name: License check on: pull_request_target: types: [opened, reopened, synchronize] diff --git a/BUILD b/BUILD index 473b5d5..005c8a2 100644 --- a/BUILD +++ b/BUILD @@ -1,5 +1,5 @@ # ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation +# Copyright (c) 2026 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -20,11 +20,21 @@ setup_starpls( visibility = ["//visibility:public"], ) +docs( + data = [ + "@score_process//:needs_json", + ], + source_dir = "docs", +) + copyright_checker( name = "copyright", srcs = [ - "src", - "tests", + ".github", + "docs", + "examples", + "score", + "tools", "//:BUILD", "//:MODULE.bazel", ], @@ -42,7 +52,3 @@ dash_license_checker( # Add target for formatting checks use_format_targets() - -docs( - source_dir = "docs", -) diff --git a/MODULE.bazel b/MODULE.bazel index 1ec606d..ff91eeb 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,5 +1,5 @@ # ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation +# Copyright (c) 2026 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -11,47 +11,91 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* module( - name = "cpp_rust_template_repository", - version = "1.0", + name = "score_time", + version = "0.0.0", + compatibility_level = 0, ) -bazel_dep(name = "rules_python", version = "1.4.1") +## Configure the C++ toolchain -PYTHON_VERSION = "3.12" +bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.2.2", dev_dependency = True) -python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.toolchain( - is_default = True, - python_version = PYTHON_VERSION, +gcc = use_extension("@score_bazel_cpp_toolchains//extensions:gcc.bzl", "gcc", dev_dependency = True) +gcc.toolchain( + name = "score_gcc_x86_64_toolchain", + target_cpu = "x86_64", + target_os = "linux", + use_default_package = True, + version = "12.2.0", +) +gcc.toolchain( + name = "score_gcc_aarch64_toolchain", + target_cpu = "aarch64", + target_os = "linux", + use_default_package = True, + version = "12.2.0", +) +gcc.toolchain( + name = "score_qcc_x86_64_toolchain", + sdp_version = "8.0.0", + target_cpu = "x86_64", + target_os = "qnx", + use_default_package = True, + version = "12.2.0", +) +gcc.toolchain( + name = "score_qcc_aarch64_toolchain", + sdp_version = "8.0.0", + target_cpu = "aarch64", + target_os = "qnx", + use_default_package = True, + version = "12.2.0", +) +use_repo( + gcc, + "score_gcc_aarch64_toolchain", + "score_gcc_x86_64_toolchain", + "score_qcc_aarch64_toolchain", + "score_qcc_x86_64_toolchain", ) -use_repo(python) -# Add GoogleTest dependency -bazel_dep(name = "googletest", version = "1.17.0") +## Custom Module Loading -# Rust rules for Bazel -bazel_dep(name = "rules_rust", version = "0.63.0") +### Public modules -# C/C++ rules for Bazel -bazel_dep(name = "rules_cc", version = "0.2.1") +bazel_dep(name = "platforms", version = "1.0.0") +bazel_dep(name = "score_bazel_platforms", version = "0.0.4") +bazel_dep(name = "score_logging", version = "0.1.0") -# LLVM Toolchains Rules - host configuration -bazel_dep(name = "toolchains_llvm", version = "1.4.0") +### Modules that are used internally within the repository but not exposed as part of the public API -llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") -llvm.toolchain( - cxx_standard = {"": "c++17"}, - llvm_version = "19.1.0", +bazel_dep(name = "score_docs_as_code", version = "3.0.0", dev_dependency = True) +bazel_dep(name = "score_process", version = "1.4.3", dev_dependency = True) +bazel_dep(name = "score_tooling", version = "1.1.0", dev_dependency = True) +bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2", dev_dependency = True) +bazel_dep(name = "aspect_rules_lint", version = "1.5.3", dev_dependency = True) +bazel_dep(name = "googletest", version = "1.17.0.bcr.2", dev_dependency = True) +bazel_dep(name = "google_benchmark", version = "1.9.5", dev_dependency = True) +bazel_dep(name = "score_baselibs", version = "0.2.4", dev_dependency = True) +bazel_dep(name = "score_lifecycle_health", version = "0.1.0", dev_dependency = True) + +# TODO: remove once inherited properly from `score_logging`. +bazel_dep(name = "trlc", version = "0.0.0", dev_dependency = True) +git_override( + module_name = "trlc", + commit = "650b51a47264a4f232b3341f473527710fc32669", # trlc-2.0.2 release + remote = "https://github.com/bmw-software-engineering/trlc.git", ) -use_repo(llvm, "llvm_toolchain") -use_repo(llvm, "llvm_toolchain_llvm") -register_toolchains("@llvm_toolchain//:all") +## Configure the python toolchain + +bazel_dep(name = "rules_python", version = "1.8.3") -# tooling -bazel_dep(name = "score_tooling", version = "1.0.1") -bazel_dep(name = "aspect_rules_lint", version = "1.5.3") -bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2") +PYTHON_VERSION = "3.12" -#docs-as-code -bazel_dep(name = "score_docs_as_code", version = "1.1.0") +python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True) +python.toolchain( + #configure_coverage_tool = True, + is_default = True, + python_version = PYTHON_VERSION, +) diff --git a/docs/conf.py b/docs/conf.py index cf13475..c44df04 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,9 +20,9 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = "Module Template Project" -project_url = "https://eclipse-score.github.io/module_template/" -project_prefix = "MODULE_TEMPLATE_" +project = "S-CORE Time" +project_url = "https://eclipse-score.github.io/time" +project_prefix = "TIME_" author = "S-CORE" version = "0.1" diff --git a/docs/index.rst b/docs/index.rst index f8e53da..14bf088 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,10 +12,10 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -Module Template Documentation -============================= +TimeDaemon Documentation +======================== -This documentation describes the structure, usage and configuration of the Bazel-based C++/Rust module template. +This documentation describes the **TimeDaemon** and the **score::time** module. .. contents:: Table of Contents :depth: 2 @@ -24,20 +24,25 @@ This documentation describes the structure, usage and configuration of the Bazel Overview -------- -This repository provides a standardized setup for projects using **C++** or **Rust** and **Bazel** as a build system. -It integrates best practices for build, test, CI/CD and documentation. +**TimeDaemon** is a non-AUTOSAR adaptive process designed to provide synchronized vehicle time to client applications. +It supports multiple time bases including **in-vehicle synchronized time** (PTP - Precision Time Protocol) and +**external synchronized time** (absolute time base). The daemon retrieves time information from the respective time sources, +verifies and validates the timepoints, and distributes this time information across multiple clients through efficient IPC mechanisms. -Requirements ------------- +The main responsibilities of TimeDaemon include: -.. stkh_req:: Example Functional Requirement - :id: stkh_req__docgen_enabled__example - :status: valid - :safety: QM - :security: YES - :reqtype: Functional - :rationale: Ensure documentation builds are possible for all modules +- **Providing current Vehicle time** to different applications +- **Setting synchronization qualifiers** (e.g., Synchronized, Timeout, etc.) +- **Providing diagnostic information** for system monitoring +- **Supporting additional verification mechanisms** such as QualifiedVehicleTime (QVT) for safety-critical applications +For a detailed concept and architectural design, please refer to the :doc:`TimeDaemon Concept Documentation