diff options
author | tekireeva <tekireeva@yandex-team.ru> | 2022-02-10 16:51:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:51:38 +0300 |
commit | 569c3cefb9e9785ef25d8a067c01ea66ffa8deef (patch) | |
tree | ab7fbbf3253d4c0e2793218f09378908beb025fb /build/scripts | |
parent | e9d6dd2e511aaaec9e6182b7ae9327dce82a051d (diff) | |
download | ydb-569c3cefb9e9785ef25d8a067c01ea66ffa8deef.tar.gz |
Restoring authorship annotation for <tekireeva@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts')
-rw-r--r-- | build/scripts/fix_msvc_output.py | 10 | ||||
-rw-r--r-- | build/scripts/fs_tools.py | 8 | ||||
-rw-r--r-- | build/scripts/gen_join_srcs.py | 8 | ||||
-rw-r--r-- | build/scripts/go_tool.py | 16 | ||||
-rw-r--r-- | build/scripts/link_dyn_lib.py | 12 | ||||
-rw-r--r-- | build/scripts/link_exe.py | 22 | ||||
-rw-r--r-- | build/scripts/link_fat_obj.py | 10 | ||||
-rw-r--r-- | build/scripts/process_command_files.py | 66 | ||||
-rw-r--r-- | build/scripts/process_whole_archive_option.py | 340 | ||||
-rw-r--r-- | build/scripts/run_msvc_wine.py | 104 |
10 files changed, 298 insertions, 298 deletions
diff --git a/build/scripts/fix_msvc_output.py b/build/scripts/fix_msvc_output.py index 7248434b5ba..b2e7d38307c 100644 --- a/build/scripts/fix_msvc_output.py +++ b/build/scripts/fix_msvc_output.py @@ -1,8 +1,8 @@ import subprocess import sys -import process_command_files as pcf -import process_whole_archive_option as pwa +import process_command_files as pcf +import process_whole_archive_option as pwa def out2err(cmd): return subprocess.Popen(cmd, stdout=sys.stderr).wait() @@ -32,9 +32,9 @@ def out2err_cut_first_line(cmd): if __name__ == '__main__': - mode = sys.argv[1] - args, wa_peers, wa_libs = pwa.get_whole_archive_peers_and_libs(pcf.skip_markers(sys.argv[2:])) - cmd = pwa.ProcessWholeArchiveOption('WINDOWS', wa_peers, wa_libs).construct_cmd(args) + mode = sys.argv[1] + args, wa_peers, wa_libs = pwa.get_whole_archive_peers_and_libs(pcf.skip_markers(sys.argv[2:])) + cmd = pwa.ProcessWholeArchiveOption('WINDOWS', wa_peers, wa_libs).construct_cmd(args) run = out2err if mode in ('cl', 'ml'): # First line of cl.exe and ml64.exe stdout is useless: it prints input file diff --git a/build/scripts/fs_tools.py b/build/scripts/fs_tools.py index 1a999f2cf02..dec4c349c89 100644 --- a/build/scripts/fs_tools.py +++ b/build/scripts/fs_tools.py @@ -6,9 +6,9 @@ import sys import shutil import errno -import process_command_files as pcf - - +import process_command_files as pcf + + def link_or_copy(src, dst): try: if platform.system().lower() == 'windows': @@ -25,7 +25,7 @@ def link_or_copy(src, dst): if __name__ == '__main__': mode = sys.argv[1] - args = pcf.get_args(sys.argv[2:]) + args = pcf.get_args(sys.argv[2:]) if mode == 'copy': shutil.copy(args[0], args[1]) diff --git a/build/scripts/gen_join_srcs.py b/build/scripts/gen_join_srcs.py index 0071801f902..e0c2df161a7 100644 --- a/build/scripts/gen_join_srcs.py +++ b/build/scripts/gen_join_srcs.py @@ -1,8 +1,8 @@ import sys -import process_command_files as pcf +import process_command_files as pcf + - with open(sys.argv[1], 'w') as f: f.write('#if defined(__GNUC__)\n') f.write('#pragma GCC diagnostic ignored "-Wunknown-pragmas"\n') @@ -12,5 +12,5 @@ with open(sys.argv[1], 'w') as f: f.write('#pragma GCC diagnostic ignored "-Wsubobject-linkage"\n') f.write('#endif\n\n') - for arg in pcf.iter_args(sys.argv[2:]): - f.write('#include "' + arg + '"\n') + for arg in pcf.iter_args(sys.argv[2:]): + f.write('#include "' + arg + '"\n') diff --git a/build/scripts/go_tool.py b/build/scripts/go_tool.py index 43e0010dd12..c1e98b20c0b 100644 --- a/build/scripts/go_tool.py +++ b/build/scripts/go_tool.py @@ -13,9 +13,9 @@ import threading import six from functools import reduce -import process_command_files as pcf -import process_whole_archive_option as pwa - +import process_command_files as pcf +import process_whole_archive_option as pwa + arc_project_prefix = 'a.yandex-team.ru/' std_lib_prefix = 'contrib/go/_std/src/' vendor_prefix = 'vendor/' @@ -115,9 +115,9 @@ def preprocess_args(args): srcs.append(f) args.srcs = srcs - if args.extldflags: - args.extldflags = pwa.ProcessWholeArchiveOption(args.targ_os).construct_cmd(args.extldflags) - + if args.extldflags: + args.extldflags = pwa.ProcessWholeArchiveOption(args.targ_os).construct_cmd(args.extldflags) + classify_srcs(args.srcs, args) @@ -780,7 +780,7 @@ def do_link_test(args): if __name__ == '__main__': - args = pcf.get_args(sys.argv[1:]) + args = pcf.get_args(sys.argv[1:]) parser = argparse.ArgumentParser(prefix_chars='+') parser.add_argument('++mode', choices=['dll', 'exe', 'lib', 'test'], required=True) @@ -825,7 +825,7 @@ if __name__ == '__main__': parser.add_argument('++debug-root-map', default=None) parser.add_argument('++embed', action='append', nargs='*') parser.add_argument('++embed_xtest', action='append', nargs='*') - args = parser.parse_args(args) + args = parser.parse_args(args) arc_project_prefix = args.arc_project_prefix std_lib_prefix = args.std_lib_prefix diff --git a/build/scripts/link_dyn_lib.py b/build/scripts/link_dyn_lib.py index 59606145d4d..23487f5c1ef 100644 --- a/build/scripts/link_dyn_lib.py +++ b/build/scripts/link_dyn_lib.py @@ -6,9 +6,9 @@ import collections import optparse import pipes -from process_whole_archive_option import ProcessWholeArchiveOption +from process_whole_archive_option import ProcessWholeArchiveOption + - def shlex_join(cmd): # equivalent to shlex.join() in python 3 return ' '.join( @@ -147,7 +147,7 @@ def fix_cmd(arch, musl, c): return list(f(list(parse_export_file(fname)))) - if p.endswith('.supp'): + if p.endswith('.supp'): return [] if p.endswith('.pkg.fake'): @@ -167,8 +167,8 @@ def parse_args(): parser.add_option('--fix-elf') parser.add_option('--linker-output') parser.add_option('--musl', action='store_true') - parser.add_option('--whole-archive-peers', action='append') - parser.add_option('--whole-archive-libs', action='append') + parser.add_option('--whole-archive-peers', action='append') + parser.add_option('--whole-archive-libs', action='append') return parser.parse_args() @@ -179,7 +179,7 @@ if __name__ == '__main__': assert opts.target cmd = fix_cmd(opts.arch, opts.musl, args) - cmd = ProcessWholeArchiveOption(opts.arch, opts.whole_archive_peers, opts.whole_archive_libs).construct_cmd(cmd) + cmd = ProcessWholeArchiveOption(opts.arch, opts.whole_archive_peers, opts.whole_archive_libs).construct_cmd(cmd) if opts.linker_output: stdout = open(opts.linker_output, 'w') diff --git a/build/scripts/link_exe.py b/build/scripts/link_exe.py index c4319c4cb9e..f469e3b442a 100644 --- a/build/scripts/link_exe.py +++ b/build/scripts/link_exe.py @@ -2,13 +2,13 @@ import sys import subprocess import optparse -from process_whole_archive_option import ProcessWholeArchiveOption +from process_whole_archive_option import ProcessWholeArchiveOption + - def get_leaks_suppressions(cmd): supp, newcmd = [], [] for arg in cmd: - if arg.endswith(".supp"): + if arg.endswith(".supp"): supp.append(arg) else: newcmd.append(arg) @@ -22,14 +22,14 @@ def fix_cmd(musl, c): return [i for i in c if (not musl or i not in musl_libs) and not i.endswith('.ios.interface') and not i.endswith('.pkg.fake')] -def gen_default_suppressions(inputs, output, source_root): +def gen_default_suppressions(inputs, output, source_root): import collections import os supp_map = collections.defaultdict(set) for filename in inputs: sanitizer = os.path.basename(filename).split('.', 1)[0] - with open(os.path.join(source_root, filename)) as src: + with open(os.path.join(source_root, filename)) as src: for line in src: line = line.strip() if not line or line.startswith('#'): @@ -49,11 +49,11 @@ def parse_args(): parser.add_option('--musl', action='store_true') parser.add_option('--custom-step') parser.add_option('--python') - parser.add_option('--source-root') - parser.add_option('--arch') + parser.add_option('--source-root') + parser.add_option('--arch') parser.add_option('--linker-output') - parser.add_option('--whole-archive-peers', action='append') - parser.add_option('--whole-archive-libs', action='append') + parser.add_option('--whole-archive-peers', action='append') + parser.add_option('--whole-archive-libs', action='append') return parser.parse_args() @@ -61,7 +61,7 @@ if __name__ == '__main__': opts, args = parse_args() cmd = fix_cmd(opts.musl, args) - cmd = ProcessWholeArchiveOption(opts.arch, opts.whole_archive_peers, opts.whole_archive_libs).construct_cmd(cmd) + cmd = ProcessWholeArchiveOption(opts.arch, opts.whole_archive_peers, opts.whole_archive_libs).construct_cmd(cmd) if opts.custom_step: assert opts.python @@ -70,7 +70,7 @@ if __name__ == '__main__': supp, cmd = get_leaks_suppressions(cmd) if supp: src_file = "default_suppressions.cpp" - gen_default_suppressions(supp, src_file, opts.source_root) + gen_default_suppressions(supp, src_file, opts.source_root) cmd += [src_file] if opts.linker_output: diff --git a/build/scripts/link_fat_obj.py b/build/scripts/link_fat_obj.py index 32083628983..c189668b9e0 100644 --- a/build/scripts/link_fat_obj.py +++ b/build/scripts/link_fat_obj.py @@ -2,8 +2,8 @@ import argparse import subprocess import sys -from process_whole_archive_option import ProcessWholeArchiveOption - +from process_whole_archive_option import ProcessWholeArchiveOption + YA_ARG_PREFIX = '-Ya,' @@ -36,7 +36,7 @@ def get_args(): def strip_suppression_files(srcs): - return [s for s in srcs if not s.endswith('.supp')] + return [s for s in srcs if not s.endswith('.supp')] def main(): @@ -52,14 +52,14 @@ def main(): # Dependencies global_srcs = groups['global_srcs'] global_srcs = strip_suppression_files(global_srcs) - global_srcs = ProcessWholeArchiveOption(args.arch).construct_cmd(global_srcs) + global_srcs = ProcessWholeArchiveOption(args.arch).construct_cmd(global_srcs) 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_link = linker + ['-o', obj_output, '-Wl,-r', '-nodefaultlibs', '-nostartfiles'] + global_srcs + auto_input do_archive = archiver + [lib_output] + peers do_globals = None if args.globals_lib: diff --git a/build/scripts/process_command_files.py b/build/scripts/process_command_files.py index 82626187ded..28accfc175e 100644 --- a/build/scripts/process_command_files.py +++ b/build/scripts/process_command_files.py @@ -1,33 +1,33 @@ -import sys - - -def is_cmdfile_arg(arg): - return arg.startswith('@') - -def cmdfile_path(arg): - return arg[1:] - -def read_from_command_file(arg): - with open(arg) as afile: - return afile.read().splitlines() - -def skip_markers(args): - res = [] - for arg in args: - if arg == '--ya-start-command-file' or arg == '--ya-end-command-file': - continue - res.append(arg) - return res - -def iter_args(args): - for arg in args: - if not is_cmdfile_arg(arg): - if arg == '--ya-start-command-file' or arg == '--ya-end-command-file': - continue - yield arg - else: - for cmdfile_arg in read_from_command_file(cmdfile_path(arg)): - yield cmdfile_arg - -def get_args(args): - return list(iter_args(args)) +import sys + + +def is_cmdfile_arg(arg): + return arg.startswith('@') + +def cmdfile_path(arg): + return arg[1:] + +def read_from_command_file(arg): + with open(arg) as afile: + return afile.read().splitlines() + +def skip_markers(args): + res = [] + for arg in args: + if arg == '--ya-start-command-file' or arg == '--ya-end-command-file': + continue + res.append(arg) + return res + +def iter_args(args): + for arg in args: + if not is_cmdfile_arg(arg): + if arg == '--ya-start-command-file' or arg == '--ya-end-command-file': + continue + yield arg + else: + for cmdfile_arg in read_from_command_file(cmdfile_path(arg)): + yield cmdfile_arg + +def get_args(args): + return list(iter_args(args)) diff --git a/build/scripts/process_whole_archive_option.py b/build/scripts/process_whole_archive_option.py index 017706b232a..a9c4ef676aa 100644 --- a/build/scripts/process_whole_archive_option.py +++ b/build/scripts/process_whole_archive_option.py @@ -1,176 +1,176 @@ -import os -import sys - -import process_command_files as pcf - - -class ProcessWholeArchiveOption(): - def __init__(self, arch, peers=None, libs=None): - self.arch = arch.upper() - self.peers = { x : 0 for x in peers } if peers else None - self.libs = { x : 0 for x in libs } if libs else None - self.start_wa_marker = '--start-wa' - self.end_wa_marker = '--end-wa' - +import os +import sys + +import process_command_files as pcf + + +class ProcessWholeArchiveOption(): + def __init__(self, arch, peers=None, libs=None): + self.arch = arch.upper() + self.peers = { x : 0 for x in peers } if peers else None + self.libs = { x : 0 for x in libs } if libs else None + self.start_wa_marker = '--start-wa' + self.end_wa_marker = '--end-wa' + def _match_peer_lib(self, arg, ext): - key = None + key = None if arg.endswith(ext): - key = os.path.dirname(arg) - return key if key and self.peers and key in self.peers else None - - def _match_lib(self, arg): - return arg if self.libs and arg in self.libs else None - + key = os.path.dirname(arg) + return key if key and self.peers and key in self.peers else None + + def _match_lib(self, arg): + return arg if self.libs and arg in self.libs else None + def _process_arg(self, arg, ext='.a'): peer_key = self._match_peer_lib(arg, ext) - lib_key = self._match_lib(arg) - if peer_key: - self.peers[peer_key] += 1 - if lib_key: - self.libs[lib_key] += 1 - return peer_key if peer_key else lib_key - - def _check_peers(self): - if self.peers: - for key, value in self.peers.items(): - assert value > 0, '"{}" specified in WHOLE_ARCHIVE() macro is not used on link command'.format(key) - - def _construct_cmd_apple(self, args): - force_load_flag = '-Wl,-force_load,' - is_inside_wa_markers = False - - cmd = [] - for arg in args: - if arg.startswith(force_load_flag): - cmd.append(arg) - elif arg == self.start_wa_marker: - is_inside_wa_markers = True - elif arg == self.end_wa_marker: - is_inside_wa_markers = False - elif is_inside_wa_markers: - cmd.append(force_load_flag + arg) - else: - key = self._process_arg(arg) - cmd.append(force_load_flag + arg if key else arg) - - self._check_peers() - - return cmd - - def _construct_cmd_win(self, args): - whole_archive_prefix = '/WHOLEARCHIVE:' - is_inside_wa_markers = False - - def add_prefix(arg, need_check_peers_and_libs): + lib_key = self._match_lib(arg) + if peer_key: + self.peers[peer_key] += 1 + if lib_key: + self.libs[lib_key] += 1 + return peer_key if peer_key else lib_key + + def _check_peers(self): + if self.peers: + for key, value in self.peers.items(): + assert value > 0, '"{}" specified in WHOLE_ARCHIVE() macro is not used on link command'.format(key) + + def _construct_cmd_apple(self, args): + force_load_flag = '-Wl,-force_load,' + is_inside_wa_markers = False + + cmd = [] + for arg in args: + if arg.startswith(force_load_flag): + cmd.append(arg) + elif arg == self.start_wa_marker: + is_inside_wa_markers = True + elif arg == self.end_wa_marker: + is_inside_wa_markers = False + elif is_inside_wa_markers: + cmd.append(force_load_flag + arg) + else: + key = self._process_arg(arg) + cmd.append(force_load_flag + arg if key else arg) + + self._check_peers() + + return cmd + + def _construct_cmd_win(self, args): + whole_archive_prefix = '/WHOLEARCHIVE:' + is_inside_wa_markers = False + + def add_prefix(arg, need_check_peers_and_libs): key = self._process_arg(arg, '.lib') if need_check_peers_and_libs else arg - return whole_archive_prefix + arg if key else arg - - def add_whole_archive_prefix(arg, need_check_peers_and_libs): - if not pcf.is_cmdfile_arg(arg): - return add_prefix(arg, need_check_peers_and_libs) - - cmd_file_path = pcf.cmdfile_path(arg) - cf_args = pcf.read_from_command_file(cmd_file_path) - with open(cmd_file_path, 'w') as afile: - for cf_arg in cf_args: - afile.write(add_prefix(cf_arg, need_check_peers_and_libs) + "\n") - return arg - - cmd = [] - for arg in args: - if arg == self.start_wa_marker: - is_inside_wa_markers = True - elif arg == self.end_wa_marker: - is_inside_wa_markers = False - elif is_inside_wa_markers: - cmd.append(add_whole_archive_prefix(arg, False)) - continue - elif self.peers or self.libs: - cmd.append(add_whole_archive_prefix(arg, True)) - else: - cmd.append(arg) - - self._check_peers() - - return cmd - - def _construct_cmd_linux(self, args): - whole_archive_flag = '-Wl,--whole-archive' - no_whole_archive_flag = '-Wl,--no-whole-archive' - - def replace_markers(arg): - if arg == self.start_wa_marker: - return whole_archive_flag - if arg == self.end_wa_marker: - return no_whole_archive_flag - return arg - - args = [replace_markers(arg) for arg in args] - - cmd = [] - is_inside_whole_archive = False - is_whole_archive = False - # We are trying not to create excessive sequences of consecutive flags - # -Wl,--no-whole-archive -Wl,--whole-archive ('externally' specified - # flags -Wl,--[no-]whole-archive are not taken for consideration in this - # optimization intentionally) - for arg in args: - if arg == whole_archive_flag: - is_inside_whole_archive = True - is_whole_archive = False - elif arg == no_whole_archive_flag: - is_inside_whole_archive = False - is_whole_archive = False - else: - key = self._process_arg(arg) - if not is_inside_whole_archive: - if key: - if not is_whole_archive: - cmd.append(whole_archive_flag) - is_whole_archive = True - elif is_whole_archive: - cmd.append(no_whole_archive_flag) - is_whole_archive = False - - cmd.append(arg) - - if is_whole_archive: - cmd.append(no_whole_archive_flag) - - self._check_peers() - - return cmd - - def construct_cmd(self, args): + return whole_archive_prefix + arg if key else arg + + def add_whole_archive_prefix(arg, need_check_peers_and_libs): + if not pcf.is_cmdfile_arg(arg): + return add_prefix(arg, need_check_peers_and_libs) + + cmd_file_path = pcf.cmdfile_path(arg) + cf_args = pcf.read_from_command_file(cmd_file_path) + with open(cmd_file_path, 'w') as afile: + for cf_arg in cf_args: + afile.write(add_prefix(cf_arg, need_check_peers_and_libs) + "\n") + return arg + + cmd = [] + for arg in args: + if arg == self.start_wa_marker: + is_inside_wa_markers = True + elif arg == self.end_wa_marker: + is_inside_wa_markers = False + elif is_inside_wa_markers: + cmd.append(add_whole_archive_prefix(arg, False)) + continue + elif self.peers or self.libs: + cmd.append(add_whole_archive_prefix(arg, True)) + else: + cmd.append(arg) + + self._check_peers() + + return cmd + + def _construct_cmd_linux(self, args): + whole_archive_flag = '-Wl,--whole-archive' + no_whole_archive_flag = '-Wl,--no-whole-archive' + + def replace_markers(arg): + if arg == self.start_wa_marker: + return whole_archive_flag + if arg == self.end_wa_marker: + return no_whole_archive_flag + return arg + + args = [replace_markers(arg) for arg in args] + + cmd = [] + is_inside_whole_archive = False + is_whole_archive = False + # We are trying not to create excessive sequences of consecutive flags + # -Wl,--no-whole-archive -Wl,--whole-archive ('externally' specified + # flags -Wl,--[no-]whole-archive are not taken for consideration in this + # optimization intentionally) + for arg in args: + if arg == whole_archive_flag: + is_inside_whole_archive = True + is_whole_archive = False + elif arg == no_whole_archive_flag: + is_inside_whole_archive = False + is_whole_archive = False + else: + key = self._process_arg(arg) + if not is_inside_whole_archive: + if key: + if not is_whole_archive: + cmd.append(whole_archive_flag) + is_whole_archive = True + elif is_whole_archive: + cmd.append(no_whole_archive_flag) + is_whole_archive = False + + cmd.append(arg) + + if is_whole_archive: + cmd.append(no_whole_archive_flag) + + self._check_peers() + + return cmd + + def construct_cmd(self, args): if self.arch in ('DARWIN', 'IOS', 'IOSSIM'): - return self._construct_cmd_apple(args) - - if self.arch == 'WINDOWS': - return self._construct_cmd_win(args) - - return self._construct_cmd_linux(args) - - -def get_whole_archive_peers_and_libs(args): - remaining_args = [] - peers = [] - libs = [] - peers_flag = '--whole-archive-peers' - libs_flag = '--whole-archive-libs' - - next_is_peer = False - next_is_lib = False - for arg in args: - if arg == peers_flag: - next_is_peer = True - elif arg == libs_flag: - next_is_lib = True - elif next_is_peer: - peers.append(arg) - next_is_peer = False - elif next_is_lib: - libs.append(arg) - next_is_lib = False - else: - remaining_args.append(arg) - return remaining_args, peers, libs + return self._construct_cmd_apple(args) + + if self.arch == 'WINDOWS': + return self._construct_cmd_win(args) + + return self._construct_cmd_linux(args) + + +def get_whole_archive_peers_and_libs(args): + remaining_args = [] + peers = [] + libs = [] + peers_flag = '--whole-archive-peers' + libs_flag = '--whole-archive-libs' + + next_is_peer = False + next_is_lib = False + for arg in args: + if arg == peers_flag: + next_is_peer = True + elif arg == libs_flag: + next_is_lib = True + elif next_is_peer: + peers.append(arg) + next_is_peer = False + elif next_is_lib: + libs.append(arg) + next_is_lib = False + else: + remaining_args.append(arg) + return remaining_args, peers, libs diff --git a/build/scripts/run_msvc_wine.py b/build/scripts/run_msvc_wine.py index 5aadae6a459..439d1f88316 100644 --- a/build/scripts/run_msvc_wine.py +++ b/build/scripts/run_msvc_wine.py @@ -8,10 +8,10 @@ import json import argparse import errno -import process_command_files as pcf -import process_whole_archive_option as pwa +import process_command_files as pcf +import process_whole_archive_option as pwa + - procs = [] build_kekeke = 45 @@ -359,56 +359,56 @@ def make_full_path_arg(arg, bld_root, short_root): return os.path.join(short_root, arg) return arg -def fix_path(p): +def fix_path(p): topdirs = ['/%s/' % d for d in os.listdir('/')] def abs_path_start(path, pos): if pos < 0: return False return pos == 0 or path[pos - 1] == ':' - pp = None - for pr in topdirs: - pp2 = p.find(pr) - if abs_path_start(p, pp2) and (pp is None or pp > pp2): - pp = pp2 - if pp is not None: - return p[:pp] + 'Z:' + p[pp:].replace('/', '\\') - if p.startswith('/Fo'): - return '/Fo' + p[3:].replace('/', '\\') - return p - -def process_free_args(args, wine, bld_root, mode): - whole_archive_prefix = '/WHOLEARCHIVE:' - short_names = {} - winepath = os.path.join(os.path.dirname(wine), 'winepath') - short_names[bld_root] = trim_path(bld_root, winepath) - # Slow for no benefit. - # arc_root = args.arcadia_root - # short_names[arc_root] = trim_path(arc_root, winepath) - - free_args, wa_peers, wa_libs = pwa.get_whole_archive_peers_and_libs(pcf.skip_markers(args)) - - process_link = lambda x: make_full_path_arg(x, bld_root, short_names[bld_root]) if mode in ('link', 'lib') else x - def process_arg(arg): - with_wa_prefix = arg.startswith(whole_archive_prefix) - prefix = whole_archive_prefix if with_wa_prefix else '' - without_prefix_arg = arg[len(prefix):] - return prefix + fix_path(process_link(downsize_path(without_prefix_arg, short_names))) - - result = [] - for arg in free_args: - if pcf.is_cmdfile_arg(arg): - cmd_file_path = pcf.cmdfile_path(arg) - cf_args = pcf.read_from_command_file(cmd_file_path) - with open(cmd_file_path, 'w') as afile: - for cf_arg in cf_args: - afile.write(process_arg(cf_arg) + "\n") - result.append(arg) - else: - result.append(process_arg(arg)) - return pwa.ProcessWholeArchiveOption('WINDOWS', wa_peers, wa_libs).construct_cmd(result) - -def run_main(): + pp = None + for pr in topdirs: + pp2 = p.find(pr) + if abs_path_start(p, pp2) and (pp is None or pp > pp2): + pp = pp2 + if pp is not None: + return p[:pp] + 'Z:' + p[pp:].replace('/', '\\') + if p.startswith('/Fo'): + return '/Fo' + p[3:].replace('/', '\\') + return p + +def process_free_args(args, wine, bld_root, mode): + whole_archive_prefix = '/WHOLEARCHIVE:' + short_names = {} + winepath = os.path.join(os.path.dirname(wine), 'winepath') + short_names[bld_root] = trim_path(bld_root, winepath) + # Slow for no benefit. + # arc_root = args.arcadia_root + # short_names[arc_root] = trim_path(arc_root, winepath) + + free_args, wa_peers, wa_libs = pwa.get_whole_archive_peers_and_libs(pcf.skip_markers(args)) + + process_link = lambda x: make_full_path_arg(x, bld_root, short_names[bld_root]) if mode in ('link', 'lib') else x + def process_arg(arg): + with_wa_prefix = arg.startswith(whole_archive_prefix) + prefix = whole_archive_prefix if with_wa_prefix else '' + without_prefix_arg = arg[len(prefix):] + return prefix + fix_path(process_link(downsize_path(without_prefix_arg, short_names))) + + result = [] + for arg in free_args: + if pcf.is_cmdfile_arg(arg): + cmd_file_path = pcf.cmdfile_path(arg) + cf_args = pcf.read_from_command_file(cmd_file_path) + with open(cmd_file_path, 'w') as afile: + for cf_arg in cf_args: + afile.write(process_arg(cf_arg) + "\n") + result.append(arg) + else: + result.append(process_arg(arg)) + return pwa.ProcessWholeArchiveOption('WINDOWS', wa_peers, wa_libs).construct_cmd(result) + +def run_main(): parser = argparse.ArgumentParser() parser.add_argument('wine', action='store') parser.add_argument('-v', action='store', dest='version', default='120') @@ -418,8 +418,8 @@ def run_main(): 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 - args = parser.parse_args() + # By now just unpack. Ideally we should fix path and pack arguments back into command file + args = parser.parse_args() wine = args.wine mode = args.mode @@ -427,7 +427,7 @@ def run_main(): version = args.version incl_paths = args.incl_paths bld_root = args.arcadia_build_root - free_args = args.free_args + free_args = args.free_args wine_dir = os.path.dirname(os.path.dirname(wine)) bin_dir = os.path.dirname(binary) @@ -435,7 +435,7 @@ def run_main(): if not incl_paths: incl_paths = [tc_dir + '/VC/include', tc_dir + '/include'] - cmd_out = find_cmd_out(free_args) + cmd_out = find_cmd_out(free_args) env = os.environ.copy() @@ -451,7 +451,7 @@ def run_main(): env['LIB'] = fix_path(tc_dir + '/VC/lib/amd64') 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) + cmd = [binary] + process_free_args(free_args, wine, bld_root, mode) for x in ('/NOLOGO', '/nologo', '/FD'): try: |