mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-02 18:11:04 +08:00
The new compiler caught a lot of pre-existing issues in the codebase. Sadly, the old compiler version was not smart enough to understand the new changes. Therefore, the changes have be included in the same CL as the compiler update. Most of the changes are related to better handling of prototype and class inheritance, as well as handling of null/undefined tracking. Change-Id: I3941a3a240a4d09c4945e1e20d2521090ef837c9 Bug: 991710 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762081 Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@google.com> Auto-Submit: Tim van der Lippe <tvanderlippe@google.com> Cr-Original-Commit-Position: refs/heads/master@{#696761} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: ca93474213278e32e36d6ace1474c56884030757
76 lines
2.2 KiB
Python
Executable File
76 lines
2.2 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
|
|
|
|
def rel_to_abs(rel_path):
|
|
return os.path.join(script_path, rel_path)
|
|
|
|
|
|
java_bin_path = os.getenv('JAVA_HOME', '')
|
|
if java_bin_path:
|
|
java_bin_path = os.path.join(java_bin_path, 'bin')
|
|
|
|
main_class = 'org.chromium.devtools.compiler.Runner'
|
|
jar_name = 'closure_runner.jar'
|
|
src_dir = 'src'
|
|
script_path = os.path.dirname(os.path.abspath(__file__))
|
|
closure_jar_relpath = os.path.join('..', 'compiler.jar')
|
|
src_path = rel_to_abs(src_dir)
|
|
|
|
|
|
def run_and_communicate(command, error_template):
|
|
proc = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
|
|
proc.communicate()
|
|
if proc.returncode:
|
|
print >> sys.stderr, error_template % proc.returncode
|
|
sys.exit(proc.returncode)
|
|
|
|
|
|
def build_artifacts():
|
|
print 'Compiling...'
|
|
java_files = []
|
|
for root, dirs, files in sorted(os.walk(src_path)):
|
|
for file_name in files:
|
|
java_files.append(os.path.join(root, file_name))
|
|
|
|
bin_path = tempfile.mkdtemp()
|
|
manifest_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
|
|
try:
|
|
manifest_file.write('Class-Path: %s\n' % closure_jar_relpath)
|
|
manifest_file.close()
|
|
javac_path = os.path.join(java_bin_path, 'javac')
|
|
javac_command = '%s -target 8 -source 8 -d %s -cp %s %s' % (javac_path, bin_path, rel_to_abs(closure_jar_relpath),
|
|
' '.join(java_files))
|
|
run_and_communicate(javac_command, 'Error: javac returned %d')
|
|
|
|
print 'Building jar...'
|
|
artifact_path = rel_to_abs(jar_name)
|
|
jar_path = os.path.join(java_bin_path, 'jar')
|
|
jar_command = '%s cvfme %s %s %s -C %s .' % (jar_path, artifact_path, manifest_file.name, main_class, bin_path)
|
|
run_and_communicate(jar_command, 'Error: jar returned %d')
|
|
finally:
|
|
os.remove(manifest_file.name)
|
|
shutil.rmtree(bin_path, True)
|
|
|
|
|
|
def help():
|
|
print 'usage: %s' % os.path.basename(__file__)
|
|
print 'Builds closure_runner.jar from the %s directory contents' % src_dir
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) > 1:
|
|
help()
|
|
return
|
|
build_artifacts()
|
|
print 'Done.'
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|