diff options
author | snermolaev <snermolaev@yandex-team.ru> | 2022-02-10 16:45:53 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:53 +0300 |
commit | 2015790ac9fcc04caab83fccc23ab2460310a797 (patch) | |
tree | e644e9bc3f6f688561a871793b59bf8a637e0f72 /build/plugins | |
parent | c768a99151e47c3a4bb7b92c514d256abd301c4d (diff) | |
download | ydb-2015790ac9fcc04caab83fccc23ab2460310a797.tar.gz |
Restoring authorship annotation for <snermolaev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'build/plugins')
-rw-r--r-- | build/plugins/copy_files_to_build_prefix.py | 72 | ||||
-rw-r--r-- | build/plugins/docs.py | 34 | ||||
-rw-r--r-- | build/plugins/gobuild.py | 548 | ||||
-rw-r--r-- | build/plugins/nots.py | 2 | ||||
-rw-r--r-- | build/plugins/pybuild.py | 38 | ||||
-rw-r--r-- | build/plugins/res.py | 8 | ||||
-rw-r--r-- | build/plugins/rodata.py | 12 | ||||
-rw-r--r-- | build/plugins/ytest.py | 2 |
8 files changed, 358 insertions, 358 deletions
diff --git a/build/plugins/copy_files_to_build_prefix.py b/build/plugins/copy_files_to_build_prefix.py index c8a6e07511..6b041ae797 100644 --- a/build/plugins/copy_files_to_build_prefix.py +++ b/build/plugins/copy_files_to_build_prefix.py @@ -1,36 +1,36 @@ -from _common import sort_by_keywords - - -SOURCE_ROOT = '${ARCADIA_ROOT}/' -BUILD_ROOT = '${ARCADIA_BUILD_ROOT}/' -CURDIR = '${CURDIR}/' -BINDIR = '${BINDIR}/' - - -def oncopy_files_to_build_prefix(unit, *args): - keywords = {'PREFIX': 1, 'GLOBAL': 0} - # NB! keyword 'GLOBAL' is a way to skip this word from the list of files - - flat_args, spec_args = sort_by_keywords(keywords, args) - prefix = spec_args['PREFIX'][0] if 'PREFIX' in spec_args else '' - - if len(prefix) > 0: - build_prefix = '/'.join([BUILD_ROOT, prefix]) - else: - build_prefix = BUILD_ROOT - - for arg in flat_args: - if arg.startswith(build_prefix): - # nothing to do - pass - elif len(prefix) > 0 and arg.startswith(BUILD_ROOT): - unit.oncopy_file([arg, '{}/{}'.format(build_prefix, arg[len(BUILD_ROOT):])]) - elif arg.startswith(SOURCE_ROOT): - unit.oncopy_file([arg, '{}/{}'.format(build_prefix, arg[len(SOURCE_ROOT):])]) - else: - offset = 0 - if arg.startswith(BINDIR): - offset = len(BINDIR) - elif arg.startswith(CURDIR): - offset = len(CURDIR) - unit.oncopy_file([arg, '{}/{}/{}'.format(build_prefix, unit.get(['MODDIR']), arg[offset:])]) +from _common import sort_by_keywords + + +SOURCE_ROOT = '${ARCADIA_ROOT}/' +BUILD_ROOT = '${ARCADIA_BUILD_ROOT}/' +CURDIR = '${CURDIR}/' +BINDIR = '${BINDIR}/' + + +def oncopy_files_to_build_prefix(unit, *args): + keywords = {'PREFIX': 1, 'GLOBAL': 0} + # NB! keyword 'GLOBAL' is a way to skip this word from the list of files + + flat_args, spec_args = sort_by_keywords(keywords, args) + prefix = spec_args['PREFIX'][0] if 'PREFIX' in spec_args else '' + + if len(prefix) > 0: + build_prefix = '/'.join([BUILD_ROOT, prefix]) + else: + build_prefix = BUILD_ROOT + + for arg in flat_args: + if arg.startswith(build_prefix): + # nothing to do + pass + elif len(prefix) > 0 and arg.startswith(BUILD_ROOT): + unit.oncopy_file([arg, '{}/{}'.format(build_prefix, arg[len(BUILD_ROOT):])]) + elif arg.startswith(SOURCE_ROOT): + unit.oncopy_file([arg, '{}/{}'.format(build_prefix, arg[len(SOURCE_ROOT):])]) + else: + offset = 0 + if arg.startswith(BINDIR): + offset = len(BINDIR) + elif arg.startswith(CURDIR): + offset = len(CURDIR) + unit.oncopy_file([arg, '{}/{}/{}'.format(build_prefix, unit.get(['MODDIR']), arg[offset:])]) diff --git a/build/plugins/docs.py b/build/plugins/docs.py index 760fe3af7f..d656ec876d 100644 --- a/build/plugins/docs.py +++ b/build/plugins/docs.py @@ -24,21 +24,21 @@ def macro_calls_to_dict(unit, calls): def onprocess_docs(unit, *args): - build_tool = unit.get('_DOCS_BUILDER_VALUE') - if build_tool: - if build_tool not in ['mkdocs', 'yfm']: - unit.message(['error', 'Unsupported build tool {}'.format(build_tool)]) + build_tool = unit.get('_DOCS_BUILDER_VALUE') + if build_tool: + if build_tool not in ['mkdocs', 'yfm']: + unit.message(['error', 'Unsupported build tool {}'.format(build_tool)]) else: - build_tool = 'yfm' - unit.ondocs_builder([build_tool]) - if build_tool == 'yfm' and unit.enabled('_DOCS_USE_PLANTUML'): - unit.on_docs_yfm_use_plantuml([]) - orig_variables = macro_calls_to_dict(unit, extract_macro_calls(unit, '_DOCS_VARS_VALUE')) - variables = {k: unit.get(k) or v for k, v in orig_variables.items()} - if variables: - if build_tool == 'mkdocs': - unit.set(['_DOCS_VARS_FLAG', ' '.join(['--var {}={}'.format(k, v) for k, v in variables.items()])]) - elif build_tool == 'yfm': - unit.set(['_DOCS_VARS_FLAG', '--vars {}'.format(json.dumps(json.dumps(variables, sort_keys=True)))]) - else: - assert False, 'Unexpected build_tool value: [{}]'.format(build_tool) + build_tool = 'yfm' + unit.ondocs_builder([build_tool]) + if build_tool == 'yfm' and unit.enabled('_DOCS_USE_PLANTUML'): + unit.on_docs_yfm_use_plantuml([]) + orig_variables = macro_calls_to_dict(unit, extract_macro_calls(unit, '_DOCS_VARS_VALUE')) + variables = {k: unit.get(k) or v for k, v in orig_variables.items()} + if variables: + if build_tool == 'mkdocs': + unit.set(['_DOCS_VARS_FLAG', ' '.join(['--var {}={}'.format(k, v) for k, v in variables.items()])]) + elif build_tool == 'yfm': + unit.set(['_DOCS_VARS_FLAG', '--vars {}'.format(json.dumps(json.dumps(variables, sort_keys=True)))]) + else: + assert False, 'Unexpected build_tool value: [{}]'.format(build_tool) diff --git a/build/plugins/gobuild.py b/build/plugins/gobuild.py index 8df96ebc55..3085eb8a5e 100644 --- a/build/plugins/gobuild.py +++ b/build/plugins/gobuild.py @@ -1,277 +1,277 @@ -import base64 -import itertools -import md5 -import os -from _common import rootrel_arc_src, tobuilddir -import ymake - - -runtime_cgo_path = os.path.join('runtime', 'cgo') -runtime_msan_path = os.path.join('runtime', 'msan') -runtime_race_path = os.path.join('runtime', 'race') -arc_project_prefix = 'a.yandex-team.ru/' -import_runtime_cgo_false = { - 'norace': (runtime_cgo_path, runtime_msan_path, runtime_race_path), - 'race': (runtime_cgo_path, runtime_msan_path), -} -import_syscall_false = { - 'norace': (runtime_cgo_path), - 'race': (runtime_cgo_path, runtime_race_path), -} - - -def get_import_path(unit): - # std_lib_prefix = unit.get('GO_STD_LIB_PREFIX') - # unit.get() doesn't evalutate the value of variable, so the line above doesn't really work - std_lib_prefix = unit.get('GOSTD') + '/' - arc_project_prefix = unit.get('GO_ARCADIA_PROJECT_PREFIX') - vendor_prefix = unit.get('GO_CONTRIB_PROJECT_PREFIX') - - module_path = rootrel_arc_src(unit.path(), unit) - assert len(module_path) > 0 - import_path = module_path.replace('\\', '/') - if import_path.startswith(std_lib_prefix): - import_path = import_path[len(std_lib_prefix):] - elif import_path.startswith(vendor_prefix): - import_path = import_path[len(vendor_prefix):] - else: - import_path = arc_project_prefix + import_path - assert len(import_path) > 0 - return import_path - - -def get_appended_values(unit, key): - value = [] - raw_value = unit.get(key) - if raw_value: - value = filter(lambda x: len(x) > 0, raw_value.split(' ')) - assert len(value) == 0 or value[0] == '$' + key - return value[1:] if len(value) > 0 else value - - -def compare_versions(version1, version2): - def last_index(version): - index = version.find('beta') - return len(version) if index < 0 else index - - v1 = tuple(x.zfill(8) for x in version1[:last_index(version1)].split('.')) - v2 = tuple(x.zfill(8) for x in version2[:last_index(version2)].split('.')) - if v1 == v2: - return 0 - return 1 if v1 < v2 else -1 - - -def need_compiling_runtime(import_path, gostd_version): - return import_path in ('runtime', 'reflect', 'syscall') or \ - import_path.startswith('runtime/internal/') or \ - compare_versions('1.17', gostd_version) >= 0 and import_path == 'internal/bytealg' - - -def go_package_name(unit): - name = unit.get('GO_PACKAGE_VALUE') - if not name: - name = unit.get('GO_TEST_IMPORT_PATH') - if name: - name = os.path.basename(os.path.normpath(name)) - elif unit.get('MODULE_TYPE') == 'PROGRAM': - name = 'main' - else: - name = unit.get('REALPRJNAME') - return name - - -def need_lint(path): - return not path.startswith('$S/vendor/') and not path.startswith('$S/contrib/') - - -def on_go_process_srcs(unit): - """ - _GO_PROCESS_SRCS() macro processes only 'CGO' files. All remaining *.go files - and other input files are currently processed by a link command of the - GO module (GO_LIBRARY, GO_PROGRAM) - """ - - srcs_files = get_appended_values(unit, '_GO_SRCS_VALUE') - - asm_files = [] - c_files = [] - cxx_files = [] - ev_files = [] - fbs_files = [] - go_files = [] - in_files = [] - proto_files = [] - s_files = [] - syso_files = [] - - classifed_files = { - '.c': c_files, - '.cc': cxx_files, - '.cpp': cxx_files, - '.cxx': cxx_files, - '.ev': ev_files, - '.fbs': fbs_files, - '.go': go_files, - '.in': in_files, - '.proto': proto_files, - '.s': asm_files, - '.syso': syso_files, - '.C': cxx_files, - '.S': s_files, - } - - # Classify files specifed in _GO_SRCS() macro by extension and process CGO_EXPORT keyword - # which can preceed C/C++ files only - is_cgo_export = False - for f in srcs_files: - _, ext = os.path.splitext(f) - ext_files = classifed_files.get(ext) - if ext_files is not None: - if is_cgo_export: - is_cgo_export = False - if ext in ('.c', '.cc', '.cpp', '.cxx', '.C'): - unit.oncopy_file_with_context([f, f, 'OUTPUT_INCLUDES', '${BINDIR}/_cgo_export.h']) - f = '${BINDIR}/' + f - else: - ymake.report_configure_error('Unmatched CGO_EXPORT keyword in SRCS() macro') - ext_files.append(f) - elif f == 'CGO_EXPORT': - is_cgo_export = True - else: - # FIXME(snermolaev): We can report an unsupported files for _GO_SRCS here - pass - if is_cgo_export: - ymake.report_configure_error('Unmatched CGO_EXPORT keyword in SRCS() macro') - - for f in go_files: - if f.endswith('_test.go'): - ymake.report_configure_error('file {} must be listed in GO_TEST_SRCS() or GO_XTEST_SRCS() macros'.format(f)) - go_test_files = get_appended_values(unit, '_GO_TEST_SRCS_VALUE') - go_xtest_files = get_appended_values(unit, '_GO_XTEST_SRCS_VALUE') - for f in go_test_files + go_xtest_files: - if not f.endswith('_test.go'): - ymake.report_configure_error('file {} should not be listed in GO_TEST_SRCS() or GO_XTEST_SRCS() macros'.format(f)) - - is_test_module = unit.enabled('GO_TEST_MODULE') - - # Add gofmt style checks - if unit.enabled('_GO_FMT_ADD_CHECK'): - 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): - if path.endswith('.go'): - resolved = unit.resolve_arc_path([path]) - if resolved != path and need_lint(resolved): - resolved_go_files.append(resolved) - if resolved_go_files: - basedirs = {} - for f in resolved_go_files: - basedir = os.path.dirname(f) - if basedir not in basedirs: - basedirs[basedir] = [] - basedirs[basedir].append(f) - for basedir in basedirs: - unit.onadd_check(['gofmt'] + basedirs[basedir]) - - # Go coverage instrumentation (NOTE! go_files list is modified here) - if is_test_module and unit.enabled('GO_TEST_COVER'): - cover_info = [] - - for f in go_files: - if f.endswith('_test.go'): - continue - cover_var = 'GoCover' + base64.b32encode(f).rstrip('=') - cover_file = unit.resolve_arc_path(f) - unit.on_go_gen_cover_go([cover_file, cover_var]) - if cover_file.startswith('$S/'): - cover_file = arc_project_prefix + cover_file[3:] - cover_info.append('{}:{}'.format(cover_var, cover_file)) - - # go_files should be empty now since the initial list shouldn't contain - # any non-go or go test file. The value of go_files list will be used later - # to update the value of _GO_SRCS_VALUE - go_files = [] - unit.set(['GO_COVER_INFO_VALUE', ' '.join(cover_info)]) - - # We have cleaned up the list of files from _GO_SRCS_VALUE var and we have to update - # the value since it is used in module command line - unit.set(['_GO_SRCS_VALUE', ' '.join(itertools.chain(go_files, asm_files, syso_files))]) - - unit_path = unit.path() - - # Add go vet check - if unit.enabled('_GO_VET_ADD_CHECK') and need_lint(unit_path): - vet_report_file_name = os.path.join(unit_path, '{}{}'.format(unit.filename(), unit.get('GO_VET_REPORT_EXT'))) - unit.onadd_check(["govet", '$(BUILD_ROOT)/' + tobuilddir(vet_report_file_name)[3:]]) - - for f in ev_files: - ev_proto_file = '{}.proto'.format(f) - unit.oncopy_file_with_context([f, ev_proto_file]) - proto_files.append(ev_proto_file) - - # Process .proto files - for f in proto_files: - unit.on_go_proto_cmd(f) - - # Process .fbs files - for f in fbs_files: - unit.on_go_flatc_cmd([f, go_package_name(unit)]) - - # Process .in files - for f in in_files: - unit.onsrc(f) - - # Generate .symabis for .s files (starting from 1.12 version) - if len(asm_files) > 0: - symabis_flags = [] - gostd_version = unit.get('GOSTD_VERSION') - if compare_versions('1.16', gostd_version) >= 0: - import_path = get_import_path(unit) - symabis_flags.extend(['FLAGS', '-p', import_path]) - if need_compiling_runtime(import_path, gostd_version): - symabis_flags.append('-compiling-runtime') - unit.on_go_compile_symabis(asm_files + symabis_flags) - - # Process cgo files - cgo_files = get_appended_values(unit, '_CGO_SRCS_VALUE') - - cgo_cflags = [] - if len(c_files) + len(cxx_files) + len(s_files) + len(cgo_files) > 0: - if is_test_module: - go_test_for_dir = unit.get('GO_TEST_FOR_DIR') - if go_test_for_dir and go_test_for_dir.startswith('$S/'): - unit.onaddincl(['FOR', 'c', go_test_for_dir[3:]]) - unit.onaddincl(['FOR', 'c', unit.get('MODDIR')]) - cgo_cflags = get_appended_values(unit, 'CGO_CFLAGS_VALUE') - - for f in itertools.chain(c_files, cxx_files, s_files): - unit.onsrc([f] + cgo_cflags) - - if len(cgo_files) > 0: - if not unit.enabled('CGO_ENABLED'): - ymake.report_configure_error('trying to build with CGO (CGO_SRCS is non-empty) when CGO is disabled') - import_path = get_import_path(unit) - if import_path != runtime_cgo_path: - go_std_root = unit.get('GOSTD') - unit.onpeerdir(os.path.join(go_std_root, runtime_cgo_path)) - race_mode = 'race' if unit.enabled('RACE') else 'norace' - import_runtime_cgo = 'false' if import_path in import_runtime_cgo_false[race_mode] else 'true' - import_syscall = 'false' if import_path in import_syscall_false[race_mode] else 'true' - args = [import_path] + cgo_files + ['FLAGS', '-import_runtime_cgo=' + import_runtime_cgo, '-import_syscall=' + import_syscall] +import base64 +import itertools +import md5 +import os +from _common import rootrel_arc_src, tobuilddir +import ymake + + +runtime_cgo_path = os.path.join('runtime', 'cgo') +runtime_msan_path = os.path.join('runtime', 'msan') +runtime_race_path = os.path.join('runtime', 'race') +arc_project_prefix = 'a.yandex-team.ru/' +import_runtime_cgo_false = { + 'norace': (runtime_cgo_path, runtime_msan_path, runtime_race_path), + 'race': (runtime_cgo_path, runtime_msan_path), +} +import_syscall_false = { + 'norace': (runtime_cgo_path), + 'race': (runtime_cgo_path, runtime_race_path), +} + + +def get_import_path(unit): + # std_lib_prefix = unit.get('GO_STD_LIB_PREFIX') + # unit.get() doesn't evalutate the value of variable, so the line above doesn't really work + std_lib_prefix = unit.get('GOSTD') + '/' + arc_project_prefix = unit.get('GO_ARCADIA_PROJECT_PREFIX') + vendor_prefix = unit.get('GO_CONTRIB_PROJECT_PREFIX') + + module_path = rootrel_arc_src(unit.path(), unit) + assert len(module_path) > 0 + import_path = module_path.replace('\\', '/') + if import_path.startswith(std_lib_prefix): + import_path = import_path[len(std_lib_prefix):] + elif import_path.startswith(vendor_prefix): + import_path = import_path[len(vendor_prefix):] + else: + import_path = arc_project_prefix + import_path + assert len(import_path) > 0 + return import_path + + +def get_appended_values(unit, key): + value = [] + raw_value = unit.get(key) + if raw_value: + value = filter(lambda x: len(x) > 0, raw_value.split(' ')) + assert len(value) == 0 or value[0] == '$' + key + return value[1:] if len(value) > 0 else value + + +def compare_versions(version1, version2): + def last_index(version): + index = version.find('beta') + return len(version) if index < 0 else index + + v1 = tuple(x.zfill(8) for x in version1[:last_index(version1)].split('.')) + v2 = tuple(x.zfill(8) for x in version2[:last_index(version2)].split('.')) + if v1 == v2: + return 0 + return 1 if v1 < v2 else -1 + + +def need_compiling_runtime(import_path, gostd_version): + return import_path in ('runtime', 'reflect', 'syscall') or \ + import_path.startswith('runtime/internal/') or \ + compare_versions('1.17', gostd_version) >= 0 and import_path == 'internal/bytealg' + + +def go_package_name(unit): + name = unit.get('GO_PACKAGE_VALUE') + if not name: + name = unit.get('GO_TEST_IMPORT_PATH') + if name: + name = os.path.basename(os.path.normpath(name)) + elif unit.get('MODULE_TYPE') == 'PROGRAM': + name = 'main' + else: + name = unit.get('REALPRJNAME') + return name + + +def need_lint(path): + return not path.startswith('$S/vendor/') and not path.startswith('$S/contrib/') + + +def on_go_process_srcs(unit): + """ + _GO_PROCESS_SRCS() macro processes only 'CGO' files. All remaining *.go files + and other input files are currently processed by a link command of the + GO module (GO_LIBRARY, GO_PROGRAM) + """ + + srcs_files = get_appended_values(unit, '_GO_SRCS_VALUE') + + asm_files = [] + c_files = [] + cxx_files = [] + ev_files = [] + fbs_files = [] + go_files = [] + in_files = [] + proto_files = [] + s_files = [] + syso_files = [] + + classifed_files = { + '.c': c_files, + '.cc': cxx_files, + '.cpp': cxx_files, + '.cxx': cxx_files, + '.ev': ev_files, + '.fbs': fbs_files, + '.go': go_files, + '.in': in_files, + '.proto': proto_files, + '.s': asm_files, + '.syso': syso_files, + '.C': cxx_files, + '.S': s_files, + } + + # Classify files specifed in _GO_SRCS() macro by extension and process CGO_EXPORT keyword + # which can preceed C/C++ files only + is_cgo_export = False + for f in srcs_files: + _, ext = os.path.splitext(f) + ext_files = classifed_files.get(ext) + if ext_files is not None: + if is_cgo_export: + is_cgo_export = False + if ext in ('.c', '.cc', '.cpp', '.cxx', '.C'): + unit.oncopy_file_with_context([f, f, 'OUTPUT_INCLUDES', '${BINDIR}/_cgo_export.h']) + f = '${BINDIR}/' + f + else: + ymake.report_configure_error('Unmatched CGO_EXPORT keyword in SRCS() macro') + ext_files.append(f) + elif f == 'CGO_EXPORT': + is_cgo_export = True + else: + # FIXME(snermolaev): We can report an unsupported files for _GO_SRCS here + pass + if is_cgo_export: + ymake.report_configure_error('Unmatched CGO_EXPORT keyword in SRCS() macro') + + for f in go_files: + if f.endswith('_test.go'): + ymake.report_configure_error('file {} must be listed in GO_TEST_SRCS() or GO_XTEST_SRCS() macros'.format(f)) + go_test_files = get_appended_values(unit, '_GO_TEST_SRCS_VALUE') + go_xtest_files = get_appended_values(unit, '_GO_XTEST_SRCS_VALUE') + for f in go_test_files + go_xtest_files: + if not f.endswith('_test.go'): + ymake.report_configure_error('file {} should not be listed in GO_TEST_SRCS() or GO_XTEST_SRCS() macros'.format(f)) + + is_test_module = unit.enabled('GO_TEST_MODULE') + + # Add gofmt style checks + if unit.enabled('_GO_FMT_ADD_CHECK'): + 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): + if path.endswith('.go'): + resolved = unit.resolve_arc_path([path]) + if resolved != path and need_lint(resolved): + resolved_go_files.append(resolved) + if resolved_go_files: + basedirs = {} + for f in resolved_go_files: + basedir = os.path.dirname(f) + if basedir not in basedirs: + basedirs[basedir] = [] + basedirs[basedir].append(f) + for basedir in basedirs: + unit.onadd_check(['gofmt'] + basedirs[basedir]) + + # Go coverage instrumentation (NOTE! go_files list is modified here) + if is_test_module and unit.enabled('GO_TEST_COVER'): + cover_info = [] + + for f in go_files: + if f.endswith('_test.go'): + continue + cover_var = 'GoCover' + base64.b32encode(f).rstrip('=') + cover_file = unit.resolve_arc_path(f) + unit.on_go_gen_cover_go([cover_file, cover_var]) + if cover_file.startswith('$S/'): + cover_file = arc_project_prefix + cover_file[3:] + cover_info.append('{}:{}'.format(cover_var, cover_file)) + + # go_files should be empty now since the initial list shouldn't contain + # any non-go or go test file. The value of go_files list will be used later + # to update the value of _GO_SRCS_VALUE + go_files = [] + unit.set(['GO_COVER_INFO_VALUE', ' '.join(cover_info)]) + + # We have cleaned up the list of files from _GO_SRCS_VALUE var and we have to update + # the value since it is used in module command line + unit.set(['_GO_SRCS_VALUE', ' '.join(itertools.chain(go_files, asm_files, syso_files))]) + + unit_path = unit.path() + + # Add go vet check + if unit.enabled('_GO_VET_ADD_CHECK') and need_lint(unit_path): + vet_report_file_name = os.path.join(unit_path, '{}{}'.format(unit.filename(), unit.get('GO_VET_REPORT_EXT'))) + unit.onadd_check(["govet", '$(BUILD_ROOT)/' + tobuilddir(vet_report_file_name)[3:]]) + + for f in ev_files: + ev_proto_file = '{}.proto'.format(f) + unit.oncopy_file_with_context([f, ev_proto_file]) + proto_files.append(ev_proto_file) + + # Process .proto files + for f in proto_files: + unit.on_go_proto_cmd(f) + + # Process .fbs files + for f in fbs_files: + unit.on_go_flatc_cmd([f, go_package_name(unit)]) + + # Process .in files + for f in in_files: + unit.onsrc(f) + + # Generate .symabis for .s files (starting from 1.12 version) + if len(asm_files) > 0: + symabis_flags = [] + gostd_version = unit.get('GOSTD_VERSION') + if compare_versions('1.16', gostd_version) >= 0: + import_path = get_import_path(unit) + symabis_flags.extend(['FLAGS', '-p', import_path]) + if need_compiling_runtime(import_path, gostd_version): + symabis_flags.append('-compiling-runtime') + unit.on_go_compile_symabis(asm_files + symabis_flags) + + # Process cgo files + cgo_files = get_appended_values(unit, '_CGO_SRCS_VALUE') + + cgo_cflags = [] + if len(c_files) + len(cxx_files) + len(s_files) + len(cgo_files) > 0: + if is_test_module: + go_test_for_dir = unit.get('GO_TEST_FOR_DIR') + if go_test_for_dir and go_test_for_dir.startswith('$S/'): + unit.onaddincl(['FOR', 'c', go_test_for_dir[3:]]) + unit.onaddincl(['FOR', 'c', unit.get('MODDIR')]) + cgo_cflags = get_appended_values(unit, 'CGO_CFLAGS_VALUE') + + for f in itertools.chain(c_files, cxx_files, s_files): + unit.onsrc([f] + cgo_cflags) + + if len(cgo_files) > 0: + if not unit.enabled('CGO_ENABLED'): + ymake.report_configure_error('trying to build with CGO (CGO_SRCS is non-empty) when CGO is disabled') + import_path = get_import_path(unit) + if import_path != runtime_cgo_path: + go_std_root = unit.get('GOSTD') + unit.onpeerdir(os.path.join(go_std_root, runtime_cgo_path)) + race_mode = 'race' if unit.enabled('RACE') else 'norace' + import_runtime_cgo = 'false' if import_path in import_runtime_cgo_false[race_mode] else 'true' + import_syscall = 'false' if import_path in import_syscall_false[race_mode] else 'true' + args = [import_path] + cgo_files + ['FLAGS', '-import_runtime_cgo=' + import_runtime_cgo, '-import_syscall=' + import_syscall] unit.on_go_compile_cgo1(args) - cgo2_cflags = get_appended_values(unit, 'CGO2_CFLAGS_VALUE') - for f in cgo_files: - if f.endswith('.go'): - unit.onsrc([f[:-2] + 'cgo2.c'] + cgo_cflags + cgo2_cflags) - else: - ymake.report_configure_error('file {} should not be listed in CGO_SRCS() macros'.format(f)) + cgo2_cflags = get_appended_values(unit, 'CGO2_CFLAGS_VALUE') + for f in cgo_files: + if f.endswith('.go'): + unit.onsrc([f[:-2] + 'cgo2.c'] + cgo_cflags + cgo2_cflags) + else: + ymake.report_configure_error('file {} should not be listed in CGO_SRCS() macros'.format(f)) args = [go_package_name(unit)] + cgo_files - if len(c_files) > 0: - args += ['C_FILES'] + c_files - if len(s_files) > 0: - args += ['S_FILES'] + s_files - if len(syso_files) > 0: - args += ['OBJ_FILES'] + syso_files + if len(c_files) > 0: + args += ['C_FILES'] + c_files + if len(s_files) > 0: + args += ['S_FILES'] + s_files + if len(syso_files) > 0: + args += ['OBJ_FILES'] + syso_files unit.on_go_compile_cgo2(args) @@ -279,8 +279,8 @@ def on_go_resource(unit, *args): args = list(args) files = args[::2] keys = args[1::2] - suffix_md5 = md5.new('@'.join(args)).hexdigest() - resource_go = os.path.join("resource.{}.res.go".format(suffix_md5)) + suffix_md5 = md5.new('@'.join(args)).hexdigest() + resource_go = os.path.join("resource.{}.res.go".format(suffix_md5)) unit.onpeerdir(["library/go/core/resource"]) diff --git a/build/plugins/nots.py b/build/plugins/nots.py index 5018256ddc..7c4478c454 100644 --- a/build/plugins/nots.py +++ b/build/plugins/nots.py @@ -27,7 +27,7 @@ def onnode_modules(unit): pm = _create_pm(unit) unit.onpeerdir(pm.get_peer_paths_from_package_json()) ins, outs = pm.calc_node_modules_inouts() - unit.on_node_modules(["IN"] + sorted(ins) + ["OUT"] + sorted(outs)) + unit.on_node_modules(["IN"] + sorted(ins) + ["OUT"] + sorted(outs)) def on_ts_configure(unit, tsconfig_path): diff --git a/build/plugins/pybuild.py b/build/plugins/pybuild.py index f32a2d39a0..457a9a8231 100644 --- a/build/plugins/pybuild.py +++ b/build/plugins/pybuild.py @@ -197,9 +197,9 @@ def onpy_srcs(unit, *args): py_main_only = unit.get('PROCESS_PY_MAIN_ONLY') with_py = not unit.get('PYBUILD_NO_PY') with_pyc = not unit.get('PYBUILD_NO_PYC') - in_proto_library = unit.get('PY_PROTO') or unit.get('PY3_PROTO') + in_proto_library = unit.get('PY_PROTO') or unit.get('PY3_PROTO') venv = unit.get(YA_IDE_VENV_VAR) - need_gazetteer_peerdir = False + need_gazetteer_peerdir = False trim = 0 if not upath.startswith('contrib/tools/python') and not upath.startswith('library/python/runtime') and unit.get('NO_PYTHON_INCLS') != 'yes': @@ -234,7 +234,7 @@ def onpy_srcs(unit, *args): pys = [] protos = [] evs = [] - fbss = [] + fbss = [] py_namespaces = {} dump_dir = unit.get('PYTHON_BUILD_DUMP_DIR') @@ -272,7 +272,7 @@ def onpy_srcs(unit, *args): elif arg == 'SWIG_CPP': swigs = swigs_cpp # Unsupported but legal PROTO_LIBRARY arguments. - elif arg == 'GLOBAL' or not in_proto_library and arg.endswith('.gztproto'): + elif arg == 'GLOBAL' or not in_proto_library and arg.endswith('.gztproto'): pass elif arg == '_MR': # GLOB support: convert arcadia-root-relative paths to module-relative @@ -290,11 +290,11 @@ def onpy_srcs(unit, *args): else: if trim: arg = arg[trim:] - if arg.endswith('.gztproto'): - need_gazetteer_peerdir = True - path = '{}.proto'.format(arg[:-9]) - else: - path = arg + if arg.endswith('.gztproto'): + need_gazetteer_peerdir = True + path = '{}.proto'.format(arg[:-9]) + else: + path = arg main_py = (path == '__main__.py' or path.endswith('/__main__.py')) if not py3 and unit_needs_main and main_py: mod = '__main__' @@ -344,8 +344,8 @@ def onpy_srcs(unit, *args): # Allow pyi files in PY_SRCS for autocomplete in IDE, but skip it during building elif path.endswith('.pyi'): pass - elif path.endswith('.fbs'): - fbss.append(pathmod) + elif path.endswith('.fbs'): + fbss.append(pathmod) else: ymake.report_configure_error('in PY_SRCS: unrecognized arg {!r}'.format(path)) @@ -464,7 +464,7 @@ def onpy_srcs(unit, *args): unit.onresource(ns_res) unit.onresource_files(res) - add_python_lint_checks(unit, 3, [path for path, mod in pys] + unit.get(['_PY_EXTRA_LINT_FILES_VALUE']).split()) + add_python_lint_checks(unit, 3, [path for path, mod in pys] + unit.get(['_PY_EXTRA_LINT_FILES_VALUE']).split()) else: for path, mod in pys: root_rel_path = rootrel_arc_src(path, unit) @@ -481,7 +481,7 @@ def onpy_srcs(unit, *args): res += [dst + '.yapyc', '/py_code/' + mod] unit.onresource(res) - add_python_lint_checks(unit, 2, [path for path, mod in pys] + unit.get(['_PY_EXTRA_LINT_FILES_VALUE']).split()) + add_python_lint_checks(unit, 2, [path for path, mod in pys] + unit.get(['_PY_EXTRA_LINT_FILES_VALUE']).split()) use_vanilla_protoc = unit.get('USE_VANILLA_PROTOC') == 'yes' if use_vanilla_protoc: @@ -515,13 +515,13 @@ def onpy_srcs(unit, *args): unit.on_generate_py_evs_internal([path for path, mod in evs]) unit.onpy_srcs([ev_arg(path, mod, unit) for path, mod in evs]) - if fbss: - unit.onpeerdir(unit.get('_PY_FBS_DEPS').split()) - pysrc_base_name = listid(fbss) - unit.onfbs_to_pysrc([pysrc_base_name] + [path for path, _ in fbss]) - unit.onsrcs(['GLOBAL', '{}.fbs.pysrc'.format(pysrc_base_name)]) - + if fbss: + unit.onpeerdir(unit.get('_PY_FBS_DEPS').split()) + pysrc_base_name = listid(fbss) + unit.onfbs_to_pysrc([pysrc_base_name] + [path for path, _ in fbss]) + unit.onsrcs(['GLOBAL', '{}.fbs.pysrc'.format(pysrc_base_name)]) + def _check_test_srcs(*args): used = set(args) & {"NAMESPACE", "TOP_LEVEL", "__main__.py"} if used: diff --git a/build/plugins/res.py b/build/plugins/res.py index a937caba81..baeec9e6eb 100644 --- a/build/plugins/res.py +++ b/build/plugins/res.py @@ -100,7 +100,7 @@ def onresource_files(unit, *args): src = 'resfs/src/{}={}'.format(key, rootrel_arc_src(path, unit)) res += ['-', src, path, key] - if unit.enabled('_GO_MODULE'): - unit.on_go_resource(res) - else: - unit.onresource(res) + if unit.enabled('_GO_MODULE'): + unit.on_go_resource(res) + else: + unit.onresource(res) diff --git a/build/plugins/rodata.py b/build/plugins/rodata.py index 3ecb0f9a83..ffb31be093 100644 --- a/build/plugins/rodata.py +++ b/build/plugins/rodata.py @@ -21,13 +21,13 @@ class ROData(iw.CustomCommand): if flags: self.parse_flags(path, unit, collections.deque(flags.split(' '))) - if unit.enabled('DARWIN') or unit.enabled('IOS'): + if unit.enabled('DARWIN') or unit.enabled('IOS'): self._platform = ['DARWIN', 'UNIX'] self._fmt = 'macho' - elif unit.enabled('WIN64') or unit.enabled('CYGWIN'): + elif unit.enabled('WIN64') or unit.enabled('CYGWIN'): self._platform = ['WIN64'] self._fmt = 'win' - elif unit.enabled('WIN32'): + elif unit.enabled('WIN32'): self._platform = ['WIN32'] self._fmt = 'win' else: @@ -37,10 +37,10 @@ class ROData(iw.CustomCommand): if 'elf' in self._fmt: self._flags += ['-g', 'dwarf2'] - self._fmt += unit.get('HARDWARE_ARCH') - self._type = unit.get('HARDWARE_TYPE') + self._fmt += unit.get('HARDWARE_ARCH') + self._type = unit.get('HARDWARE_TYPE') - if unit.enabled('DARWIN') or unit.enabled('IOS') or (unit.enabled('WINDOWS') and unit.enabled('ARCH_TYPE_32')): + if unit.enabled('DARWIN') or unit.enabled('IOS') or (unit.enabled('WINDOWS') and unit.enabled('ARCH_TYPE_32')): self._prefix = '_' else: self._prefix = '' diff --git a/build/plugins/ytest.py b/build/plugins/ytest.py index 8970837f0f..35fd151dcf 100644 --- a/build/plugins/ytest.py +++ b/build/plugins/ytest.py @@ -814,7 +814,7 @@ def onjava_test(unit, *args): test_data = get_norm_paths(unit, 'TEST_DATA_VALUE') test_data.append('arcadia/build/scripts/run_junit.py') - test_data.append('arcadia/build/scripts/unpacking_jtest_runner.py') + test_data.append('arcadia/build/scripts/unpacking_jtest_runner.py') data, data_files = get_canonical_test_resources(unit) test_data += data |