Changeset 1aef190 in rtems_waf


Ignore:
Timestamp:
Jun 16, 2016, 3:28:52 AM (3 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
master
Children:
eb6ff97
Parents:
b0afac0
Message:

Add long command line support for gcc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtems.py

    rb0afac0 r1aef190  
    3636rtems_default_version = None
    3737rtems_filters = None
     38rtems_long_commands = False
    3839
    3940def options(opt):
     
    6465                   help = 'Print the commands as strings.')
    6566
    66 def init(ctx, filters = None, version = None):
     67def init(ctx, filters = None, version = None, long_commands = False):
    6768    global rtems_filters
    6869    global rtems_default_version
     70    global rtems_long_commands
    6971
    7072    #
     
    7779    #
    7880    rtems_default_version = version
     81
     82    #
     83    # Set the long commands option.
     84    #
     85    rtems_long_commands = long_commands
    7986
    8087    try:
     
    137144
    138145    #
    139     # Handle the show commands option.
     146    # Handle the configurable commands options.
    140147    #
    141148    if conf.options.show_commands:
     
    143150    else:
    144151        show_commands = 'no'
     152    if rtems_long_commands and os.name == 'nt':
     153        long_commands = 'yes'
     154    else:
     155        long_commands = 'no'
    145156
    146157    rtems_version, rtems_path, rtems_bin, rtems_tools, archs, arch_bsps = \
     
    168179
    169180        conf.msg('Board Support Package', ab, 'YELLOW')
     181
     182        #
     183        # Show and long commands support.
     184        #
     185        conf.env.SHOW_COMMANDS = show_commands
     186        conf.env.LONG_COMMANDS = long_commands
     187
     188        conf.msg('Show commands', show_commands)
     189        conf.msg('Long commands', long_commands)
    170190
    171191        arch = _arch_from_arch_bsp(ab)
     
    251271            bsp_configure(conf, ab)
    252272
    253         #
    254         # Show commands support the user can supply.
    255         #
    256         conf.env.SHOW_COMMANDS = show_commands
    257 
    258273        conf.setenv('', env)
    259274
     
    263278
    264279    conf.env.SHOW_COMMANDS = show_commands
     280    conf.env.LONG_COMMANDS = long_commands
    265281
    266282def build(bld):
    267283    if bld.env.SHOW_COMMANDS == 'yes':
    268284        output_command_line()
     285    if bld.env.LONG_COMMANDS == 'yes':
     286        long_command_line()
    269287
    270288def load_cpuopts(conf, arch_bsp, rtems_path):
     
    548566            Logs.info('%s' % cmd)
    549567        else:
    550             Logs.info('%s' % ' '.join(cmd)) # here is the change
     568            cmd = ' '.join(cmd)
     569            Logs.info('(%d) %s' % (len(cmd), cmd)) # here is the change
    551570        Logs.debug('runner_env: kw=%s' % kw)
    552571        try:
     
    574593
    575594    Task.__str__ = display
     595
     596#
     597# From the extras. Use this to support long command lines.
     598#
     599def long_command_line():
     600    def exec_command(self, cmd, **kw):
     601        # workaround for command line length limit:
     602        # http://support.microsoft.com/kb/830473
     603        import tempfile
     604        tmp = None
     605        try:
     606            if not isinstance(cmd, str) and len(str(cmd)) > 8192:
     607                (fd, tmp) = tempfile.mkstemp(dir=self.generator.bld.bldnode.abspath())
     608                flat = ['"%s"' % x.replace('\\', '\\\\').replace('"', '\\"') for x in cmd[1:]]
     609                try:
     610                    os.write(fd, ' '.join(flat).encode())
     611                finally:
     612                    if tmp:
     613                        os.close(fd)
     614                # Line may be very long:
     615                # Logs.debug('runner:' + ' '.join(flat))
     616                cmd = [cmd[0], '@' + tmp]
     617            ret = super(self.__class__, self).exec_command(cmd, **kw)
     618        finally:
     619            if tmp:
     620                os.remove(tmp)
     621        return ret
     622    for k in 'c cxx cprogram cxxprogram cshlib cxxshlib cstlib cxxstlib'.split():
     623        cls = Task.classes.get(k)
     624        if cls:
     625            derived_class = type(k, (cls,), {})
     626            derived_class.exec_command = exec_command
     627            if hasattr(cls, 'hcode'):
     628                derived_class.hcode = cls.hcode
    576629
    577630def _find_tools(conf, arch, paths, tools):
Note: See TracChangeset for help on using the changeset viewer.