From b43e789f520db780dbc36d7101e23db1d6177bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20B=C3=A4uerle?= Date: Fri, 6 Mar 2026 15:30:49 +0100 Subject: [PATCH 1/5] MODULE.bazel: add version override for python 3.8 bazel-tools-cc and bazel-tools-python currently still require python 3.8, so in order to allow using the latest release of those two bazel modules, add a version override to bring back support for python 3.8 which rules_python dropped with version 1.8.0. --- MODULE.bazel | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MODULE.bazel b/MODULE.bazel index 94d7af33..4bd8e6d7 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -79,6 +79,14 @@ bazel_dep(name = "rules_python", version = "1.8.3") PYTHON_VERSION = "3.12" python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True) +python.single_version_override( + python_version = "3.8.20", + sha256 = { + "aarch64-unknown-linux-gnu": "9d8798f9e79e0fc0f36fcb95bfa28a1023407d51a8ea5944b4da711f1f75f1ed", + "x86_64-unknown-linux-gnu": "285e141c36f88b2e9357654c5f77d1f8fb29cc25132698fe35bb30d787f38e87", + }, + urls = ["https://github.com/astral-sh/python-build-standalone/releases/download/20241002/cpython-{python_version}+20241002-{platform}-{build}.tar.gz"], +) python.toolchain( #configure_coverage_tool = True, is_default = True, From 507467df628c830781e91ce6f91901cb6d3c6d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20B=C3=A4uerle?= Date: Tue, 3 Feb 2026 15:30:05 +0100 Subject: [PATCH 2/5] Add clang format config and rules from bazel-tools-cc repo However, the checks are currently failing due to the strict need of allowing reversible transformations back to the bmw-internal repository. --- .bazelrc | 5 +++++ .clang-format | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ BUILD | 14 +++++++++++++- MODULE.bazel | 2 ++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 .clang-format diff --git a/.bazelrc b/.bazelrc index d1e338ba..483d1ba7 100644 --- a/.bazelrc +++ b/.bazelrc @@ -78,3 +78,8 @@ test:asan_ubsan_lsan --copt -g3 test:asan_ubsan_lsan --platform_suffix=asan_ubsan_lsan test:asan_ubsan_lsan --test_env=ASAN_OPTIONS="exitcode=55 allow_addr2line=1 verbosity=1 coverage=1 check_initialization_order=1 detect_stack_use_after_return=1 print_stats=1 halt_on_error=1 allocator_may_return_null=1 detect_leaks=1" test:asan_ubsan_lsan --test_env=UBSAN_OPTIONS="exitcode=55 allow_addr2line=1 verbosity=1 coverage=1 print_stacktrace=1 halt_on_error=1" + +build:clang_format --config=_bl_stub +build:clang_format --output_groups=clang_format_output +build:clang_format --aspects=@score_bazel_tools_cc//quality:defs.bzl%clang_format_aspect +build:clang_format --@score_bazel_tools_cc//quality:clang_format_config=//:clang_format_config diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..92df3942 --- /dev/null +++ b/.clang-format @@ -0,0 +1,48 @@ +# For changes please present first the motivation in the TAL round +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 +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/BUILD b/BUILD index 09ad0cb1..9a67b913 100644 --- a/BUILD +++ b/BUILD @@ -11,6 +11,7 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* +load("@score_bazel_tools_cc//quality:defs.bzl", "clang_format_config") load("@score_docs_as_code//:docs.bzl", "docs") load("@score_tooling//:defs.bzl", "copyright_checker", "use_format_targets") load(":qemu.bzl", "qemu_aarch64") @@ -38,6 +39,17 @@ copyright_checker( visibility = ["//visibility:public"], ) +qemu_aarch64() + use_format_targets() -qemu_aarch64() +clang_format_config( + name = "clang_format_config", + config_file = "//:.clang-format", + target_types = [ + "cc_binary", + "cc_library", + "cc_test", + ], + visibility = ["//visibility:public"], +) diff --git a/MODULE.bazel b/MODULE.bazel index 4bd8e6d7..9a614057 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -97,6 +97,8 @@ bazel_dep(name = "aspect_rules_py", version = "1.6.3", 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 = "score_bazel_tools_cc", version = "0.1.0") + deb = use_repo_rule("@download_utils//download/deb:defs.bzl", "download_deb") deb( From bcca997260ef8bbcd721bc6d16509b9fd9d478b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20B=C3=A4uerle?= Date: Tue, 3 Feb 2026 15:49:02 +0100 Subject: [PATCH 3/5] Add workflow for clang-format And let it pass on failure, for now. --- .github/workflows/format.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index ebe7cb6a..e0e28bea 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -22,3 +22,18 @@ on: jobs: formatting-check: uses: eclipse-score/cicd-workflows/.github/workflows/format.yml@main + clang-format: + 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 with clang-format + run: | + bazel build --config clang_format -- //... || true From 8dd4d70a2f79e389a18ea66d533636bebd591beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20B=C3=A4uerle?= Date: Thu, 5 Feb 2026 12:08:58 +0100 Subject: [PATCH 4/5] Add minimal clang-tidy config and targets using bazel-tools-cc --- .bazelrc | 9 +++++++ .clang-tidy-minimal | 60 +++++++++++++++++++++++++++++++++++++++++++++ BUILD | 30 ++++++++++++++++++++++- MODULE.bazel | 10 ++++++++ 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 .clang-tidy-minimal diff --git a/.bazelrc b/.bazelrc index 483d1ba7..05172656 100644 --- a/.bazelrc +++ b/.bazelrc @@ -83,3 +83,12 @@ build:clang_format --config=_bl_stub build:clang_format --output_groups=clang_format_output build:clang_format --aspects=@score_bazel_tools_cc//quality:defs.bzl%clang_format_aspect build:clang_format --@score_bazel_tools_cc//quality:clang_format_config=//:clang_format_config + +build:clang_tidy --config=_bl_stub +build:clang_tidy --@score_bazel_tools_cc//quality:quality_clang_tidy_config=//:clang_tidy_config +build:clang_tidy --aspects=@score_bazel_tools_cc//quality:defs.bzl%quality_clang_tidy_aspect +build:clang_tidy --build_tag_filters="-tidy_suite" +build:clang_tidy --force_pic +build:clang_tidy --incompatible_enable_cc_toolchain_resolution +build:clang_tidy --output_groups=clang_tidy_output +build:clang_tidy --verbose_failures diff --git a/.clang-tidy-minimal b/.clang-tidy-minimal new file mode 100644 index 00000000..038a27c4 --- /dev/null +++ b/.clang-tidy-minimal @@ -0,0 +1,60 @@ +--- +Checks: > + -*, + misc-confusable-identifiers, + misc-misleading-bidirectional, + misc-misleading-identifier, + misc-uniqueptr-reset-release, + misc-unused-alias-decls, + readability-avoid-nested-conditional-operator, + readability-const-return-type, + readability-delete-null-pointer, + readability-enum-initial-value, + readability-identifier-naming, + readability-misleading-indentation, + readability-redundant-string-init, + readability-reference-to-constructed-temporary, + readability-simplify-subscript-expr, + readability-string-compare, + readability-uniqueptr-delete-release, + +CheckOptions: + - key: misc-uniqueptr-reset-release.IncludeStyle + value: "llvm" + + - key: readability-avoid-return-with-void-value.StrictMode + value: true + + - key: readability-enum-initial-value.AllowExplicitZeroFirstInitialValue + value: true + - key: readability-enum-initial-value.AllowExplicitSequentialInitialValues + value: true + + - key: readability-identifier-naming.MacroDefinitionCase + value: UPPER_CASE + - key: readability-identifier-naming.NamespaceCase + value: lower_case + + - key: readability-simplify-subscript-expr.Types + value: > + ::score::futurecpp::basic_string_view; + ::score::futurecpp::pmr::basic_string; + ::score::futurecpp::pmr::vector; + ::score::futurecpp::span; + ::score::safecpp::basic_zstring_view; + ::std::array; + ::std::basic_string_view; + ::std::basic_string; + ::std::vector; + ::std::span + + - key: readability-string-compare.StringLikeClasses + value: > + ::score::futurecpp::basic_string_view; + ::score::futurecpp::pmr::basic_string; + ::score::safecpp::basic_zstring_view; + ::std::basic_string_view; + ::std::basic_string + + - key: readability-uniqueptr-delete-release.PreferResetCall + value: true diff --git a/BUILD b/BUILD index 9a67b913..411d7b4d 100644 --- a/BUILD +++ b/BUILD @@ -11,7 +11,7 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -load("@score_bazel_tools_cc//quality:defs.bzl", "clang_format_config") +load("@score_bazel_tools_cc//quality:defs.bzl", "clang_format_config", "quality_clang_tidy_config") load("@score_docs_as_code//:docs.bzl", "docs") load("@score_tooling//:defs.bzl", "copyright_checker", "use_format_targets") load(":qemu.bzl", "qemu_aarch64") @@ -53,3 +53,31 @@ clang_format_config( ], visibility = ["//visibility:public"], ) + +filegroup( + name = "clang_tidy_config_files", + srcs = [ + ".clang-tidy-minimal", + ], + visibility = ["//visibility:public"], +) + +quality_clang_tidy_config( + name = "clang_tidy_config", + additional_flags = [], + clang_tidy_binary = "@llvm_toolchain//:clang-tidy", + default_feature = "strict", + dependency_attributes = [ + "deps", + "srcs", + ], + excludes = [], + feature_mapping = { + "//:.clang-tidy-minimal": "strict", + }, + target_types = [ + "cc_library", + ], + unsupported_flags = [], + visibility = ["//visibility:public"], +) diff --git a/MODULE.bazel b/MODULE.bazel index 9a614057..a278ee1d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -98,6 +98,16 @@ bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2", dev_dependency = Tr bazel_dep(name = "aspect_rules_lint", version = "1.5.3", dev_dependency = True) bazel_dep(name = "score_bazel_tools_cc", version = "0.1.0") +bazel_dep(name = "toolchains_llvm", version = "1.4.0") + +llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") +llvm.toolchain( + llvm_version = "19.1.1", + stdlib = {"linux-x86_64": "stdc++"}, +) +use_repo(llvm, "llvm_toolchain") + +register_toolchains("@llvm_toolchain//:all") deb = use_repo_rule("@download_utils//download/deb:defs.bzl", "download_deb") From fcd61a420995dcb34cec2be0b16e72ac708f1cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20B=C3=A4uerle?= Date: Wed, 11 Mar 2026 09:02:30 +0100 Subject: [PATCH 5/5] Add linter workflow Which currently runs clang-tidy. Scores' cicd-workflows also contains a static-analysis workflow, this one, however, seems to be tailored towards rust. --- .github/workflows/lint.yml | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..95811f81 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,39 @@ +# ******************************************************************************* +# 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: Linter checks +permissions: + contents: read +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - main + merge_group: + types: [checks_requested] +jobs: + clang-tidy: + 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 with clang-tidy + run: | + bazel build --config clang_tidy -- //...