diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-07-19 13:09:43 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-09-14 07:11:32 +0200 |
commit | f3f0370f1054f4e49aa8f5ea70485d673e8e94b6 (patch) | |
tree | 11d44920353aea9bf4301eb267f8c831e622520e /long_gcc.py | |
parent | i386/score: fix assembly mnemonic (diff) | |
download | rtems-f3f0370f1054f4e49aa8f5ea70485d673e8e94b6.tar.bz2 |
build: Alternative build system based on waf
Update #3818.
Diffstat (limited to 'long_gcc.py')
-rw-r--r-- | long_gcc.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/long_gcc.py b/long_gcc.py new file mode 100644 index 0000000000..20ca2a7f77 --- /dev/null +++ b/long_gcc.py @@ -0,0 +1,45 @@ +#! /usr/bin/env python +# encoding: utf-8 + +""" +def build(bld): + bld.load('long_gcc') +""" + +import os, tempfile +from waflib import Task + +def exec_command(self, cmd, **kw): + # workaround for command line length limit: + # http://support.microsoft.com/kb/830473 + tmp = None + try: + if not isinstance(cmd, str) and len(str(cmd)) > 8192: + (fd, tmp) = tempfile.mkstemp(dir=self.generator.bld.bldnode.abspath()) + flat = ['"%s"' % x.replace('\\', '\\\\').replace('"', '\\"') for x in cmd[1:]] + try: + os.write(fd, ' '.join(flat).encode()) + finally: + if tmp: + os.close(fd) + # Line may be very long: + # Logs.debug('runner:' + ' '.join(flat)) + cmd = [cmd[0], '@' + tmp] + ret = super(self.__class__, self).exec_command(cmd, **kw) + finally: + if tmp: + os.remove(tmp) + return ret + +def wrap_class(class_name): + cls = Task.classes.get(class_name) + if not cls: + return None + derived_class = type(class_name, (cls,), {}) + derived_class.exec_command = exec_command + if hasattr(cls, 'hcode'): + derived_class.hcode = cls.hcode + return derived_class + +for k in 'c cxx cprogram cxxprogram cshlib cxxshlib cstlib cxxstlib'.split(): + wrap_class(k) |