src_builder = [CFile, CXXFile])
def win32LinkGenerator(env, target, source, **kw):
- args = []
- for a in [env['LINKFLAGS'],
- '/OUT:' + str(target[0]),
- env['_LIBDIRFLAGS'],
- env['_LIBFLAGS'],
- map(lambda x: str(x), source)]:
- if SCons.Util.is_List(a):
- args.extend(a)
- else:
- args.append(a)
- argstring = string.join(args, " ")
- if len(argstring) <= 2048:
- return env['LINK'] + " " + argstring
+ cmd = env.subst_list([ '$LINK', '$LINKFLAGS', '/OUT:' + str(target[0]) ])[0]
+ cmd.extend(['$('] + env.subst_list('$_LIBDIRFLAGS')[0] + ['$)'])
+ cmd.extend(env.subst_list('$_LIBFLAGS')[0])
+ cmd.extend(map(lambda x: str(x), source))
+ cmdlen = reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)
+ if cmdlen <= 2048:
+ return [cmd]
else:
import tempfile
tmp = tempfile.mktemp()
- open(tmp, 'w').write(argstring + "\n")
- return [ env['LINK'] + " @" + tmp,
- "del " + tmp, ]
+ args = filter(lambda x: x != '$(' and x != '$)', cmd[1:])
+ args = map(SCons.Util.quote_spaces, args)
+ open(tmp, 'w').write(string.join(args, " ") + "\n")
+ return [ [cmd[0], '@' + tmp],
+ ['del', tmp] ]
kw = {
'name' : 'Program',
# suffix and basepath.
return self.__class__([ UserList.UserList.__getitem__(self, item), ])
+def quote_spaces(arg):
+ if ' ' in arg or '\t' in arg:
+ return '"%s"' % arg
+ else:
+ return arg
+
_cv = re.compile(r'\$([_a-zA-Z]\w*|{[^}]*})')
_space_sep = re.compile(r'[\t ]+(?![^{]*})')
assert len(cmd_list) == 1, cmd_list
assert cmd_list[0] == ['test', '3', '2', '4', 'test'], cmd_list
-
-
+ def test_quote_spaces(self):
+ """Testing the quote_spaces() method..."""
+ q = quote_spaces('x')
+ assert q == 'x', q
+
+ q = quote_spaces('x x')
+ assert q == '"x x"', q
+
+ q = quote_spaces('x\tx')
+ assert q == '"x\tx"', q
def test_render_tree(self):
class Node:
linkflags = r'%s'
while len(linkflags) <= 8100:
linkflags = linkflags + r' %s'
-env = Environment(LINKFLAGS = linkflags)
+env = Environment(LINKFLAGS = '$LINKXXX', LINKXXX = linkflags)
env.Program(target = 'foo', source = 'foo.c')
""" % (linkflag, linkflag))