aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-04-08 22:46:49 +0300
committerJukka Jylänki <jujjyl@gmail.com>2013-04-11 10:42:16 +0300
commit5351b86b0768813c4c18bb61494c43b07bc00372 (patch)
tree2a212179ad24ebfa9050f0d7eeecd37fdff8eae8
parent829add1ee972bc3f68cc065c5e9b69b8a6e3fa5c (diff)
Don't require response files to end with '.rsp'. Only autodelete response files that end with the suffix '.tmp'. Use the suffix '.tmp' for all internally utilized response files.
-rw-r--r--tools/response_file.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/response_file.py b/tools/response_file.py
index cb368d47..29756833 100644
--- a/tools/response_file.py
+++ b/tools/response_file.py
@@ -1,10 +1,11 @@
import tempfile, os, sys, shlex
from tempfiles import try_delete
-# Routes the given cmdline param list in args into a new .rsp file and returns the filename to it.
+# Routes the given cmdline param list in args into a new response file and returns the filename to it.
+# The response file has a suffix '.tmp' to signal that the process receiving the response file is free to delete it after it has consumed it.
# The returned filename has '@' prepended to it already for convenience.
def create_response_file(args, directory):
- (response_fd, response_filename) = tempfile.mkstemp(prefix='emscripten_', suffix='.rsp', dir=directory, text=True)
+ (response_fd, response_filename) = tempfile.mkstemp(prefix='emscripten_', suffix='.tmp', dir=directory, text=True)
response_fd = os.fdopen(response_fd, "w")
#print >> sys.stderr, "Creating response file '%s'" % response_filename
args = map(lambda p: p.replace(' ', '').replace('\\', '\\\\').replace('"', '\\"'), args)
@@ -12,12 +13,11 @@ def create_response_file(args, directory):
response_fd.close()
return '@' + response_filename
-# Reads and deletes a .rsp file, and returns the list of cmdline params found in the file.
+# Reads a response file, and returns the list of cmdline params found in the file.
+# If the response file ends with .tmp, it is automatically deleted after reading it.
def read_and_delete_response_file(response_filename):
- # Ensure safety so that this function can never accidentally delete any non-.rsp files if things go wrong!
- if not (response_filename.startswith('@') and response_filename.endswith('.rsp')):
- raise Exception("'%s' is not a valid response file name! Response file names must start with '@' and end in '.rsp'!" % response_filename)
- response_filename = response_filename[1:]
+ if response_filename.startswith('@'):
+ response_filename = response_filename[1:]
#print >> sys.stderr, "Using response file '%s'" % response_filename
if not os.path.exists(response_filename):
@@ -26,6 +26,9 @@ def read_and_delete_response_file(response_filename):
response_fd = open(response_filename, 'r')
args = response_fd.read()
response_fd.close()
- try_delete(response_filename)
+ # For conveniency, the receiver is allowed to immediately clean up response files ending with '.tmp' so that the
+ # caller doesn't have to do it.
+ if response_filename.endswith(".tmp"):
+ try_delete(response_filename)
args = shlex.split(args)
return args