aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralevitskii <alevitskii@yandex-team.com>2024-09-19 09:23:33 +0300
committeralevitskii <alevitskii@yandex-team.com>2024-09-19 09:36:58 +0300
commitb483c552ab774f1c6dfeb9cd16493caf9a4bd147 (patch)
tree551f7c280f40305838a00a2315cdcf854f1cb17e
parent3f4d314c20d9192bdf84f803ca3a30a051c18198 (diff)
downloadydb-b483c552ab774f1c6dfeb9cd16493caf9a4bd147.tar.gz
new STYLE_CPP
new STYLE_CPP * STYLE_CPP с дефолтным конфигом * Прокси файлы с линтерными конфигами для python и cpp, чтобы оторвать конфиги от релизных процессов ya-bin commit_hash:fa75b9b1437d66eda31caf24e9232370d8cce031
-rw-r--r--build/conf/python.conf33
-rw-r--r--build/config/tests/py_style/config_paths.json12
-rw-r--r--build/config/tests/py_style/default_configs.json6
-rw-r--r--build/config/tests/py_style/dummy_linter_config.json1
-rw-r--r--build/config/tests/py_style/ya.make1
-rw-r--r--build/plugins/_common.py14
-rw-r--r--build/plugins/_dart_fields.py93
-rw-r--r--build/plugins/ytest.py146
-rw-r--r--build/ymake.core.conf31
9 files changed, 178 insertions, 159 deletions
diff --git a/build/conf/python.conf b/build/conf/python.conf
index ec03c9bebf..eaa2c402c0 100644
--- a/build/conf/python.conf
+++ b/build/conf/python.conf
@@ -179,9 +179,10 @@ macro NO_YMAKE_PYTHON3() {
SET(YMAKE_PYTHON3_PEERDIR)
}
+PYTHON_LINTERS_DEFAULT_CONFIGS=build/config/tests/py_style/default_configs.json
+
FLAKE_EXTRA_PARAMS=
FLAKE_MIGRATIONS_CONFIG=
-FLAKE_CONFIG_FILES=build/config/tests/flake8/flake8.conf $FLAKE_MIGRATIONS_CONFIG
when ($DISABLE_FLAKE8_MIGRATIONS == "yes") {
FLAKE_EXTRA_PARAMS="DISABLE_FLAKE8_MIGRATIONS=yes"
}
@@ -265,24 +266,38 @@ multimodule PY3_PROGRAM {
}
}
+# tag:python-specific tag:internal
+### @usage: _ADD_PY_LINTER_CHECK(NAME name LINTER linter [DEPENDS deps] CONFIGS configs_file [GLOBAL_RESOURCES gr] [FILE_PROCESSING_TIME fpt] [EXTRA_PARAMS params] [PROJECT_TO_CONFIG_MAP pcm] [FLAKE_MIGRATIONS_CONFIG fmc] [CUSTOM_CONFIG cc])
+###
+### Triggers respective plugin
+macro _ADD_PY_LINTER_CHECK(Args...) {
+ SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/${PYTHON_LINTERS_DEFAULT_CONFIGS})
+}
+
+# tag:python-specific tag:internal
+### @usage: STYLE_DUMMY()
+###
+### Not an actual linter, used for dummy linter demonstration
+macro STYLE_DUMMY() {
+ _ADD_PY_LINTER_CHECK(NAME dummy_linter LINTER tools/dummy_linter/dummy_linter CONFIGS $PYTHON_LINTERS_DEFAULT_CONFIGS)
+}
+
# tag:python-specific tag:test
### @usage: STYLE_PYTHON([pyproject])
###
### Check python3 sources for style issues using black.
-BLACK_CONFIG_FILES=
macro STYLE_PYTHON(pyproject...) {
- BLACK_CONFIG_FILES=$pyproject build/config/tests/py_style/config.toml
- _ADD_PY_LINTER_CHECK(NAME black LINTER tools/black_linter/black_linter FILE_PROCESSING_TIME $BLACK_FILE_PROCESSING_TIME CONFIGS $BLACK_CONFIG_FILES)
+ _ADD_PY_LINTER_CHECK(NAME black LINTER tools/black_linter/black_linter FILE_PROCESSING_TIME $BLACK_FILE_PROCESSING_TIME CONFIGS $PYTHON_LINTERS_DEFAULT_CONFIGS CUSTOM_CONFIG $pyproject)
}
# tag:python-specific tag:test
### @usage: STYLE_RUFF()
###
### Check python3 sources for style issues using ruff.
-RUFF_CONFIG_PATHS_FILE=build/config/tests/ruff/ruff_config_paths.json
+RUFF_PROJECT_TO_CONFIG_MAP=build/config/tests/ruff/ruff_config_paths.json
macro STYLE_RUFF() {
- SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/${RUFF_CONFIG_PATHS_FILE})
- _ADD_PY_LINTER_CHECK(NAME ruff LINTER tools/ruff_linter/bin/ruff_linter GLOBAL_RESOURCES build/external_resources/ruff CONFIGS $RUFF_CONFIG_PATHS_FILE)
+ SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/${RUFF_PROJECT_TO_CONFIG_MAP})
+ _ADD_PY_LINTER_CHECK(NAME ruff LINTER tools/ruff_linter/bin/ruff_linter GLOBAL_RESOURCES build/external_resources/ruff CONFIGS $PYTHON_LINTERS_DEFAULT_CONFIGS PROJECT_TO_CONFIG_MAP $RUFF_PROJECT_TO_CONFIG_MAP)
}
# tag:python-specific tag:test
@@ -290,7 +305,7 @@ macro STYLE_RUFF() {
###
### Check python3 sources for style issues using flake8.
macro STYLE_FLAKE8() {
- _ADD_PY_LINTER_CHECK(NAME flake8 LINTER tools/flake8_linter/flake8_linter GLOBAL_RESOURCES build/external_resources/flake8_py3 FILE_PROCESSING_TIME $FLAKE8_FILE_PROCESSING_TIME CONFIGS $FLAKE_CONFIG_FILES EXTRA_PARAMS $FLAKE_EXTRA_PARAMS)
+ _ADD_PY_LINTER_CHECK(NAME flake8 LINTER tools/flake8_linter/flake8_linter GLOBAL_RESOURCES build/external_resources/flake8_py3 FILE_PROCESSING_TIME $FLAKE8_FILE_PROCESSING_TIME CONFIGS $PYTHON_LINTERS_DEFAULT_CONFIGS FLAKE_MIGRATIONS_CONFIG $FLAKE_MIGRATIONS_CONFIG EXTRA_PARAMS $FLAKE_EXTRA_PARAMS)
}
# tag:python-specific tag:test
@@ -298,7 +313,7 @@ macro STYLE_FLAKE8() {
###
### Check python3 sources for style issues using flake8.
macro STYLE_PY2_FLAKE8() {
- _ADD_PY_LINTER_CHECK(NAME py2_flake8 LINTER tools/flake8_linter/flake8_linter GLOBAL_RESOURCES build/external_resources/flake8_py2 FILE_PROCESSING_TIME $FLAKE8_FILE_PROCESSING_TIME CONFIGS $FLAKE_CONFIG_FILES EXTRA_PARAMS $FLAKE_EXTRA_PARAMS)
+ _ADD_PY_LINTER_CHECK(NAME py2_flake8 LINTER tools/flake8_linter/flake8_linter GLOBAL_RESOURCES build/external_resources/flake8_py2 FILE_PROCESSING_TIME $FLAKE8_FILE_PROCESSING_TIME CONFIGS $PYTHON_LINTERS_DEFAULT_CONFIGS FLAKE_MIGRATIONS_CONFIG $FLAKE_MIGRATIONS_CONFIG EXTRA_PARAMS $FLAKE_EXTRA_PARAMS)
}
# tag:python-specific tag:test
diff --git a/build/config/tests/py_style/config_paths.json b/build/config/tests/py_style/config_paths.json
deleted file mode 100644
index 7b3c51669b..0000000000
--- a/build/config/tests/py_style/config_paths.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "": "build/config/tests/py_style/config.toml",
- "devtools/contrib/piglet/template_generator/": "maps/infra/pyproject.toml",
- "devtools/dwh/intrasearch/utils/": "devtools/dwh/pyproject.toml",
- "devtools/rnd/": "devtools/rnd/pyproject.toml",
- "devtools/yamaker/": "devtools/yamaker/pyproject.toml",
- "dj/services/arcanum/": "dj/services/arcanum/pyproject.toml",
- "intranet/search/": "intranet/search/pyproject.toml",
- "maps/": "maps/infra/pyproject.toml",
- "ml/tensorflow/models/userbert/pipeline/multipart/data/": "ml/tensorflow/models/userbert/pipeline/multipart/data/pyproject.toml",
- "partner/python/": "partner/python/pyproject.toml"
-}
diff --git a/build/config/tests/py_style/default_configs.json b/build/config/tests/py_style/default_configs.json
new file mode 100644
index 0000000000..1c8f2ab585
--- /dev/null
+++ b/build/config/tests/py_style/default_configs.json
@@ -0,0 +1,6 @@
+{
+ "flake8": "build/config/tests/flake8/flake8.conf",
+ "py2_flake8": "build/config/tests/flake8/flake8.conf",
+ "black": "build/config/tests/py_style/config.toml",
+ "dummy_linter": "build/config/tests/py_style/dummy_linter_config.json"
+}
diff --git a/build/config/tests/py_style/dummy_linter_config.json b/build/config/tests/py_style/dummy_linter_config.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/build/config/tests/py_style/dummy_linter_config.json
@@ -0,0 +1 @@
+{}
diff --git a/build/config/tests/py_style/ya.make b/build/config/tests/py_style/ya.make
index 37dcd2ec82..6a6a287558 100644
--- a/build/config/tests/py_style/ya.make
+++ b/build/config/tests/py_style/ya.make
@@ -2,7 +2,6 @@ LIBRARY()
RESOURCE_FILES(
config.toml
- config_paths.json
)
END()
diff --git a/build/plugins/_common.py b/build/plugins/_common.py
index a2b19b5b3d..e40798aaf8 100644
--- a/build/plugins/_common.py
+++ b/build/plugins/_common.py
@@ -22,6 +22,20 @@ def lazy(func):
return wrapper
+def cache_by_second_arg(func):
+ result = {}
+
+ def wrapper(arg0, arg1, *args, **kwargs):
+ try:
+ return result[arg1]
+ except KeyError:
+ result[arg1] = func(arg0, arg1, *args, **kwargs)
+
+ return result[arg1]
+
+ return wrapper
+
+
def pathid(path):
return six.ensure_str(base64.b32encode(hashlib.md5(six.ensure_binary(path)).digest()).lower().strip(b'='))
diff --git a/build/plugins/_dart_fields.py b/build/plugins/_dart_fields.py
index 51349aa4ae..34f13579a2 100644
--- a/build/plugins/_dart_fields.py
+++ b/build/plugins/_dart_fields.py
@@ -259,13 +259,28 @@ def _get_ts_test_data_dirs(unit):
)
-@_common.lazy
+@_common.cache_by_second_arg
def get_linter_configs(unit, config_paths):
rel_config_path = _common.rootrel_arc_src(config_paths, unit)
arc_config_path = unit.resolve_arc_path(rel_config_path)
abs_config_path = unit.resolve(arc_config_path)
with open(abs_config_path, 'r') as fd:
- return list(json.load(fd).values())
+ return json.load(fd)
+
+
+def _reference_group_var(varname: str, extensions: list[str] | None = None) -> str:
+ if extensions is None:
+ return f'"${{join=\\;:{varname}}}"'
+
+ return serialize_list(f'${{ext={ext};join=\\;:{varname}}}' for ext in extensions)
+
+
+def assert_file_exists(unit, path):
+ path = unit.resolve(SOURCE_ROOT_SHORT + path)
+ if not os.path.exists(path):
+ message = 'File {} is not found'.format(path)
+ ymake.report_configure_error(message)
+ raise DartValueError()
class AndroidApkTestActivity:
@@ -552,25 +567,56 @@ class LintConfigs:
KEY = 'LINT-CONFIGS'
@classmethod
- def value(cls, unit, flat_args, spec_args):
+ def python_configs(cls, unit, flat_args, spec_args):
resolved_configs = []
- configs = spec_args.get('CONFIGS', [])
- for cfg in configs:
- filename = unit.resolve(SOURCE_ROOT_SHORT + cfg)
- if not os.path.exists(filename):
- message = 'Configuration file {} is not found'.format(filename)
- raise DartValueError(message)
- resolved_configs.append(cfg)
- if os.path.splitext(filename)[-1] == '.json':
- cfgs = get_linter_configs(unit, cfg)
- for c in cfgs:
- filename = unit.resolve(SOURCE_ROOT_SHORT + c)
- if not os.path.exists(filename):
- message = 'Configuration file {} is not found'.format(filename)
- raise DartValueError(message)
- resolved_configs.append(c)
+
+ project_to_config_map = spec_args.get('PROJECT_TO_CONFIG_MAP', [])
+ if project_to_config_map:
+ # ruff, TODO rewrite once custom configs migrated to autoincludes scheme
+ project_to_config_map = project_to_config_map[0]
+ assert_file_exists(unit, project_to_config_map)
+ resolved_configs.append(project_to_config_map)
+ cfgs = get_linter_configs(unit, project_to_config_map).values()
+ for c in cfgs:
+ assert_file_exists(unit, c)
+ resolved_configs.append(c)
+ return {cls.KEY: serialize_list(resolved_configs)}
+
+ custom_config = spec_args.get('CUSTOM_CONFIG', [])
+ if custom_config:
+ # black if custom config is passed
+ # TODO rewrite once custom configs migrated to autoincludes scheme
+ custom_config = custom_config[0]
+ assert_file_exists(unit, custom_config)
+ resolved_configs.append(custom_config)
+ return {cls.KEY: serialize_list(resolved_configs)}
+
+ config = spec_args['CONFIGS'][0]
+ # black without custom config or flake8, using default configs file
+ assert_file_exists(unit, config)
+ name = spec_args['NAME'][0]
+ cfg = get_linter_configs(unit, config)[name]
+ assert_file_exists(unit, cfg)
+ resolved_configs.append(cfg)
+ if name in ('flake8', 'py2_flake8'):
+ resolved_configs.extend(spec_args.get('FLAKE_MIGRATIONS_CONFIG', []))
return {cls.KEY: serialize_list(resolved_configs)}
+ @classmethod
+ def cpp_configs(cls, unit, flat_args, spec_args):
+ custom_config = spec_args.get('CUSTOM_CONFIG')
+ if custom_config:
+ 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])}
+
class LintExtraParams:
KEY = 'LINT-EXTRA-PARAMS'
@@ -581,7 +627,8 @@ class LintExtraParams:
for arg in extra_params:
if '=' not in arg:
message = 'Wrong EXTRA_PARAMS value: "{}". Values must have format "name=value".'.format(arg)
- raise DartValueError(message)
+ ymake.report_configure_error(message)
+ raise DartValueError()
return {cls.KEY: serialize_list(extra_params)}
@@ -600,7 +647,8 @@ class LintName:
def value(cls, unit, flat_args, spec_args):
lint_name = spec_args['NAME'][0]
if lint_name in ('flake8', 'py2_flake8') and (unit.get('DISABLE_FLAKE8') or 'no') == 'yes':
- raise DartValueError('Flake8 linting is disabled by `DISABLE_FLAKE8`')
+ unit.message(['INFO', 'Flake8 linting is disabled by `DISABLE_FLAKE8`'])
+ raise DartValueError()
return {cls.KEY: lint_name}
@@ -1144,6 +1192,11 @@ class TestFiles:
test_files = serialize_list(test_files)
return {cls.KEY: test_files, cls.KEY2: test_files}
+ @classmethod
+ def cpp_linter_files(cls, unit, flat_args, spec_args):
+ files_dart = _reference_group_var("ALL_SRCS", consts.STYLE_CPP_ALL_EXTS)
+ return {cls.KEY: files_dart, cls.KEY2: files_dart}
+
class TestEnv:
KEY = 'TEST-ENV'
diff --git a/build/plugins/ytest.py b/build/plugins/ytest.py
index 05ccb430be..f24ba674a0 100644
--- a/build/plugins/ytest.py
+++ b/build/plugins/ytest.py
@@ -24,7 +24,6 @@ from _dart_fields import (
serialize_list,
get_unit_list_variable,
deserialize_list,
- prepare_env,
create_dart_record,
)
@@ -99,6 +98,19 @@ CHECK_FIELDS_BASE = (
df.UseArcadiaPython.value,
)
+LINTER_FIELDS_BASE = (
+ df.LintName.value,
+ df.LintExtraParams.from_macro_args,
+ df.TestName.name_from_macro_args,
+ df.TestedProjectName.unit_name,
+ df.SourceFolderPath.normalized,
+ df.TestEnv.value,
+ df.UseArcadiaPython.value,
+ df.LintFileProcessingTime.from_macro_args,
+ df.Linter.value,
+ df.CustomDependencies.depends_with_linter,
+)
+
tidy_config_map = None
@@ -397,13 +409,6 @@ def dump_test(unit, kw):
return data
-def reference_group_var(varname: str, extensions: list[str] | None = None) -> str:
- if extensions is None:
- return f'"${{join=\\;:{varname}}}"'
-
- return serialize_list(f'${{ext={ext};join=\\;:{varname}}}' for ext in extensions)
-
-
def count_entries(x):
# see (de)serialize_list
assert x is None or isinstance(x, str), type(x)
@@ -985,32 +990,14 @@ def onsetup_run_python(unit):
unit.ondepends('contrib/tools/python')
-@_common.lazy
-def get_linter_configs(unit, config_paths):
- rel_config_path = _common.rootrel_arc_src(config_paths, unit)
- arc_config_path = unit.resolve_arc_path(rel_config_path)
- abs_config_path = unit.resolve(arc_config_path)
- with open(abs_config_path, 'r') as fd:
- return list(json.load(fd).values())
-
-
@df.with_fields(
(
- df.LintName.value,
- df.TestFiles.py_linter_files,
- df.LintConfigs.value,
- df.LintExtraParams.from_macro_args,
- df.TestName.name_from_macro_args,
- df.TestedProjectName.unit_name,
- df.SourceFolderPath.normalized,
- df.TestEnv.value,
- df.UseArcadiaPython.value,
- df.LintFileProcessingTime.from_macro_args,
- df.Linter.value,
- df.CustomDependencies.depends_with_linter,
+ df.TestFiles.cpp_linter_files,
+ df.LintConfigs.cpp_configs,
)
+ + LINTER_FIELDS_BASE
)
-def on_add_py_linter_check(fields, unit, *args):
+def on_add_cpp_linter_check(fields, unit, *args):
if unit.get("TIDY") == "yes":
return
@@ -1023,8 +1010,8 @@ def on_add_py_linter_check(fields, unit, *args):
"NAME": 1,
"LINTER": 1,
"DEPENDS": unlimited,
- "FILES": unlimited,
- "CONFIGS": unlimited,
+ "CONFIGS": 1,
+ "CUSTOM_CONFIG": 1,
"GLOBAL_RESOURCES": unlimited,
"FILE_PROCESSING_TIME": 1,
"EXTRA_PARAMS": unlimited,
@@ -1047,91 +1034,48 @@ def on_add_py_linter_check(fields, unit, *args):
unit.set_property(["DART_DATA", data])
-def on_add_linter_check(unit, *args):
+@df.with_fields(
+ (
+ df.TestFiles.py_linter_files,
+ df.LintConfigs.python_configs,
+ )
+ + LINTER_FIELDS_BASE
+)
+def on_add_py_linter_check(fields, unit, *args):
if unit.get("TIDY") == "yes":
return
- source_root_from_prefix = '${ARCADIA_ROOT}/'
- source_root_to_prefix = '$S/'
- unlimited = -1
no_lint_value = _common.get_no_lint_value(unit)
if no_lint_value in ("none", "none_internal"):
return
+ unlimited = -1
keywords = {
+ "NAME": 1,
+ "LINTER": 1,
"DEPENDS": unlimited,
- "FILES": unlimited,
- "CONFIGS": unlimited,
+ "CONFIGS": 1,
"GLOBAL_RESOURCES": unlimited,
"FILE_PROCESSING_TIME": 1,
"EXTRA_PARAMS": unlimited,
+ "PROJECT_TO_CONFIG_MAP": 1,
+ "FLAKE_MIGRATIONS_CONFIG": 1,
+ "CUSTOM_CONFIG": 1,
}
- flat_args, spec_args = _common.sort_by_keywords(keywords, args)
- if len(flat_args) != 2:
- unit.message(['ERROR', '_ADD_LINTER_CHECK params: expected 2 free parameters'])
- return
-
- configs = []
- for cfg in spec_args.get('CONFIGS', []):
- filename = unit.resolve(source_root_to_prefix + cfg)
- if not os.path.exists(filename):
- unit.message(['ERROR', 'Configuration file {} is not found'.format(filename)])
- return
- configs.append(cfg)
- deps = []
-
- lint_name, linter = flat_args
- deps.append(os.path.dirname(linter))
-
- test_files = []
- for path in spec_args.get('FILES', []):
- if path.startswith(source_root_from_prefix):
- test_files.append(path.replace(source_root_from_prefix, source_root_to_prefix, 1))
- elif path.startswith(source_root_to_prefix):
- test_files.append(path)
-
- if lint_name == 'cpp_style':
- files_dart = reference_group_var("ALL_SRCS", consts.STYLE_CPP_ALL_EXTS)
- else:
- if not test_files:
- unit.message(['WARN', 'No files to lint for {}'.format(lint_name)])
- return
- files_dart = serialize_list(test_files)
-
- for arg in spec_args.get('EXTRA_PARAMS', []):
- if '=' not in arg:
- unit.message(['WARN', 'Wrong EXTRA_PARAMS value: "{}". Values must have format "name=value".'.format(arg)])
- return
-
- deps += spec_args.get('DEPENDS', [])
-
- for dep in deps:
- unit.ondepends(dep)
+ _, spec_args = _common.sort_by_keywords(keywords, args)
- for resource in spec_args.get('GLOBAL_RESOURCES', []):
+ global_resources = spec_args.get('GLOBAL_RESOURCES', [])
+ for resource in global_resources:
unit.onpeerdir(resource)
+ try:
+ dart_record = create_dart_record(fields, unit, (), spec_args)
+ except df.DartValueError as e:
+ if msg := str(e):
+ unit.message(['WARN', msg])
+ return
+ dart_record[df.ScriptRelPath.KEY] = 'custom_lint'
- test_record = {
- 'TEST-NAME': lint_name,
- 'SCRIPT-REL-PATH': 'custom_lint',
- 'TESTED-PROJECT-NAME': unit.name(),
- 'SOURCE-FOLDER-PATH': _common.get_norm_unit_path(unit),
- 'CUSTOM-DEPENDENCIES': " ".join(deps),
- 'TEST-ENV': prepare_env(unit.get("TEST_ENV_VALUE")),
- 'USE_ARCADIA_PYTHON': unit.get('USE_ARCADIA_PYTHON') or '',
- # TODO remove FILES, see DEVTOOLS-7052
- 'FILES': files_dart,
- 'TEST-FILES': files_dart,
- # Linter specific parameters
- # TODO Add configs to DATA. See YMAKE-427
- 'LINT-CONFIGS': serialize_list(configs),
- 'LINT-NAME': lint_name,
- 'LINT-FILE-PROCESSING-TIME': spec_args.get('FILE_PROCESSING_TIME', [''])[0],
- 'LINT-EXTRA-PARAMS': serialize_list(spec_args.get('EXTRA_PARAMS', [])),
- 'LINTER': linter,
- }
-
- data = dump_test(unit, test_record)
+ data = dump_test(unit, dart_record)
if data:
unit.set_property(["DART_DATA", data])
diff --git a/build/ymake.core.conf b/build/ymake.core.conf
index 388705f63d..b659589740 100644
--- a/build/ymake.core.conf
+++ b/build/ymake.core.conf
@@ -133,6 +133,8 @@ when ($USE_PREBUILT_TOOLS == "yes") {
}
}
+CPP_LINTERS_DEFAULT_CONFIGS=build/config/tests/cpp_style/default_configs.json
+
### @usage: FUNCTION_ORDERING_FILE(VAR_NAME)
###
### Select file for function reordering. Works only with lld linker.
@@ -5830,33 +5832,30 @@ macro YA_CONF_JSON(File) {
}
# tag:internal
-# Don't use directly - wrap with custom macros
-macro ADD_LINTER_CHECK(CheckName, Linter, DEPENDS[], EXCLUDE[], FILES[], CONFIGS[]) {
- SET(_FILES_VAR uniq_${hash:VAR_SALT})
- _GLOB($_FILES_VAR $FILES EXCLUDE $EXCLUDE)
- _ADD_LINTER_CHECK($CheckName $Linter ${pre=DEPENDS :DEPENDS} FILES $$_FILES_VAR CONFIGS $CONFIGS)
-}
-
-# tag:internal
-# Draft. Don't use.
-macro _CPP_STYLE(EXCLUDE[], Files...) {
- ADD_LINTER_CHECK(cpp_style tools/cpp_style_checker/cpp_style_checker DEPENDS contrib/libs/clang16/tools/clang-format EXCLUDE $EXCLUDE FILES $Files CONFIGS devtools/ya/handlers/style/style_config)
+### @usage: _STYLE_CPP([CONFIG])
+###
+### Proxy. Don't use. Call _ADD_CPP_LINTER_CHECK directly if you need a new macro, see STYLE_CPP
+macro _STYLE_CPP(CONFIG...) {
+ _ADD_CPP_LINTER_CHECK(NAME clang_format LINTER tools/cpp_style_checker/cpp_style_checker DEPENDS contrib/libs/clang16/tools/clang-format CONFIGS $CPP_LINTERS_DEFAULT_CONFIGS CUSTOM_CONFIG $CONFIG)
}
# tag:internal
-# A convenient proxy
-macro _STYLE_CPP(CONFIG) {
+### @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])
+###
+### Triggers respective plugin
+macro _ADD_CPP_LINTER_CHECK(Args...) {
SET(USE_ALL_SRCS yes)
HEADERS(.)
- _ADD_LINTER_CHECK(cpp_style tools/cpp_style_checker/cpp_style_checker DEPENDS contrib/libs/clang16/tools/clang-format CONFIGS $CONFIG)
+ SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS $CPP_LINTERS_DEFAULT_CONFIGS)
}
-#tag:test
+# tag:test
### @usage STYLE_CPP()
###
### Run 'ya tool clang-format' test on all cpp sources and headers of the current module
macro STYLE_CPP() {
- _STYLE_CPP("build/config/tests/cpp_style/config.clang-format")
+ .ALLOWED_IN_COMMON=yes
+ _ADD_CPP_LINTER_CHECK(NAME clang_format LINTER tools/cpp_style_checker/cpp_style_checker DEPENDS contrib/libs/clang16/tools/clang-format CONFIGS $CPP_LINTERS_DEFAULT_CONFIGS)
}
### @usage: HEADERS([Dir1 Dir2 ...])