blob: 3275ddad253d4378a0c5fb543c63eedeaffeb468 [file]
"""Recipe for running clang-format-diff on the given build."""
from __future__ import absolute_import
from slave import base_recipe
from slave.step import clang_format_step
# Note that the keys are Gerrit project names.
PROJECT_CONFIGS = {
'chromecast/internal': {
'deny_list_filter': [r'vendor/media/google3/(.*)', 'android/prebuilt',
r'(.*)/third_party/(.*)']
},
'chromium/src': {
'deny_list_filter': [r'.*'],
},
'eureka/playready_cdm': {
'deny_list_filter': [r'cast_playready_dummy.cc'],
},
'libassistant/internal/third_party': {
'deny_list_filter': [r'.*'],
},
'vendor/amlogic': {
'deny_list_filter': [r'(\w+)/prebuilt/(.*)'],
},
'vendor/google/neural_network_models': {
'deny_list_filter': [
r'NBGParser',
],
},
'vendor/marvell': {
'deny_list_filter': [r'(\w+)/prebuilt/(.*)'],
},
}
def GetValidBuildNames():
return ['clang_format']
def CreateRecipe(build_name: str, **kwargs):
"""Builds a recipe object."""
del build_name # Unused.
return ClangFormatRecipe(**kwargs)
class ClangFormatRecipe(base_recipe.BaseRecipe):
"""Recipe to clang-format a change."""
def get_steps(self):
allow_list_filter = PROJECT_CONFIGS.get(
self._properties['patch_project'], {}).get('allow_list_filter', None)
deny_list_filter = PROJECT_CONFIGS.get(
self._properties['patch_project'], {}).get('deny_list_filter', None)
return [
clang_format_step.ClangFormatStep(allow_list_filter=allow_list_filter,
deny_list_filter=deny_list_filter,
**self._step_kwargs),
]