Line | |
---|
1 | #! /usr/bin/env python |
---|
2 | # encoding: utf-8 |
---|
3 | |
---|
4 | """ |
---|
5 | def build(bld): |
---|
6 | bld.load('long_gcc') |
---|
7 | """ |
---|
8 | |
---|
9 | import os, tempfile |
---|
10 | from waflib import Task |
---|
11 | |
---|
12 | def exec_command(self, cmd, **kw): |
---|
13 | # workaround for command line length limit: |
---|
14 | # http://support.microsoft.com/kb/830473 |
---|
15 | tmp = None |
---|
16 | try: |
---|
17 | if not isinstance(cmd, str) and len(str(cmd)) > 8192: |
---|
18 | (fd, tmp) = tempfile.mkstemp(dir=self.generator.bld.bldnode.abspath()) |
---|
19 | flat = ['"%s"' % x.replace('\\', '\\\\').replace('"', '\\"') for x in cmd[1:]] |
---|
20 | try: |
---|
21 | os.write(fd, ' '.join(flat).encode()) |
---|
22 | finally: |
---|
23 | if tmp: |
---|
24 | os.close(fd) |
---|
25 | # Line may be very long: |
---|
26 | # Logs.debug('runner:' + ' '.join(flat)) |
---|
27 | cmd = [cmd[0], '@' + tmp] |
---|
28 | ret = super(self.__class__, self).exec_command(cmd, **kw) |
---|
29 | finally: |
---|
30 | if tmp: |
---|
31 | os.remove(tmp) |
---|
32 | return ret |
---|
33 | |
---|
34 | def wrap_class(class_name): |
---|
35 | cls = Task.classes.get(class_name) |
---|
36 | if not cls: |
---|
37 | return None |
---|
38 | derived_class = type(class_name, (cls,), {}) |
---|
39 | derived_class.exec_command = exec_command |
---|
40 | if hasattr(cls, 'hcode'): |
---|
41 | derived_class.hcode = cls.hcode |
---|
42 | return derived_class |
---|
43 | |
---|
44 | for k in 'c cxx cprogram cxxprogram cshlib cxxshlib cstlib cxxstlib'.split(): |
---|
45 | wrap_class(k) |
---|
Note: See
TracBrowser
for help on using the repository browser.