summaryrefslogtreecommitdiffstats
path: root/tools/gypv8sh.py
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-18 18:15:19 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-18 18:15:19 +0000
commit4f6b1db0d960ca6531a8a320c5cda768ee86f1f0 (patch)
treec111d57fca126d3167a70920661e052544d3dfa8 /tools/gypv8sh.py
parent08d3076893dae11db3b2bb6d047b11b02002388d (diff)
downloadchromium_src-4f6b1db0d960ca6531a8a320c5cda768ee86f1f0.zip
chromium_src-4f6b1db0d960ca6531a8a320c5cda768ee86f1f0.tar.gz
chromium_src-4f6b1db0d960ca6531a8a320c5cda768ee86f1f0.tar.bz2
Make gypv8sh.py compatible with ninja on Windows.
This is because python's subprocess.py excepts GetStdHandle(STD_INPUT_HANDLE) to return a valid handle and it seems ninja on Windows doesn't give one, causing the subprocess.call() to fail unless we request stdin to be redirected. Also fix file handle lifetime in gypv8sh.py When an exception is thrown, the file handle could still be open, causing an exception while trying to remove it in the exception handler due to file locking on Windows. Note that the exception being generated is another problem but this exception in the exception handler was masking the original error. R=scr@chromium.org BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10388191 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137902 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gypv8sh.py')
-rwxr-xr-xtools/gypv8sh.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/tools/gypv8sh.py b/tools/gypv8sh.py
index 7018db9..c45dbfd 100755
--- a/tools/gypv8sh.py
+++ b/tools/gypv8sh.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -11,16 +11,14 @@ Usage:
inputfile inputrelfile cxxoutfile jsoutfile
"""
-try:
- import json
-except ImportError:
- import simplejson as json
+import json
import optparse
import os
import subprocess
import sys
import shutil
+
def main ():
parser = optparse.OptionParser()
parser.set_usage(
@@ -42,13 +40,16 @@ def main ():
print cmd
if not opts.impotent:
try:
- subprocess.check_call(cmd, stdout=open(cxxoutfile, 'w'))
+ with open(cxxoutfile, 'w') as f:
+ subprocess.check_call(cmd, stdin=subprocess.PIPE, stdout=f)
shutil.copyfile(inputfile, jsoutfile)
except Exception, ex:
- print ex
- os.remove(cxxoutfile)
- os.remove(jsoutfile)
- sys.exit(1)
+ if os.path.exists(cxxoutfile):
+ os.remove(cxxoutfile)
+ if os.path.exists(jsoutfile):
+ os.remove(jsoutfile)
+ raise
+
if __name__ == '__main__':
sys.exit(main())