diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /build/scripts/fix_msvc_output.py | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'build/scripts/fix_msvc_output.py')
-rw-r--r-- | build/scripts/fix_msvc_output.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/build/scripts/fix_msvc_output.py b/build/scripts/fix_msvc_output.py new file mode 100644 index 00000000000..b2e7d38307c --- /dev/null +++ b/build/scripts/fix_msvc_output.py @@ -0,0 +1,42 @@ +import subprocess +import sys + +import process_command_files as pcf +import process_whole_archive_option as pwa + +def out2err(cmd): + return subprocess.Popen(cmd, stdout=sys.stderr).wait() + + +def decoding_needed(strval): + if sys.version_info >= (3, 0, 0): + return isinstance(strval, bytes) + else: + return False + + +def out2err_cut_first_line(cmd): + p = subprocess.Popen(cmd, stdout=subprocess.PIPE) + first_line = True + while True: + line = p.stdout.readline() + line = line.decode('utf-8') if decoding_needed(line) else line + if not line: + break + if first_line: + sys.stdout.write(line) + first_line = False + else: + sys.stderr.write(line) + return p.wait() + + +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) + run = out2err + if mode in ('cl', 'ml'): + # First line of cl.exe and ml64.exe stdout is useless: it prints input file + run = out2err_cut_first_line + sys.exit(run(cmd)) |