aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/run_javac.py
diff options
context:
space:
mode:
authorheretic <heretic@yandex-team.ru>2022-02-10 16:45:46 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:46 +0300
commit81eddc8c0b55990194e112b02d127b87d54164a9 (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /build/scripts/run_javac.py
parent397cbe258b9e064f49c4ca575279f02f39fef76e (diff)
downloadydb-81eddc8c0b55990194e112b02d127b87d54164a9.tar.gz
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts/run_javac.py')
-rw-r--r--build/scripts/run_javac.py102
1 files changed, 51 insertions, 51 deletions
diff --git a/build/scripts/run_javac.py b/build/scripts/run_javac.py
index 0adf42a2e07..c35546e0fef 100644
--- a/build/scripts/run_javac.py
+++ b/build/scripts/run_javac.py
@@ -10,8 +10,8 @@ def parse_args():
parser.add_option('--sources-list')
parser.add_option('--verbose', default=False, action='store_true')
parser.add_option('--remove-notes', default=False, action='store_true')
- parser.add_option('--ignore-errors', default=False, action='store_true')
- parser.add_option('--kotlin', default=False, action='store_true')
+ parser.add_option('--ignore-errors', default=False, action='store_true')
+ parser.add_option('--kotlin', default=False, action='store_true')
return parser.parse_args()
@@ -42,63 +42,63 @@ def remove_notes(err):
return '\n'.join([line for line in err.split('\n') if not line.startswith('Note:')])
-def find_javac(cmd):
- if not cmd:
- return None
- if cmd[0].endswith('javac') or cmd[0].endswith('javac.exe'):
- return cmd[0]
- if len(cmd) > 2 and cmd[1].endswith('build_java_with_error_prone.py'):
- for javas in ('java', 'javac'):
- if cmd[2].endswith(javas) or cmd[2].endswith(javas + '.exe'):
- return cmd[2]
- return None
-
-
-# temporary, for jdk8/jdk9+ compatibility
-def fix_cmd(cmd):
- if not cmd:
- return cmd
- javac = find_javac(cmd)
- if not javac:
- return cmd
- p = subprocess.Popen([javac, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, err = p.communicate()
- out, err = out.strip(), err.strip()
- for prefix in ('javac 1.8', 'java version "1.8'):
- for raw_out in ((out or ''), (err or '')):
- for line in raw_out.split('\n'):
- if line.startswith(prefix):
- res = []
- i = 0
- while i < len(cmd):
- for option in ('--add-exports', '--add-modules'):
- if cmd[i] == option:
- i += 1
- break
- elif cmd[i].startswith(option + '='):
- break
- else:
- res.append(cmd[i])
- i += 1
- return res
- return cmd
-
-
+def find_javac(cmd):
+ if not cmd:
+ return None
+ if cmd[0].endswith('javac') or cmd[0].endswith('javac.exe'):
+ return cmd[0]
+ if len(cmd) > 2 and cmd[1].endswith('build_java_with_error_prone.py'):
+ for javas in ('java', 'javac'):
+ if cmd[2].endswith(javas) or cmd[2].endswith(javas + '.exe'):
+ return cmd[2]
+ return None
+
+
+# temporary, for jdk8/jdk9+ compatibility
+def fix_cmd(cmd):
+ if not cmd:
+ return cmd
+ javac = find_javac(cmd)
+ if not javac:
+ return cmd
+ p = subprocess.Popen([javac, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = p.communicate()
+ out, err = out.strip(), err.strip()
+ for prefix in ('javac 1.8', 'java version "1.8'):
+ for raw_out in ((out or ''), (err or '')):
+ for line in raw_out.split('\n'):
+ if line.startswith(prefix):
+ res = []
+ i = 0
+ while i < len(cmd):
+ for option in ('--add-exports', '--add-modules'):
+ if cmd[i] == option:
+ i += 1
+ break
+ elif cmd[i].startswith(option + '='):
+ break
+ else:
+ res.append(cmd[i])
+ i += 1
+ return res
+ return cmd
+
+
def main():
opts, cmd = parse_args()
with open(opts.sources_list) as f:
input_files = f.read().strip().split()
- if opts.kotlin:
- input_files = [i for i in input_files if i.endswith('.kt')]
-
+ if opts.kotlin:
+ input_files = [i for i in input_files if i.endswith('.kt')]
+
if not input_files:
if opts.verbose:
sys.stderr.write('No files to compile, javac is not launched.\n')
else:
- p = subprocess.Popen(fix_cmd(cmd), stderr=subprocess.PIPE)
+ p = subprocess.Popen(fix_cmd(cmd), stderr=subprocess.PIPE)
_, err = p.communicate()
rc = p.wait()
@@ -111,9 +111,9 @@ def main():
except Exception:
pass
- if opts.ignore_errors and rc:
- sys.stderr.write('error: javac actually failed with exit code {}\n'.format(rc))
- rc = 0
+ if opts.ignore_errors and rc:
+ sys.stderr.write('error: javac actually failed with exit code {}\n'.format(rc))
+ rc = 0
sys.stderr.write(err)
sys.exit(rc)