diff options
author | somov <somov@yandex-team.ru> | 2022-02-10 16:45:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:49 +0300 |
commit | 7489e4682331202b9c7d863c0898eb83d7b12c2b (patch) | |
tree | 9142afc54d335ea52910662635b898e79e192e49 /build/scripts | |
parent | a5950576e397b1909261050b8c7da16db58f10b1 (diff) | |
download | ydb-7489e4682331202b9c7d863c0898eb83d7b12c2b.tar.gz |
Restoring authorship annotation for <somov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts')
-rw-r--r-- | build/scripts/check_config_h.py | 32 | ||||
-rw-r--r-- | build/scripts/clang_wrapper.py | 22 | ||||
-rw-r--r-- | build/scripts/compile_cuda.py | 118 | ||||
-rw-r--r-- | build/scripts/custom_link_green_mysql.py | 194 | ||||
-rw-r--r-- | build/scripts/link_dyn_lib.py | 2 | ||||
-rw-r--r-- | build/scripts/link_exe.py | 10 | ||||
-rw-r--r-- | build/scripts/link_fat_obj.py | 74 | ||||
-rw-r--r-- | build/scripts/link_lib.py | 20 | ||||
-rw-r--r-- | build/scripts/run_msvc_wine.py | 46 |
9 files changed, 259 insertions, 259 deletions
diff --git a/build/scripts/check_config_h.py b/build/scripts/check_config_h.py index b5e53cecd8..07bc12e230 100644 --- a/build/scripts/check_config_h.py +++ b/build/scripts/check_config_h.py @@ -2,81 +2,81 @@ import sys data = """ #if defined(SIZEOF_LONG) -static_assert(sizeof(long) == SIZEOF_LONG, "fixme 1"); +static_assert(sizeof(long) == SIZEOF_LONG, "fixme 1"); #endif #if defined(SIZEOF_PTHREAD_T) #include <pthread.h> -static_assert(sizeof(pthread_t) == SIZEOF_PTHREAD_T, "fixme 2"); +static_assert(sizeof(pthread_t) == SIZEOF_PTHREAD_T, "fixme 2"); #endif #if defined(SIZEOF_SIZE_T) #include <stddef.h> -static_assert(sizeof(size_t) == SIZEOF_SIZE_T, "fixme 3"); +static_assert(sizeof(size_t) == SIZEOF_SIZE_T, "fixme 3"); #endif #if defined(SIZEOF_TIME_T) #include <time.h> -static_assert(sizeof(time_t) == SIZEOF_TIME_T, "fixme 4"); +static_assert(sizeof(time_t) == SIZEOF_TIME_T, "fixme 4"); #endif #if defined(SIZEOF_UINTPTR_T) #include <stdint.h> -static_assert(sizeof(uintptr_t) == SIZEOF_UINTPTR_T, "fixme 5"); +static_assert(sizeof(uintptr_t) == SIZEOF_UINTPTR_T, "fixme 5"); #endif #if defined(SIZEOF_VOID_P) -static_assert(sizeof(void*) == SIZEOF_VOID_P, "fixme 6"); +static_assert(sizeof(void*) == SIZEOF_VOID_P, "fixme 6"); #endif #if defined(SIZEOF_FPOS_T) #include <stdio.h> -static_assert(sizeof(fpos_t) == SIZEOF_FPOS_T, "fixme 7"); +static_assert(sizeof(fpos_t) == SIZEOF_FPOS_T, "fixme 7"); #endif #if defined(SIZEOF_DOUBLE) -static_assert(sizeof(double) == SIZEOF_DOUBLE, "fixme 8"); +static_assert(sizeof(double) == SIZEOF_DOUBLE, "fixme 8"); #endif #if defined(SIZEOF_LONG_DOUBLE) -static_assert(sizeof(long double) == SIZEOF_LONG_DOUBLE, "fixme 9"); +static_assert(sizeof(long double) == SIZEOF_LONG_DOUBLE, "fixme 9"); #endif #if defined(SIZEOF_FLOAT) -static_assert(sizeof(float) == SIZEOF_FLOAT, "fixme 10"); +static_assert(sizeof(float) == SIZEOF_FLOAT, "fixme 10"); #endif #if defined(SIZEOF_INT) -static_assert(sizeof(int) == SIZEOF_INT, "fixme 11"); +static_assert(sizeof(int) == SIZEOF_INT, "fixme 11"); #endif #if defined(SIZEOF_LONG_LONG) -static_assert(sizeof(long long) == SIZEOF_LONG_LONG, "fixme 12"); +static_assert(sizeof(long long) == SIZEOF_LONG_LONG, "fixme 12"); #endif #if defined(SIZEOF_OFF_T) #include <stdio.h> -static_assert(sizeof(off_t) == SIZEOF_OFF_T, "fixme 13"); +static_assert(sizeof(off_t) == SIZEOF_OFF_T, "fixme 13"); #endif #if defined(SIZEOF_PID_T) #include <unistd.h> -static_assert(sizeof(pid_t) == SIZEOF_PID_T, "fixme 14"); +static_assert(sizeof(pid_t) == SIZEOF_PID_T, "fixme 14"); #endif #if defined(SIZEOF_SHORT) -static_assert(sizeof(short) == SIZEOF_SHORT, "fixme 15"); +static_assert(sizeof(short) == SIZEOF_SHORT, "fixme 15"); #endif #if defined(SIZEOF_WCHAR_T) -static_assert(sizeof(wchar_t) == SIZEOF_WCHAR_T, "fixme 16"); +static_assert(sizeof(wchar_t) == SIZEOF_WCHAR_T, "fixme 16"); #endif #if defined(SIZEOF__BOOL) diff --git a/build/scripts/clang_wrapper.py b/build/scripts/clang_wrapper.py index f574e594ac..af3869f789 100644 --- a/build/scripts/clang_wrapper.py +++ b/build/scripts/clang_wrapper.py @@ -1,8 +1,8 @@ import subprocess -import sys - - -def fix(s): +import sys + + +def fix(s): # disable dbg DEVTOOLS-2744 if s == '-g': return None @@ -17,14 +17,14 @@ def fix(s): if s.startswith('-fabi-version'): return None - # remove arguments unknown to clang-cl + # remove arguments unknown to clang-cl if s == '-fcase-insensitive-paths': # or s == '-fno-lto': # DEVTOOLSSUPPORT-3966 - return None - + return None + # Paths under .ya/tools/v3/.../msvc/include are divided with '\' return s.replace('\\', '/') - - + + def fix_path(p): try: i = p.rfind('/bin/clang') @@ -34,7 +34,7 @@ def fix_path(p): return p -if __name__ == '__main__': +if __name__ == '__main__': is_on_win = sys.argv[1] == 'yes' path = sys.argv[2] args = filter(None, [fix(s) for s in sys.argv[3:]]) @@ -46,7 +46,7 @@ if __name__ == '__main__': except ValueError: pass args.append('-fms-compatibility-version=19') - + cmd = [path] + args rc = subprocess.call(cmd, shell=False, stderr=sys.stderr, stdout=sys.stdout) diff --git a/build/scripts/compile_cuda.py b/build/scripts/compile_cuda.py index aaf9142b6d..c0bec50b2a 100644 --- a/build/scripts/compile_cuda.py +++ b/build/scripts/compile_cuda.py @@ -1,7 +1,7 @@ import sys import subprocess -import os -import collections +import os +import collections import re import tempfile @@ -13,52 +13,52 @@ def is_clang(command): return False - -def main(): - try: - sys.argv.remove('--y_skip_nocxxinc') - skip_nocxxinc = True - except ValueError: - skip_nocxxinc = False - + +def main(): + try: + sys.argv.remove('--y_skip_nocxxinc') + skip_nocxxinc = True + except ValueError: + skip_nocxxinc = False + spl = sys.argv.index('--cflags') 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') - dump_args = True - + dump_args = False + if '--y_dump_args' in command: + command.remove('--y_dump_args') + dump_args = True + executable = command[0] if not os.path.exists(executable): print >> sys.stderr, '{} not found'.format(executable) sys.exit(1) - if is_clang(command): + 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. cflags += ['-Wno-unused-function', '-Wno-unused-parameter'] - + if not is_clang(command) and '-fopenmp=libomp' in cflags: cflags.append('-fopenmp') cflags.remove('-fopenmp=libomp') - + skip_list = [ '-gline-tables-only', # clang coverage '-fprofile-instr-generate', '-fcoverage-mapping', '/Zc:inline', # disable unreferenced functions (kernel registrators) remove - '-Wno-c++17-extensions', - '-flto', + '-Wno-c++17-extensions', + '-flto', '-faligned-allocation', ] - if skip_nocxxinc: - skip_list.append('-nostdinc++') - + if skip_nocxxinc: + skip_list.append('-nostdinc++') + for flag in skip_list: if flag in cflags: cflags.remove(flag) @@ -67,7 +67,7 @@ def main(): '-fsanitize=', '-fsanitize-coverage=', '-fsanitize-blacklist=', - '--system-header-prefix', + '--system-header-prefix', ] for prefix in skip_prefix_list: cflags = [i for i in cflags if not i.startswith(prefix)] @@ -83,49 +83,49 @@ def main(): cflags = filter(good, cflags) cpp_args = [] - compiler_args = [] - - # NVCC requires particular MSVC versions which may differ from the version - # used to compile regular C++ code. We have a separate MSVC in Arcadia for - # the CUDA builds and pass it's root in $Y_VC_Root. - # The separate MSVC for CUDA may absent in Yandex Open Source builds. - vc_root = os.environ.get('Y_VC_Root') - - cflags_queue = collections.deque(cflags) - while cflags_queue: - - arg = cflags_queue.popleft() + compiler_args = [] + + # NVCC requires particular MSVC versions which may differ from the version + # used to compile regular C++ code. We have a separate MSVC in Arcadia for + # the CUDA builds and pass it's root in $Y_VC_Root. + # The separate MSVC for CUDA may absent in Yandex Open Source builds. + vc_root = os.environ.get('Y_VC_Root') + + cflags_queue = collections.deque(cflags) + while cflags_queue: + + arg = cflags_queue.popleft() if arg == '-mllvm': compiler_args.append(arg) compiler_args.append(cflags_queue.popleft()) continue if arg[:2].upper() in ('-I', '/I', '-B'): - value = arg[2:] - if not value: - value = cflags_queue.popleft() + value = arg[2:] + if not value: + value = cflags_queue.popleft() if arg[1] == 'I': cpp_args.append('-I{}'.format(value)) elif arg[1] == 'B': # todo: delete "B" flag check when cuda stop to use gcc pass continue - - match = re.match(r'[-/]D(.*)', arg) - if match: - define = match.group(1) - # We have C++ flags configured for the regular C++ build. - # There is Y_MSVC_INCLUDE define with a path to the VC header files. - # We need to change the path accordingly when using a separate MSVC for CUDA. - if vc_root and define.startswith('Y_MSVC_INCLUDE'): - define = os.path.expandvars('Y_MSVC_INCLUDE={}/include'.format(vc_root)) - cpp_args.append('-D' + define.replace('\\', '/')) + + match = re.match(r'[-/]D(.*)', arg) + if match: + define = match.group(1) + # We have C++ flags configured for the regular C++ build. + # There is Y_MSVC_INCLUDE define with a path to the VC header files. + # We need to change the path accordingly when using a separate MSVC for CUDA. + if vc_root and define.startswith('Y_MSVC_INCLUDE'): + define = os.path.expandvars('Y_MSVC_INCLUDE={}/include'.format(vc_root)) + cpp_args.append('-D' + define.replace('\\', '/')) continue - + compiler_args.append(arg) - + command += cpp_args if compiler_args: command += ['--compiler-options', ','.join(compiler_args)] - + # --keep is necessary to prevent nvcc from embedding nvcc pid in generated # symbols. It makes nvcc use the original file name as the prefix in the # generated files (otherwise it also prepends tmpxft_{pid}_00000000-5), and @@ -142,11 +142,11 @@ def main(): os.environ['TZ'] = 'UTC0' # POSIX fixed offset format. os.environ['TZDIR'] = '/var/empty' # Against counterfeit /usr/share/zoneinfo/$TZ. - if dump_args: - sys.stdout.write('\n'.join(command)) - else: + if dump_args: + sys.stdout.write('\n'.join(command)) + else: sys.exit(subprocess.Popen(command, stdout=sys.stderr, stderr=sys.stderr, cwd='/').wait()) - - -if __name__ == '__main__': - main() + + +if __name__ == '__main__': + main() diff --git a/build/scripts/custom_link_green_mysql.py b/build/scripts/custom_link_green_mysql.py index 81d57b1f11..13bb9e4ac7 100644 --- a/build/scripts/custom_link_green_mysql.py +++ b/build/scripts/custom_link_green_mysql.py @@ -1,97 +1,97 @@ -import os -import shutil -import subprocess -import sys -import tempfile - - -SYMBOLS_TO_PATCH = ( - 'connect', - 'poll', - 'recv', - 'recvfrom', - 'send', - 'sendto', -) - -class Error(Exception): - pass - - -def find_compiler(args): - for arg in args: - if os.path.basename(arg) in ('clang', 'clang++'): - return arg - raise Error('No known compiler found in the command line') - - -def find_libraries(project, args): - if not project.endswith('/'): - project = project + '/' - - for arg in args: - if arg.startswith(project): - yield arg - - -def rename_symbol(symbol): - return 'green_{}'.format(symbol) - - -def patch_object(object_path, objcopy): - args = [objcopy] - for symbol in SYMBOLS_TO_PATCH: - args.extend(('--redefine-sym', '{}={}'.format(symbol, rename_symbol(symbol)))) - args.append(object_path) - subprocess.check_call(args) - - -def patch_library(library_path, ar, objcopy): - tmpdir = tempfile.mkdtemp(dir=os.path.dirname(library_path)) - try: - subprocess.check_call((ar, 'x', library_path), cwd=tmpdir) - names = os.listdir(tmpdir) - for name in names: - patch_object(os.path.join(tmpdir, name), objcopy=objcopy) - - new_library_path = os.path.join(tmpdir, 'library.a') - subprocess.check_call([ar, 'rcs', new_library_path] + names, cwd=tmpdir) - - os.rename(new_library_path, library_path) - - finally: - shutil.rmtree(tmpdir) - - -def main(): - try: - args = sys.argv[1:] - compiler = find_compiler(args) - compiler_dir = os.path.dirname(compiler) - - def get_tool(name): - path = os.path.join(compiler_dir, name) - if not os.path.exists(path): - raise Error('No {} found alongside the compiler'.format(name)) - return path - - ar = get_tool('llvm-ar') - objcopy = get_tool('llvm-objcopy') - - libraries = tuple(find_libraries('contrib/libs/libmysql_r', args)) - for library in libraries: - library_path = os.path.abspath(library) - if not os.path.exists(library_path): - raise Error('No {} file exists'.format(library)) - - patch_library(library_path, ar=ar, objcopy=objcopy) - - except Exception as error: - name = os.path.basename(sys.argv[0]) - command = ' '.join(args) - message = '{name} failed: {error}\nCommand line: {command}' - print >> sys.stderr, message.format(**locals()) - - -if __name__ == '__main__': - main() +import os +import shutil +import subprocess +import sys +import tempfile + + +SYMBOLS_TO_PATCH = ( + 'connect', + 'poll', + 'recv', + 'recvfrom', + 'send', + 'sendto', +) + +class Error(Exception): + pass + + +def find_compiler(args): + for arg in args: + if os.path.basename(arg) in ('clang', 'clang++'): + return arg + raise Error('No known compiler found in the command line') + + +def find_libraries(project, args): + if not project.endswith('/'): + project = project + '/' + + for arg in args: + if arg.startswith(project): + yield arg + + +def rename_symbol(symbol): + return 'green_{}'.format(symbol) + + +def patch_object(object_path, objcopy): + args = [objcopy] + for symbol in SYMBOLS_TO_PATCH: + args.extend(('--redefine-sym', '{}={}'.format(symbol, rename_symbol(symbol)))) + args.append(object_path) + subprocess.check_call(args) + + +def patch_library(library_path, ar, objcopy): + tmpdir = tempfile.mkdtemp(dir=os.path.dirname(library_path)) + try: + subprocess.check_call((ar, 'x', library_path), cwd=tmpdir) + names = os.listdir(tmpdir) + for name in names: + patch_object(os.path.join(tmpdir, name), objcopy=objcopy) + + new_library_path = os.path.join(tmpdir, 'library.a') + subprocess.check_call([ar, 'rcs', new_library_path] + names, cwd=tmpdir) + + os.rename(new_library_path, library_path) + + finally: + shutil.rmtree(tmpdir) + + +def main(): + try: + args = sys.argv[1:] + compiler = find_compiler(args) + compiler_dir = os.path.dirname(compiler) + + def get_tool(name): + path = os.path.join(compiler_dir, name) + if not os.path.exists(path): + raise Error('No {} found alongside the compiler'.format(name)) + return path + + ar = get_tool('llvm-ar') + objcopy = get_tool('llvm-objcopy') + + libraries = tuple(find_libraries('contrib/libs/libmysql_r', args)) + for library in libraries: + library_path = os.path.abspath(library) + if not os.path.exists(library_path): + raise Error('No {} file exists'.format(library)) + + patch_library(library_path, ar=ar, objcopy=objcopy) + + except Exception as error: + name = os.path.basename(sys.argv[0]) + command = ' '.join(args) + message = '{name} failed: {error}\nCommand line: {command}' + print >> sys.stderr, message.format(**locals()) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/link_dyn_lib.py b/build/scripts/link_dyn_lib.py index cd31592997..23487f5c1e 100644 --- a/build/scripts/link_dyn_lib.py +++ b/build/scripts/link_dyn_lib.py @@ -133,7 +133,7 @@ def fix_cmd(arch, musl, c): f = fix_windows_param else: prefix = '-Wl,--version-script=' - if arch in ('DARWIN', 'IOS'): + if arch in ('DARWIN', 'IOS'): f = fix_darwin_param else: f = lambda x: fix_gnu_param(arch, x) diff --git a/build/scripts/link_exe.py b/build/scripts/link_exe.py index 8919ec1642..f469e3b442 100644 --- a/build/scripts/link_exe.py +++ b/build/scripts/link_exe.py @@ -47,8 +47,8 @@ def parse_args(): parser = optparse.OptionParser() parser.disable_interspersed_args() parser.add_option('--musl', action='store_true') - parser.add_option('--custom-step') - parser.add_option('--python') + parser.add_option('--custom-step') + parser.add_option('--python') parser.add_option('--source-root') parser.add_option('--arch') parser.add_option('--linker-output') @@ -63,9 +63,9 @@ if __name__ == '__main__': cmd = fix_cmd(opts.musl, args) cmd = ProcessWholeArchiveOption(opts.arch, opts.whole_archive_peers, opts.whole_archive_libs).construct_cmd(cmd) - if opts.custom_step: - assert opts.python - subprocess.check_call([opts.python] + [opts.custom_step] + args) + if opts.custom_step: + assert opts.python + subprocess.check_call([opts.python] + [opts.custom_step] + args) supp, cmd = get_leaks_suppressions(cmd) if supp: diff --git a/build/scripts/link_fat_obj.py b/build/scripts/link_fat_obj.py index c21a6f4cd8..c189668b9e 100644 --- a/build/scripts/link_fat_obj.py +++ b/build/scripts/link_fat_obj.py @@ -4,10 +4,10 @@ import sys from process_whole_archive_option import ProcessWholeArchiveOption -YA_ARG_PREFIX = '-Ya,' - - -def get_args(): +YA_ARG_PREFIX = '-Ya,' + + +def get_args(): parser = argparse.ArgumentParser() parser.add_argument('--obj') parser.add_argument('--globals-lib') @@ -17,9 +17,9 @@ def get_args(): parser.add_argument('--with-own-obj', action='store_true', default=False) parser.add_argument('--with-global-srcs', action='store_true', default=False) - groups = {} - args_list = groups.setdefault('default', []) - for arg in sys.argv[1:]: + groups = {} + args_list = groups.setdefault('default', []) + for arg in sys.argv[1:]: if arg == '--with-own-obj': groups['default'].append(arg) elif arg == '--globals-lib': @@ -27,40 +27,40 @@ def get_args(): elif arg == '--with-global-srcs': groups['default'].append(arg) elif arg.startswith(YA_ARG_PREFIX): - group_name = arg[len(YA_ARG_PREFIX):] - args_list = groups.setdefault(group_name, []) - else: - args_list.append(arg) - - return parser.parse_args(groups['default']), groups - - + group_name = arg[len(YA_ARG_PREFIX):] + args_list = groups.setdefault(group_name, []) + else: + args_list.append(arg) + + return parser.parse_args(groups['default']), groups + + def strip_suppression_files(srcs): return [s for s in srcs if not s.endswith('.supp')] -def main(): - args, groups = get_args() - - # Inputs - auto_input = groups['input'] - - # Outputs +def main(): + args, groups = get_args() + + # Inputs + auto_input = groups['input'] + + # Outputs lib_output = args.lib obj_output = args.obj - - # Dependencies - global_srcs = groups['global_srcs'] + + # Dependencies + global_srcs = groups['global_srcs'] global_srcs = strip_suppression_files(global_srcs) global_srcs = ProcessWholeArchiveOption(args.arch).construct_cmd(global_srcs) - peers = groups['peers'] - - # Tools - linker = groups['linker'] - archiver = groups['archiver'] - + peers = groups['peers'] + + # Tools + linker = groups['linker'] + archiver = groups['archiver'] + do_link = linker + ['-o', obj_output, '-Wl,-r', '-nodefaultlibs', '-nostartfiles'] + global_srcs + auto_input - do_archive = archiver + [lib_output] + peers + do_archive = archiver + [lib_output] + peers do_globals = None if args.globals_lib: do_globals = archiver + [args.globals_lib] + auto_input + global_srcs @@ -84,8 +84,8 @@ def main(): if glob_res: sys.exit(glob_res) - sys.exit(call(do_archive)) - - -if __name__ == '__main__': - main() + sys.exit(call(do_archive)) + + +if __name__ == '__main__': + main() diff --git a/build/scripts/link_lib.py b/build/scripts/link_lib.py index 2e66d21500..344d50d4eb 100644 --- a/build/scripts/link_lib.py +++ b/build/scripts/link_lib.py @@ -32,9 +32,9 @@ class Opts(object): self.objs = auto_input self.libs = [] - self.plugin_flags = ['--plugin', self.plugin] if self.plugin != 'None' else [] + self.plugin_flags = ['--plugin', self.plugin] if self.plugin != 'None' else [] + - def get_opts(args): return Opts(args) @@ -42,12 +42,12 @@ def get_opts(args): if __name__ == "__main__": opts = get_opts(sys.argv[1:]) - # There is a bug in llvm-ar. Some files with size slightly greater 2^32 - # still have GNU format instead of GNU64 and cause link problems. - # Workaround just lowers llvm-ar's GNU64 threshold to 2^31. - if opts.arch_type == 'LLVM_AR': - os.environ['SYM64_THRESHOLD'] = '31' - + # There is a bug in llvm-ar. Some files with size slightly greater 2^32 + # still have GNU format instead of GNU64 and cause link problems. + # Workaround just lowers llvm-ar's GNU64 threshold to 2^31. + if opts.arch_type == 'LLVM_AR': + os.environ['SYM64_THRESHOLD'] = '31' + def call(): try: p = subprocess.Popen(cmd, stdin=stdin, cwd=opts.build_root) @@ -62,7 +62,7 @@ if __name__ == "__main__": pass if not opts.libs: - cmd = [opts.archiver] + opts.create_flags + opts.plugin_flags + [opts.output] + opts.objs + cmd = [opts.archiver] + opts.create_flags + opts.plugin_flags + [opts.output] + opts.objs stdin = None exit_code = call() else: @@ -76,7 +76,7 @@ if __name__ == "__main__": tmp.write('ADDMOD {0}\n'.format(obj)) tmp.write('SAVE\n') tmp.write('END\n') - cmd = [opts.archiver] + opts.modify_flags + opts.plugin_flags + cmd = [opts.archiver] + opts.modify_flags + opts.plugin_flags stdin = open(temp.name) exit_code = call() os.remove(temp.name) diff --git a/build/scripts/run_msvc_wine.py b/build/scripts/run_msvc_wine.py index 4779a868cd..439d1f8831 100644 --- a/build/scripts/run_msvc_wine.py +++ b/build/scripts/run_msvc_wine.py @@ -6,7 +6,7 @@ import signal import time import json import argparse -import errno +import errno import process_command_files as pcf import process_whole_archive_option as pwa @@ -55,20 +55,20 @@ def subst_path(l): def call_wine_cmd_once(wine, cmd, env, mode): p = run_subprocess(wine + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env, close_fds=True, shell=False) - output = find_cmd_out(cmd) - error = None - if output is not None and os.path.exists(output): - try: - os.remove(output) - except OSError as e: - if e.errno != errno.ENOENT: - error = e - except Exception as e: - error = e - - if error is not None: - print >> sys.stderr, 'Output {} already exists and we have failed to remove it: {}'.format(output, error) - + output = find_cmd_out(cmd) + error = None + if output is not None and os.path.exists(output): + try: + os.remove(output) + except OSError as e: + if e.errno != errno.ENOENT: + error = e + except Exception as e: + error = e + + if error is not None: + print >> sys.stderr, 'Output {} already exists and we have failed to remove it: {}'.format(output, error) + # print >>sys.stderr, cmd, env, wine stdout_and_stderr, _ = p.communicate() @@ -360,7 +360,7 @@ def make_full_path_arg(arg, bld_root, short_root): return arg def fix_path(p): - topdirs = ['/%s/' % d for d in os.listdir('/')] + topdirs = ['/%s/' % d for d in os.listdir('/')] def abs_path_start(path, pos): if pos < 0: return False @@ -482,7 +482,7 @@ def run_main(): log = colorize(log) print >>sys.stderr, log - tout = 200 + tout = 200 while True: rc, out = run_process(0, tout) @@ -525,12 +525,12 @@ def run_main(): def main(): - prefix_suffix = os.environ.pop('WINEPREFIX_SUFFIX', None) - if prefix_suffix is not None: - prefix = os.environ.pop('WINEPREFIX', None) - if prefix is not None: - os.environ['WINEPREFIX'] = os.path.join(prefix, prefix_suffix) - + prefix_suffix = os.environ.pop('WINEPREFIX_SUFFIX', None) + if prefix_suffix is not None: + prefix = os.environ.pop('WINEPREFIX', None) + if prefix is not None: + os.environ['WINEPREFIX'] = os.path.join(prefix, prefix_suffix) + # just in case signal.alarm(2000) |