diff options
| -rw-r--r-- | build/plugins/_dart_fields.py | 36 | ||||
| -rw-r--r-- | build/plugins/lib/test_const/__init__.py | 1 | ||||
| -rw-r--r-- | build/plugins/ytest.py | 1 | ||||
| -rw-r--r-- | build/ymake.core.conf | 8 |
4 files changed, 35 insertions, 11 deletions
diff --git a/build/plugins/_dart_fields.py b/build/plugins/_dart_fields.py index aa1b5d9a161..eb5a0baa759 100644 --- a/build/plugins/_dart_fields.py +++ b/build/plugins/_dart_fields.py @@ -611,15 +611,37 @@ class LintConfigs: def cpp_configs(cls, unit, flat_args, spec_args): custom_config = spec_args.get('CUSTOM_CONFIG') if custom_config: + # TODO delete CUSTOM_CONFIG, it's used only by arc config = custom_config[0] assert_file_exists(unit, config) - else: - # file with default configs - config = spec_args.get('CONFIGS')[0] - assert_file_exists(unit, config) - name = spec_args['NAME'][0] - config = get_linter_configs(unit, config)[name] - assert_file_exists(unit, config) + return {cls.KEY: serialize_list([config])} + linter_name = spec_args['NAME'][0] + if config_type := spec_args.get('CONFIG_TYPE'): + config_type = config_type[0] + if config_type not in consts.LINTER_CONFIG_TYPES[linter_name]: + message = "Unknown CPP linter config type: {}. Allowed types: {}".format( + config_type, ', '.join(consts.LINTER_CONFIG_TYPES[linter_name]) + ) + ymake.report_configure_error(message) + raise DartValueError() + if common_configs_dir := unit.get('MODULE_COMMON_CONFIGS_DIR'): + config = os.path.join(common_configs_dir, config_type) + path = unit.resolve(config) + if os.path.exists(path): + config = _common.strip_roots(config) + return {cls.KEY: serialize_list([config])} + message = "File not found: {}".format(path) + ymake.report_configure_error(message) + raise DartValueError() + else: + message = "Config type specifier is only allowed with autoincludes" + ymake.report_configure_error(message) + raise DartValueError() + # default config + config = spec_args.get('CONFIGS')[0] + assert_file_exists(unit, config) + config = get_linter_configs(unit, config)[linter_name] + assert_file_exists(unit, config) return {cls.KEY: serialize_list([config])} diff --git a/build/plugins/lib/test_const/__init__.py b/build/plugins/lib/test_const/__init__.py index 02c3c5313ad..cc2536d6fed 100644 --- a/build/plugins/lib/test_const/__init__.py +++ b/build/plugins/lib/test_const/__init__.py @@ -437,6 +437,7 @@ class ServiceTags(Enum): AnyTag = "ya:anytag" +# Linter names must match `NAME` set in `_ADD_*_LINTER_CHECK` class PythonLinterName(Enum): Black = "black" DummyLinter = "dummy_linter" diff --git a/build/plugins/ytest.py b/build/plugins/ytest.py index 33eeac4403f..dd540baf829 100644 --- a/build/plugins/ytest.py +++ b/build/plugins/ytest.py @@ -1014,6 +1014,7 @@ def on_add_cpp_linter_check(fields, unit, *args): "GLOBAL_RESOURCES": unlimited, "FILE_PROCESSING_TIME": 1, "EXTRA_PARAMS": unlimited, + "CONFIG_TYPE": 1, } _, spec_args = _common.sort_by_keywords(keywords, args) diff --git a/build/ymake.core.conf b/build/ymake.core.conf index 976d5debd3c..a2fa9450cca 100644 --- a/build/ymake.core.conf +++ b/build/ymake.core.conf @@ -5854,7 +5854,7 @@ macro _STYLE_CPP(CONFIG...) { } # tag:internal -### @usage: _ADD_CPP_LINTER_CHECK(NAME name LINTER linter [DEPENDS deps] CONFIGS configs_file [GLOBAL_RESOURCES gr] [FILE_PROCESSING_TIME fpt] [EXTRA_PARAMS params] [CUSTOM_CONFIG cc]) +### @usage: _ADD_CPP_LINTER_CHECK(NAME name LINTER linter [DEPENDS deps] CONFIGS configs_file [GLOBAL_RESOURCES gr] [FILE_PROCESSING_TIME fpt] [EXTRA_PARAMS params] [CUSTOM_CONFIG cc] [CONFIG_TYPE ct]) ### ### Triggers respective plugin macro _ADD_CPP_LINTER_CHECK(Args...) { @@ -5864,12 +5864,12 @@ macro _ADD_CPP_LINTER_CHECK(Args...) { } # tag:test -### @usage STYLE_CPP() +### @usage STYLE_CPP([CONFIG_TYPE config_type]) ### ### Run 'ya tool clang-format' test on all cpp sources and headers of the current module -macro STYLE_CPP() { +macro STYLE_CPP(CONFIG_TYPE="") { .ALLOWED_IN_COMMON=yes - _ADD_CPP_LINTER_CHECK(NAME clang_format LINTER tools/cpp_style_checker/cpp_style_checker GLOBAL_RESOURCES build/platform/clang/clang-format CONFIGS $CPP_LINTERS_DEFAULT_CONFIGS) + _ADD_CPP_LINTER_CHECK(NAME clang_format LINTER tools/cpp_style_checker/cpp_style_checker GLOBAL_RESOURCES build/platform/clang/clang-format CONFIGS $CPP_LINTERS_DEFAULT_CONFIGS CONFIG_TYPE $CONFIG_TYPE) } ### @usage: HEADERS(<Dirs...> [EXCLUDE patterns...]) |
