summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralevitskii <[email protected]>2025-03-07 20:10:03 +0300
committeralevitskii <[email protected]>2025-03-07 20:30:16 +0300
commit7eee4fb7ae7031d07abc0834fbfb528ebb377e12 (patch)
treefaf1641bc8b05c91ca37bcf93cd329477e863379
parentc49489fab07af7d2cf8e7fdcd67e838a54f75b8e (diff)
More generic custom clang-format delivery to wrapper mechanism
Wider custom clang-format delivery to wrapper mechanism commit_hash:a3b4f93090e386cb7a24afa302fd947cca0c090a
-rw-r--r--build/plugins/_dart_fields.py6
-rw-r--r--tools/cpp_style_checker/__main__.py22
2 files changed, 22 insertions, 6 deletions
diff --git a/build/plugins/_dart_fields.py b/build/plugins/_dart_fields.py
index 8d2c471e539..e36c416dcee 100644
--- a/build/plugins/_dart_fields.py
+++ b/build/plugins/_dart_fields.py
@@ -670,7 +670,7 @@ class LintConfigs:
class LintExtraParams:
KEY = 'LINT-EXTRA-PARAMS'
- _CUSTOM_CLANG_FORMAT_BIN_ALLOWED_PATHS = ('ads', 'bigrt', 'grut', 'yabs')
+ _CUSTOM_CLANG_FORMAT_ALLOWED_PATHS = ('ads', 'bigrt', 'grut', 'yabs')
@classmethod
def from_macro_args(cls, unit, flat_args, spec_args):
@@ -680,9 +680,9 @@ class LintExtraParams:
message = 'Wrong EXTRA_PARAMS value: "{}". Values must have format "name=value".'.format(arg)
ymake.report_configure_error(message)
raise DartValueError()
- if 'clang_format_bin' in arg:
+ if 'custom_clang_format' in arg:
upath = unit.path()[3:]
- if not upath.startswith(cls._CUSTOM_CLANG_FORMAT_BIN_ALLOWED_PATHS):
+ if not upath.startswith(cls._CUSTOM_CLANG_FORMAT_ALLOWED_PATHS):
message = f'Custom clang-format is not allowed in upath: {upath}'
ymake.report_configure_error(message)
raise DartValueError()
diff --git a/tools/cpp_style_checker/__main__.py b/tools/cpp_style_checker/__main__.py
index 089d9fa0791..6d5e5fe8bbd 100644
--- a/tools/cpp_style_checker/__main__.py
+++ b/tools/cpp_style_checker/__main__.py
@@ -4,6 +4,7 @@ import os
import subprocess
import time
import yaml
+from pathlib import PurePath
from build.plugins.lib.test_const import CLANG_FORMAT_RESOURCE, CLANG_FORMAT_15_RESOURCE
from library.python.testing.custom_linter_util import linter_params, reporter
@@ -13,9 +14,24 @@ from library.python.testing.style import rules
def main():
params = linter_params.get_params()
- if 'clang_format_bin' in params.extra_params:
- # custom clang-format
- clang_format_binary = params.depends[params.extra_params['clang_format_bin']]
+ if 'custom_clang_format' in params.extra_params:
+ dep_result = next(
+ (
+ PurePath(params.depends[dep])
+ for dep in params.depends
+ if str(PurePath(dep).parent) == params.extra_params['custom_clang_format']
+ ),
+ None,
+ )
+ if dep_result is None:
+ raise Exception('Could not find clang-format binary')
+
+ if 'custom_clang_format_bin' in params.extra_params:
+ # dep_result is not a clang-format binary (package etc)
+ clang_format_binary = str(dep_result.parent / params.extra_params['custom_clang_format_bin'])
+ else:
+ # dep_result is a clang-format binary
+ clang_format_binary = str(dep_result)
elif 'use_clang_format_15' in params.extra_params:
clang_format_binary = os.path.join(params.global_resources[CLANG_FORMAT_15_RESOURCE], 'clang-format-15')
else: