diff options
author | neksard <neksard@yandex-team.ru> | 2022-02-10 16:45:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:23 +0300 |
commit | 8f7cf138264e0caa318144bf8a2c950e0b0a8593 (patch) | |
tree | 83bf5c8c8047c42d8475e6095df90ccdc3d1b57f /build/scripts | |
parent | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (diff) | |
download | ydb-8f7cf138264e0caa318144bf8a2c950e0b0a8593.tar.gz |
Restoring authorship annotation for <neksard@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'build/scripts')
-rw-r--r-- | build/scripts/compile_cuda.py | 26 | ||||
-rw-r--r-- | build/scripts/coverage-info.py | 10 | ||||
-rw-r--r-- | build/scripts/fetch_from_external.py | 16 | ||||
-rw-r--r-- | build/scripts/link_dyn_lib.py | 262 | ||||
-rw-r--r-- | build/scripts/run_msvc_wine.py | 74 | ||||
-rw-r--r-- | build/scripts/ya.make | 10 |
6 files changed, 199 insertions, 199 deletions
diff --git a/build/scripts/compile_cuda.py b/build/scripts/compile_cuda.py index c0bec50b2a..e393b7ecf1 100644 --- a/build/scripts/compile_cuda.py +++ b/build/scripts/compile_cuda.py @@ -1,18 +1,18 @@ -import sys -import subprocess +import sys +import subprocess import os import collections import re import tempfile - - -def is_clang(command): - for word in command: - if '--compiler-bindir' in word and 'clang' in word: - return True - - return False - + + +def is_clang(command): + for word in command: + if '--compiler-bindir' in word and 'clang' in word: + return True + + return False + def main(): try: @@ -25,7 +25,7 @@ def main(): mtime0 = sys.argv[1] command = sys.argv[2: spl] cflags = sys.argv[spl + 1:] - + dump_args = False if '--y_dump_args' in command: command.remove('--y_dump_args') @@ -35,7 +35,7 @@ def main(): if not os.path.exists(executable): print >> sys.stderr, '{} not found'.format(executable) sys.exit(1) - + if is_clang(command): # nvcc concatenates the sources for clang, and clang reports unused # things from .h files as if they they were defined in a .cpp file. diff --git a/build/scripts/coverage-info.py b/build/scripts/coverage-info.py index 94491d9256..7dc2691d23 100644 --- a/build/scripts/coverage-info.py +++ b/build/scripts/coverage-info.py @@ -237,10 +237,10 @@ def main(source_root, output, gcno_archive, gcda_archive, gcov_tool, prefix_filt init_all_coverage_files(gcno_archive, fname2gcno, fname2info, geninfo_executable, gcov_tool, gen_info, prefix_filter, exclude_files) process_all_coverage_files(gcda_archive, fname2gcno, fname2info, geninfo_executable, gcov_tool, gen_info) - if coverage_report_path: - output_dir = coverage_report_path - else: - output_dir = output + '.dir' + if coverage_report_path: + output_dir = coverage_report_path + else: + output_dir = output + '.dir' if not os.path.exists(output_dir): os.makedirs(output_dir) @@ -274,7 +274,7 @@ if __name__ == '__main__': parser.add_argument('--prefix-filter', action='store') parser.add_argument('--exclude-regexp', action='store') parser.add_argument('--teamcity-stat-output', action='store_const', const=True) - parser.add_argument('--coverage-report-path', action='store') + parser.add_argument('--coverage-report-path', action='store') parser.add_argument('--gcov-report', action='store') parser.add_argument('--lcov-cobertura', action='store') diff --git a/build/scripts/fetch_from_external.py b/build/scripts/fetch_from_external.py index d4ed6f4221..47060130f8 100644 --- a/build/scripts/fetch_from_external.py +++ b/build/scripts/fetch_from_external.py @@ -1,11 +1,11 @@ -import sys -import json +import sys +import json import os.path import fetch_from import argparse import logging - - + + def parse_args(): parser = argparse.ArgumentParser() fetch_from.add_common_arguments(parser) @@ -13,8 +13,8 @@ def parse_args(): parser.add_argument('--custom-fetcher') parser.add_argument('--resource-file') return parser.parse_args() - - + + def main(args): external_file = args.external_file.rstrip('.external') if os.path.isfile(args.resource_file): @@ -25,7 +25,7 @@ def main(args): try: with open(args.external_file) as f: js = json.load(f) - + if js['storage'] == 'SANDBOX': import fetch_from_sandbox as ffsb del args.external_file @@ -45,7 +45,7 @@ def main(args): raise Exception(error) -if __name__ == '__main__': +if __name__ == '__main__': args = parse_args() fetch_from.setup_logging(args, os.path.basename(__file__)) diff --git a/build/scripts/link_dyn_lib.py b/build/scripts/link_dyn_lib.py index 23487f5c1e..709a9b4fbd 100644 --- a/build/scripts/link_dyn_lib.py +++ b/build/scripts/link_dyn_lib.py @@ -30,75 +30,75 @@ def parse_export_file(p): yield {'lang': words[0], 'sym': words[1]} elif len(words) == 1: yield {'lang': 'C', 'sym': words[0]} - else: + else: raise Exception('unsupported exports line: ' + l) -def to_c(sym): - symbols = collections.deque(sym.split('::')) - c_prefixes = [ # demangle prefixes for c++ symbols - '_ZN', # namespace - '_ZTIN', # typeinfo for - '_ZTSN', # typeinfo name for - '_ZTTN', # VTT for - '_ZTVN', # vtable for - '_ZNK', # const methods - ] - c_sym = '' - while symbols: - s = symbols.popleft() - if s == '*': - c_sym += '*' - break - if '*' in s and len(s) > 1: - raise Exception('Unsupported format, cannot guess length of symbol: ' + s) - c_sym += str(len(s)) + s - if symbols: - raise Exception('Unsupported format: ' + sym) - if c_sym[-1] != '*': - c_sym += 'E*' - return ['{prefix}{sym}'.format(prefix=prefix, sym=c_sym) for prefix in c_prefixes] - - +def to_c(sym): + symbols = collections.deque(sym.split('::')) + c_prefixes = [ # demangle prefixes for c++ symbols + '_ZN', # namespace + '_ZTIN', # typeinfo for + '_ZTSN', # typeinfo name for + '_ZTTN', # VTT for + '_ZTVN', # vtable for + '_ZNK', # const methods + ] + c_sym = '' + while symbols: + s = symbols.popleft() + if s == '*': + c_sym += '*' + break + if '*' in s and len(s) > 1: + raise Exception('Unsupported format, cannot guess length of symbol: ' + s) + c_sym += str(len(s)) + s + if symbols: + raise Exception('Unsupported format: ' + sym) + if c_sym[-1] != '*': + c_sym += 'E*' + return ['{prefix}{sym}'.format(prefix=prefix, sym=c_sym) for prefix in c_prefixes] + + def fix_darwin_param(ex): for item in ex: - if item.get('linux_version'): - continue - + if item.get('linux_version'): + continue + if item['lang'] == 'C': yield '-Wl,-exported_symbol,_' + item['sym'] - elif item['lang'] == 'C++': - for sym in to_c(item['sym']): - yield '-Wl,-exported_symbol,_' + sym + elif item['lang'] == 'C++': + for sym in to_c(item['sym']): + yield '-Wl,-exported_symbol,_' + sym else: raise Exception('unsupported lang: ' + item['lang']) def fix_gnu_param(arch, ex): d = collections.defaultdict(list) - version = None + version = None for item in ex: - if item.get('linux_version'): - if not version: - version = item.get('linux_version') - else: - raise Exception('More than one linux_version defined') - elif item['lang'] == 'C++': - d['C'].extend(to_c(item['sym'])) - else: - d[item['lang']].append(item['sym']) + if item.get('linux_version'): + if not version: + version = item.get('linux_version') + else: + raise Exception('More than one linux_version defined') + elif item['lang'] == 'C++': + d['C'].extend(to_c(item['sym'])) + else: + d[item['lang']].append(item['sym']) with tempfile.NamedTemporaryFile(mode='wt', delete=False) as f: - if version: - f.write('{} {{\nglobal:\n'.format(version)) - else: - f.write('{\nglobal:\n') + if version: + f.write('{} {{\nglobal:\n'.format(version)) + else: + f.write('{\nglobal:\n') for k, v in d.items(): f.write(' extern "' + k + '" {\n') for x in v: - f.write(' ' + x + ';\n') + f.write(' ' + x + ';\n') f.write(' };\n') @@ -208,87 +208,87 @@ if __name__ == '__main__': if os.path.exists(opts.soname): os.unlink(opts.soname) os.link(opts.target, opts.soname) - - -# -----------------Test---------------- # -def write_temp_file(content): - import yatest.common as yc - filename = yc.output_path('test.exports') - with open(filename, 'w') as f: - f.write(content) - return filename - - -def test_fix_cmd_darwin(): - export_file_content = """ -C++ geobase5::details::lookup_impl::* -C++ geobase5::hardcoded_service -""" - filename = write_temp_file(export_file_content) - args = ['-Wl,--version-script={}'.format(filename)] + + +# -----------------Test---------------- # +def write_temp_file(content): + import yatest.common as yc + filename = yc.output_path('test.exports') + with open(filename, 'w') as f: + f.write(content) + return filename + + +def test_fix_cmd_darwin(): + export_file_content = """ +C++ geobase5::details::lookup_impl::* +C++ geobase5::hardcoded_service +""" + filename = write_temp_file(export_file_content) + args = ['-Wl,--version-script={}'.format(filename)] assert fix_cmd('DARWIN', False, args) == [ - '-Wl,-exported_symbol,__ZN8geobase57details11lookup_impl*', - '-Wl,-exported_symbol,__ZTIN8geobase57details11lookup_impl*', - '-Wl,-exported_symbol,__ZTSN8geobase57details11lookup_impl*', - '-Wl,-exported_symbol,__ZTTN8geobase57details11lookup_impl*', - '-Wl,-exported_symbol,__ZTVN8geobase57details11lookup_impl*', - '-Wl,-exported_symbol,__ZNK8geobase57details11lookup_impl*', - '-Wl,-exported_symbol,__ZN8geobase517hardcoded_serviceE*', - '-Wl,-exported_symbol,__ZTIN8geobase517hardcoded_serviceE*', - '-Wl,-exported_symbol,__ZTSN8geobase517hardcoded_serviceE*', - '-Wl,-exported_symbol,__ZTTN8geobase517hardcoded_serviceE*', - '-Wl,-exported_symbol,__ZTVN8geobase517hardcoded_serviceE*', - '-Wl,-exported_symbol,__ZNK8geobase517hardcoded_serviceE*', - ] - - -def run_fix_gnu_param(export_file_content): - filename = write_temp_file(export_file_content) - result = fix_gnu_param('LINUX', list(parse_export_file(filename)))[0] - version_script_path = result[len('-Wl,--version-script='):] - with open(version_script_path) as f: - content = f.read() - return content - - -def test_fix_gnu_param(): - export_file_content = """ -C++ geobase5::details::lookup_impl::* -C getFactoryMap -""" - assert run_fix_gnu_param(export_file_content) == """{ -global: - extern "C" { - _ZN8geobase57details11lookup_impl*; - _ZTIN8geobase57details11lookup_impl*; - _ZTSN8geobase57details11lookup_impl*; - _ZTTN8geobase57details11lookup_impl*; - _ZTVN8geobase57details11lookup_impl*; - _ZNK8geobase57details11lookup_impl*; - getFactoryMap; - }; -local: *; -}; -""" - - -def test_fix_gnu_param_with_linux_version(): - export_file_content = """ -C++ geobase5::details::lookup_impl::* -linux_version ver1.0 -C getFactoryMap -""" - assert run_fix_gnu_param(export_file_content) == """ver1.0 { -global: - extern "C" { - _ZN8geobase57details11lookup_impl*; - _ZTIN8geobase57details11lookup_impl*; - _ZTSN8geobase57details11lookup_impl*; - _ZTTN8geobase57details11lookup_impl*; - _ZTVN8geobase57details11lookup_impl*; - _ZNK8geobase57details11lookup_impl*; - getFactoryMap; - }; -local: *; -}; -""" + '-Wl,-exported_symbol,__ZN8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZTIN8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZTSN8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZTTN8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZTVN8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZNK8geobase57details11lookup_impl*', + '-Wl,-exported_symbol,__ZN8geobase517hardcoded_serviceE*', + '-Wl,-exported_symbol,__ZTIN8geobase517hardcoded_serviceE*', + '-Wl,-exported_symbol,__ZTSN8geobase517hardcoded_serviceE*', + '-Wl,-exported_symbol,__ZTTN8geobase517hardcoded_serviceE*', + '-Wl,-exported_symbol,__ZTVN8geobase517hardcoded_serviceE*', + '-Wl,-exported_symbol,__ZNK8geobase517hardcoded_serviceE*', + ] + + +def run_fix_gnu_param(export_file_content): + filename = write_temp_file(export_file_content) + result = fix_gnu_param('LINUX', list(parse_export_file(filename)))[0] + version_script_path = result[len('-Wl,--version-script='):] + with open(version_script_path) as f: + content = f.read() + return content + + +def test_fix_gnu_param(): + export_file_content = """ +C++ geobase5::details::lookup_impl::* +C getFactoryMap +""" + assert run_fix_gnu_param(export_file_content) == """{ +global: + extern "C" { + _ZN8geobase57details11lookup_impl*; + _ZTIN8geobase57details11lookup_impl*; + _ZTSN8geobase57details11lookup_impl*; + _ZTTN8geobase57details11lookup_impl*; + _ZTVN8geobase57details11lookup_impl*; + _ZNK8geobase57details11lookup_impl*; + getFactoryMap; + }; +local: *; +}; +""" + + +def test_fix_gnu_param_with_linux_version(): + export_file_content = """ +C++ geobase5::details::lookup_impl::* +linux_version ver1.0 +C getFactoryMap +""" + assert run_fix_gnu_param(export_file_content) == """ver1.0 { +global: + extern "C" { + _ZN8geobase57details11lookup_impl*; + _ZTIN8geobase57details11lookup_impl*; + _ZTSN8geobase57details11lookup_impl*; + _ZTTN8geobase57details11lookup_impl*; + _ZTVN8geobase57details11lookup_impl*; + _ZNK8geobase57details11lookup_impl*; + getFactoryMap; + }; +local: *; +}; +""" diff --git a/build/scripts/run_msvc_wine.py b/build/scripts/run_msvc_wine.py index 439d1f8831..34862af650 100644 --- a/build/scripts/run_msvc_wine.py +++ b/build/scripts/run_msvc_wine.py @@ -94,7 +94,7 @@ def call_wine_cmd_once(wine, cmd, env, mode): 'Could not load wine-gecko', 'wine: configuration in', 'wine: created the configuration directory', - 'libpng warning:' + 'libpng warning:' ] suffixes = [ @@ -106,13 +106,13 @@ def call_wine_cmd_once(wine, cmd, env, mode): ] substrs = [ - 'Creating library Z:', - 'err:heap', - 'err:menubuilder:', - 'err:msvcrt', - 'err:ole:', - 'err:wincodecs:', - 'err:winediag:', + 'Creating library Z:', + 'err:heap', + 'err:menubuilder:', + 'err:msvcrt', + 'err:ole:', + 'err:wincodecs:', + 'err:winediag:', ] def good_line(l): @@ -318,47 +318,47 @@ def colorize(out): return '\n'.join(colorize_line(l) for l in out.split('\n')) -def trim_path(path, winepath): +def trim_path(path, winepath): p1 = run_subprocess([winepath, '-w', path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p1_stdout, p1_stderr = p1.communicate() win_path = p1_stdout.strip() - + if p1.returncode != 0 or not win_path: # Fall back to only winepath -s win_path = path - + p2 = run_subprocess([winepath, '-s', win_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p2_stdout, p2_stderr = p2.communicate() short_path = p2_stdout.strip() - + check_path = short_path if check_path.startswith(('Z:', 'z:')): check_path = check_path[2:] - + if not check_path[1:].startswith((path[1:4], path[1:4].upper())): raise Exception('Cannot trim path {}; 1st winepath exit code: {}, stdout:\n{}\n stderr:\n{}\n 2nd winepath exit code: {}, stdout:\n{}\n stderr:\n{}'.format(path, p1.returncode, p1_stdout, p1_stderr, p2.returncode, p2_stdout, p2_stderr)) return short_path -def downsize_path(path, short_names): - flag = '' - if path.startswith('/Fo'): - flag = '/Fo' - path = path[3:] - - for full_name, short_name in short_names.items(): - if path.startswith(full_name): - path = path.replace(full_name, short_name) - - return flag + path - - -def make_full_path_arg(arg, bld_root, short_root): - if arg[0] != '/' and len(os.path.join(bld_root, arg)) > 250: - return os.path.join(short_root, arg) - return arg - +def downsize_path(path, short_names): + flag = '' + if path.startswith('/Fo'): + flag = '/Fo' + path = path[3:] + + for full_name, short_name in short_names.items(): + if path.startswith(full_name): + path = path.replace(full_name, short_name) + + return flag + path + + +def make_full_path_arg(arg, bld_root, short_root): + if arg[0] != '/' and len(os.path.join(bld_root, arg)) > 250: + return os.path.join(short_root, arg) + return arg + def fix_path(p): topdirs = ['/%s/' % d for d in os.listdir('/')] def abs_path_start(path, pos): @@ -414,8 +414,8 @@ def run_main(): parser.add_argument('-v', action='store', dest='version', default='120') parser.add_argument('-I', action='append', dest='incl_paths') parser.add_argument('mode', action='store') - parser.add_argument('arcadia_root', action='store') - parser.add_argument('arcadia_build_root', action='store') + parser.add_argument('arcadia_root', action='store') + parser.add_argument('arcadia_build_root', action='store') parser.add_argument('binary', action='store') parser.add_argument('free_args', nargs=argparse.REMAINDER) # By now just unpack. Ideally we should fix path and pack arguments back into command file @@ -426,10 +426,10 @@ def run_main(): binary = args.binary version = args.version incl_paths = args.incl_paths - bld_root = args.arcadia_build_root + bld_root = args.arcadia_build_root free_args = args.free_args - wine_dir = os.path.dirname(os.path.dirname(wine)) + wine_dir = os.path.dirname(os.path.dirname(wine)) bin_dir = os.path.dirname(binary) tc_dir = os.path.dirname(os.path.dirname(os.path.dirname(bin_dir))) if not incl_paths: @@ -449,10 +449,10 @@ def run_main(): env['WindowsSdkDir'] = fix_path(tc_dir) env['LIBPATH'] = fix_path(tc_dir + '/VC/lib/amd64') env['LIB'] = fix_path(tc_dir + '/VC/lib/amd64') - env['LD_LIBRARY_PATH'] = ':'.join(wine_dir + d for d in ['/lib', '/lib64', '/lib64/wine']) + env['LD_LIBRARY_PATH'] = ':'.join(wine_dir + d for d in ['/lib', '/lib64', '/lib64/wine']) cmd = [binary] + process_free_args(free_args, wine, bld_root, mode) - + for x in ('/NOLOGO', '/nologo', '/FD'): try: cmd.remove(x) diff --git a/build/scripts/ya.make b/build/scripts/ya.make index 710165e40d..35b7184460 100644 --- a/build/scripts/ya.make +++ b/build/scripts/ya.make @@ -1,8 +1,8 @@ OWNER(g:ymake) PY2TEST() - -TEST_SRCS( + +TEST_SRCS( build_dll_and_java.py build_info_gen.py build_java_codenav_index.py @@ -53,7 +53,7 @@ TEST_SRCS( ios_wrapper.py java_pack_to_file.py link_asrc.py - link_dyn_lib.py + link_dyn_lib.py link_exe.py link_fat_obj.py link_lib.py @@ -93,8 +93,8 @@ TEST_SRCS( xargs.py yield_line.py yndexer.py -) - +) + PEERDIR( ydb/library/yql/public/udf ) |