diff options
author | Jamie Gennis <jgennis@google.com> | 2012-05-22 16:29:02 -0700 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2012-05-23 15:15:56 -0700 |
commit | 50dfd0660916e38f7e186b97be4b5b1a1a693a8a (patch) | |
tree | 440842d7317eba2c7840d00033e750b33453cc53 /update.py | |
parent | a2e0cfb86bdd7702e54374ecfcf6834720474b6c (diff) | |
download | chromium-trace-50dfd0660916e38f7e186b97be4b5b1a1a693a8a.tar.gz |
systrace: check for errors when compiling JS
Change-Id: I0daba4b5977734ce819451dd9200317d7e0c4ca9
Diffstat (limited to 'update.py')
-rwxr-xr-x | update.py | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -1,6 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/python2.6 -import httplib, urllib, subprocess, sys, config +import config, httplib, json, urllib, subprocess, sys # Read all the Javascript files. js_code = [('js_code', open(f).read()) for f in config.js_in_files] @@ -13,7 +13,8 @@ css_code = ''.join(open(f).read() for f in config.css_in_files) params = urllib.urlencode(js_code + [ ('language', 'ECMASCRIPT5'), ('compilation_level', 'SIMPLE_OPTIMIZATIONS'), - ('output_format', 'text'), + ('output_format', 'json'), + ('output_info', 'errors'), ('output_info', 'compiled_code'), ]) @@ -29,8 +30,20 @@ if response.status != 200: print sys.stderr, "error returned from JS compile service: %d" % response.status sys.exit(1) -open(config.js_out_file, 'wt').write(data) -print 'Generated %s. Check the file to see if errors occured!' % config.js_out_file +result = json.loads(data) +if 'errors' in result: + for e in result['errors']: + filenum = int(e['file'][6:]) + filename = js_in_files[filenum] + lineno = e['lineno'] + charno = e['charno'] + err = e['error'] + print '%s:%d:%d: %s' % (filename, lineno, charno, err) + print 'Failed to generate %s.' % config.js_out_file + sys.exit(1) + +open(config.js_out_file, 'wt').write(result['compiledCode'] + '\n') +print 'Generated %s' % config.js_out_file yuic_args = ['yui-compressor', '--type', 'css', '-o', config.css_out_file] p = subprocess.Popen(yuic_args, stdin=subprocess.PIPE) @@ -39,4 +52,4 @@ if p.wait() != 0: print 'Failed to generate %s.' % config.css_out_file sys.exit(1) -print 'Generated %s.' % config.css_out_file +print 'Generated %s' % config.css_out_file |