1
import tempfile, os, sys, shlex
3
# Routes the given cmdline param list in args into a new response file and returns the filename to it.
4
# The returned filename has a suffix '.rsp'.
5
def create_response_file(args, directory):
6
(response_fd, response_filename) = tempfile.mkstemp(prefix='emscripten_', suffix='.rsp', dir=directory, text=True)
7
response_fd = os.fdopen(response_fd, "w")
8
#print >> sys.stderr, "Creating response file '%s'" % response_filename
9
args = map(lambda p: p.replace(' ', '').replace('\\', '\\\\').replace('"', '\\"'), args)
10
response_fd.write(' '.join(args))
12
return response_filename
14
# Reads a response file, and returns the list of cmdline params found in the file.
15
# The parameter response_filename may start with '@'.
16
def read_response_file(response_filename):
17
if response_filename.startswith('@'):
18
response_filename = response_filename[1:]
20
#print >> sys.stderr, "Using response file '%s'" % response_filename
21
if not os.path.exists(response_filename):
22
raise Exception("Response file '%s' not found!" % response_filename)
24
response_fd = open(response_filename, 'r')
25
args = response_fd.read()
27
args = shlex.split(args)