diff options
author | v-korovin <v-korovin@yandex-team.com> | 2024-05-23 11:11:05 +0300 |
---|---|---|
committer | v-korovin <v-korovin@yandex-team.com> | 2024-05-23 11:27:15 +0300 |
commit | fc97008d55d28660b75009eb8e95181660aa815b (patch) | |
tree | 69046b9bf3a2aa395e542122f79269d2cafb6f2a /build/scripts | |
parent | 9eb59abc0a64defc2486366760ab47c3f809e977 (diff) | |
download | ydb-fc97008d55d28660b75009eb8e95181660aa815b.tar.gz |
test
d394e1d4a37d8c9b93bc4c1feab8362a3488f41e
Diffstat (limited to 'build/scripts')
-rw-r--r-- | build/scripts/compile_java.py | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/build/scripts/compile_java.py b/build/scripts/compile_java.py index ef744afdbd..ba055d9dbf 100644 --- a/build/scripts/compile_java.py +++ b/build/scripts/compile_java.py @@ -7,6 +7,7 @@ import subprocess as sp import tarfile import zipfile import sys +import platform import process_command_files as pcf @@ -26,6 +27,33 @@ def parse_args(args): return args, args.srcs +def check_call_command_file(cmd, wrapped_args, **kwargs): + is_win = platform.system() == 'Windows' + + args = cmd + args_to_wrap = wrapped_args + if is_win: + args = [cmd[0]] + args_to_wrap = cmd[1:] + args_to_wrap + + commands_file = 'wrapped.args' + with open(commands_file, 'w') as f: + f.write(' '.join(wrapped_args)) + + if is_win: + # Windows has troubles with running cmd lines with `@` without shell=True + kwargs['shell'] = True + + try: + return sp.check_call( + args + ["@" + commands_file], + **kwargs + ) + except Exception as e: + e.args = tuple(args) + ("Original command: {} {}".format(cmd, wrapped_args), ) + raise + + def mkdir_p(directory): if not os.path.exists(directory): os.makedirs(directory) @@ -77,12 +105,10 @@ def main(): ts.write(' '.join(srcs)) if ktsrcs: - temp_kt_sources_file = 'temp.kt.sources.list' - with open(temp_kt_sources_file, 'w') as ts: - ts.write(' '.join(ktsrcs + srcs)) kt_classes_dir = 'kt_cls' mkdir_p(kt_classes_dir) - sp.check_call( + + check_call_command_file( [ opts.java_bin, '-Didea.max.content.load.filesize=30720', @@ -93,16 +119,16 @@ def main(): '-d', kt_classes_dir, ] - + ktc_opts - + ['@' + temp_kt_sources_file] + + ktc_opts, + wrapped_args=ktsrcs + srcs, ) classpath = os.pathsep.join([kt_classes_dir, classpath]) if srcs: - sp.check_call( + check_call_command_file( [opts.javac_bin, '-nowarn', '-g', '-classpath', classpath, '-encoding', 'UTF-8', '-d', classes_dir] - + javac_opts - + ['@' + temp_sources_file] + + javac_opts, + wrapped_args=srcs, ) for s in jsrcs: |