diff options
author | spreis <spreis@yandex-team.com> | 2024-04-18 09:04:59 +0300 |
---|---|---|
committer | spreis <spreis@yandex-team.com> | 2024-04-18 09:15:29 +0300 |
commit | 900479406e37df8dd34053bee39596d5ee64e767 (patch) | |
tree | ff5765e22dc6ad462a0e7c2eeec0ad606a584abf /build | |
parent | 8386b6d7518d2de99d244f248fa0f7a78880ae39 (diff) | |
download | ydb-900479406e37df8dd34053bee39596d5ee64e767.tar.gz |
Allow skipping gofmt only in selected paths
3b605aec23b075e3524747f5c0c1e9ea65cb4040
Diffstat (limited to 'build')
-rw-r--r-- | build/plugins/gobuild.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/build/plugins/gobuild.py b/build/plugins/gobuild.py index af073ff6ab..04603c2eb5 100644 --- a/build/plugins/gobuild.py +++ b/build/plugins/gobuild.py @@ -160,8 +160,31 @@ def on_go_process_srcs(unit): is_test_module = unit.enabled('GO_TEST_MODULE') + unit_path = unit.path() + # Add gofmt style checks - if unit.enabled('_GO_FMT_ADD_CHECK'): + add_fmt = True + if not unit.enabled('_GO_FMT_ADD_CHECK'): + allow_skip_fmt = unit.get('_GO_FMT_ALLOW_SKIP') + allow_skip_fmt_list = None + if allow_skip_fmt: + allow_skip_fmt_list = unit.get('_GO_FMT_ALLOW_SKIP').split(' ') + + if allow_skip_fmt_list: + unit_rel_path = rootrel_arc_src(unit_path, unit) + if unit_rel_path in allow_skip_fmt_list: + add_fmt = False + else: + for item in allow_skip_fmt_list: + if item: + prefix = item if item[-1] == '/' else item + '/' + if unit_rel_path.startswith(prefix): + add_fmt = False + break + if add_fmt: + ymake.report_configure_error('Disabling gofmt is prohibited, please contact devtools') + + if add_fmt: resolved_go_files = [] go_source_files = [] if is_test_module and unit.get(['GO_TEST_FOR_DIR']) else go_files for path in itertools.chain(go_source_files, go_test_files, go_xtest_files): @@ -179,8 +202,6 @@ def on_go_process_srcs(unit): for basedir in basedirs: unit.onadd_check(['gofmt'] + basedirs[basedir]) - unit_path = unit.path() - # Go coverage instrumentation (NOTE! go_files list is modified here) if is_test_module and unit.enabled('GO_TEST_COVER'): cover_info = [] |