Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Unified Diff: pydir/build-pnacl-ir.py

Issue 551723003: Subzero: Make python clean up after itself by removing its /tmp subdir. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Import errno for good measure Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pydir/build-pnacl-ir.py
diff --git a/pydir/build-pnacl-ir.py b/pydir/build-pnacl-ir.py
index 5c4c9e816b2c61cbd078517c31f2133d637658ea..96b4741f68165322f577cf2dc3493cdc0b70df95 100755
--- a/pydir/build-pnacl-ir.py
+++ b/pydir/build-pnacl-ir.py
@@ -1,7 +1,9 @@
#!/usr/bin/env python2
import argparse
+import errno
import os
+import shutil
import tempfile
from utils import shellcmd
from utils import FindBaseNaCl
@@ -21,18 +23,25 @@ if __name__ == '__main__':
nacl_root + '/toolchain/linux_x86/pnacl_newlib/bin' + os.pathsep +
os.pathsep + os.environ['PATH'])
- tempdir = tempfile.mkdtemp()
+ try:
+ tempdir = tempfile.mkdtemp()
- for cname in args.cfile:
- basename = os.path.splitext(cname)[0]
- llname = os.path.join(tempdir, basename + '.ll')
- pnaclname = basename + '.pnacl.ll'
- pnaclname = os.path.join(args.dir, pnaclname)
+ for cname in args.cfile:
+ basename = os.path.splitext(cname)[0]
+ llname = os.path.join(tempdir, basename + '.ll')
+ pnaclname = basename + '.pnacl.ll'
+ pnaclname = os.path.join(args.dir, pnaclname)
- shellcmd('pnacl-clang -O2 -c {0} -o {1}'.format(cname, llname))
- shellcmd('pnacl-opt ' +
- '-pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt' +
- ('' if args.disable_verify else
- ' -verify-pnaclabi-module -verify-pnaclabi-functions') +
- ' -pnaclabi-allow-debug-metadata'
- ' {0} -S -o {1}'.format(llname, pnaclname))
+ shellcmd('pnacl-clang -O2 -c {0} -o {1}'.format(cname, llname))
+ shellcmd('pnacl-opt ' +
+ '-pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt' +
+ ('' if args.disable_verify else
+ ' -verify-pnaclabi-module -verify-pnaclabi-functions') +
+ ' -pnaclabi-allow-debug-metadata'
+ ' {0} -S -o {1}'.format(llname, pnaclname))
+ finally:
+ try:
+ shutil.rmtree(tempdir)
+ except OSError as exc:
+ if exc.errno != errno.ENOENT: # ENOENT - no such file or directory
+ raise # re-raise exception
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698