source: rtems/long_gcc.py @ d03776e

Last change on this file since d03776e was f3f0370f, checked in by Sebastian Huber <sebastian.huber@…>, on 07/19/19 at 11:09:43

build: Alternative build system based on waf

Update #3818.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#! /usr/bin/env python
2# encoding: utf-8
3
4"""
5def build(bld):
6        bld.load('long_gcc')
7"""
8
9import os, tempfile
10from waflib import Task
11
12def 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
34def 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
44for 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.