Changeset 7d3350d in rtems-tools


Ignore:
Timestamp:
Apr 24, 2017, 2:31:44 PM (2 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
master
Children:
4370924
Parents:
15a3e06
Message:

rtemstoolkit: Move host support access into a separate module.

Moving the host support into a module lets it get used where options
is not being used.

Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • rtemstoolkit/config.py

    r15a3e06 r7d3350d  
    5252    from . import error
    5353    from . import execute
     54    from . import host
    5455    from . import log
    5556    from . import options
     
    5859    import error
    5960    import execute
     61    import host
    6062    import log
    6163    import options
     
    212214            e = execute.capture_execution()
    213215            for s in sl:
    214                 if options.host_windows:
     216                if host.is_windows:
    215217                    cmd = '%s -c "%s"' % (self.macros.expand('%{__sh}'), s[2:-1])
    216218                else:
  • rtemstoolkit/darwin.py

    r15a3e06 r7d3350d  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    4545    import execute
    4646
    47 def load():
    48     uname = os.uname()
     47def cpus():
    4948    sysctl = '/usr/sbin/sysctl '
    5049    e = execute.capture_execution()
    5150    exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
    5251    if exit_code == 0:
    53         ncpus = output.split(' ')[1].strip()
     52        ncpus = int(output.split(' ')[1].strip())
    5453    else:
    55         ncpus = '1'
     54        ncpus = 1
     55    return ncpus
     56
     57def overrides():
     58    uname = os.uname()
     59    ncpus = '%d' % (cores())
    5660    defines = {
    5761        '_ncpus':         ('none',    'none',     ncpus),
     
    8488if __name__ == '__main__':
    8589    import pprint
    86     pprint.pprint(load())
     90    pprint.pprint(cpus())
     91    pprint.pprint(overrides())
  • rtemstoolkit/freebsd.py

    r15a3e06 r7d3350d  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3434#
    3535
    36 import pprint
    3736import os
    3837
     
    4847    import execute
    4948
    50 def load():
    51     uname = os.uname()
     49def cpus():
    5250    sysctl = '/sbin/sysctl '
    5351    e = execute.capture_execution()
    5452    exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
    5553    if exit_code == 0:
    56         ncpus = output.split(' ')[1].strip()
     54        ncpus = int(output.split(' ')[1].strip())
    5755    else:
    58         ncpus = '1'
     56        ncpus = 1
     57    return ncpus
     58
     59def overrides():
     60    uname = os.uname()
     61    ncpus = '%d' % (cpus())
    5962    if uname[4] == 'amd64':
    6063        cpu = 'x86_64'
     
    105108
    106109if __name__ == '__main__':
    107     pprint.pprint(load())
     110    import pprint
     111    pprint.pprint(cpus())
     112    pprint.pprint(overrides())
  • rtemstoolkit/linux.py

    r15a3e06 r7d3350d  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3434#
    3535
    36 import pprint
    3736import os
    3837import platform
     
    4948    import path
    5049
    51 def load():
    52     uname = os.uname()
    53     smp_mflags = ''
     50def cpus():
    5451    processors = '/bin/grep processor /proc/cpuinfo'
    5552    e = execute.capture_execution()
     
    6461        except:
    6562            pass
    66     ncpus = str(ncpus + 1)
     63    return ncpus + 1
     64
     65def overrides():
     66    uname = os.uname()
     67    smp_mflags = ''
     68    ncpus = '%d' % cpus()
    6769    if uname[4].startswith('arm'):
    6870        cpu = 'arm'
     
    154156
    155157if __name__ == '__main__':
    156     pprint.pprint(load())
     158    import pprint
     159    pprint.pprint(cpus())
     160    pprint.pprint(overrides())
  • rtemstoolkit/netbsd.py

    r15a3e06 r7d3350d  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    2525#
    2626
    27 import pprint
    2827import os
    2928
     
    3534    import execute
    3635
    37 def load():
    38     uname = os.uname()
     36def cpus():
    3937    sysctl = '/sbin/sysctl '
    4038    e = execute.capture_execution()
    4139    exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
    4240    if exit_code == 0:
    43         ncpus = output.split(' ')[1].strip()
     41        ncpus = int(output.split(' ')[1].strip())
    4442    else:
    45         ncpus = '1'
     43        ncpus = 1
     44    return ncpus
     45
     46def overrides():
     47    uname = os.uname()
     48    ncpus = '%d' % (cpus())
    4649    if uname[4] == 'amd64':
    4750        cpu = 'x86_64'
     
    9497
    9598if __name__ == '__main__':
    96     pprint.pprint(load())
     99    import pprint
     100    pprint.pprint(cpus())
     101    pprint.pprint(overrides())
  • rtemstoolkit/options.py

    r15a3e06 r7d3350d  
    5151    from . import execute
    5252    from . import git
     53    from . import host
    5354    from . import log
    5455    from . import macros
     
    5960    import execute
    6061    import git
     62    import host
    6163    import log
    6264    import macros
     
    6567
    6668basepath = 'tb'
    67 
    68 #
    69 # Save the host state.
    70 #
    71 host_windows = False
    7269
    7370class command_line(object):
     
    540537        raise error.general('invalid options type passed to options loader')
    541538
    542     global host_windows
    543 
    544     overrides = None
    545     if os.name == 'nt':
    546         try:
    547             import windows
    548             overrides = windows.load()
    549             host_windows = True
    550         except:
    551             raise error.general('failed to load Windows host support')
    552     elif os.name == 'posix':
    553         uname = os.uname()
    554         try:
    555             if uname[0].startswith('CYGWIN_NT'):
    556                 try:
    557                     from . import windows
    558                 except:
    559                     import windows
    560                 overrides = windows.load()
    561             elif uname[0] == 'Darwin':
    562                 try:
    563                     from . import darwin
    564                 except:
    565                     import darwin
    566                 overrides = darwin.load()
    567             elif uname[0] == 'FreeBSD':
    568                 try:
    569                     from . import freebsd
    570                 except:
    571                     import freebsd
    572                 overrides = freebsd.load()
    573             elif uname[0] == 'NetBSD':
    574                 try:
    575                     from . import netbsd
    576                 except:
    577                     import netbsd
    578                 overrides = netbsd.load()
    579             elif uname[0] == 'Linux':
    580                 try:
    581                     from . import linux
    582                 except:
    583                     import linux
    584                 overrides = linux.load()
    585             elif uname[0] == 'SunOS':
    586                 try:
    587                     from . import solaris
    588                 except:
    589                     import solaris
    590                 overrides = solaris.load()
    591         except:
    592             raise error.general('failed to load %s host support' % (uname[0]))
    593     else:
    594         raise error.general('unsupported host type; please add')
    595     if overrides is None:
    596         raise error.general('no hosts defaults found; please add')
     539    overrides = host.overrides()
    597540    for k in overrides:
    598541        opts.defaults[k] = overrides[k]
  • rtemstoolkit/solaris.py

    r15a3e06 r7d3350d  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    2323#
    2424
    25 import pprint
    2625import os
    2726
     
    3534    import execute
    3635
    37 def load():
    38     uname = os.uname()
     36def cpus():
    3937    psrinfo = '/sbin/psrinfo|wc -l'
    4038    e = execute.capture_execution()
    4139    exit_code, proc, output = e.shell(psrinfo)
    4240    if exit_code == 0:
    43         ncpus = output
     41        ncpus = int(output)
    4442    else:
    45         ncpus = '1'
     43        ncpus = 1
     44    return ncpus
     45
     46def overrides():
     47    uname = os.uname()
     48    ncpus = '%d' % (cpus())
    4649    if uname[4] == 'i86pc':
    4750        cpu = 'i386'
     
    8891
    8992if __name__ == '__main__':
    90     pprint.pprint(load())
     93    import pprint
     94    pprint.pprint(cpus())
     95    pprint.pprint(overrides())
  • rtemstoolkit/windows.py

    r15a3e06 r7d3350d  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3333#
    3434
    35 import pprint
    3635import os
    3736
     
    4746    import execute
    4847
    49 def load():
     48def cpus():
     49    if os.environ.has_key('NUMBER_OF_PROCESSORS'):
     50        ncpus = int(os.environ['NUMBER_OF_PROCESSORS'])
     51    else:
     52        ncpus = 1
     53    return ncpus
     54
     55def overrides():
    5056    # Default to the native Windows Python.
    5157    uname = 'win32'
     
    7783            pass
    7884
    79     if os.environ.has_key('NUMBER_OF_PROCESSORS'):
    80         ncpus = os.environ['NUMBER_OF_PROCESSORS']
    81     else:
    82         ncpus = '1'
     85    ncpus = '%d' % (cpus())
    8386
    8487    defines = {
     
    141144
    142145if __name__ == '__main__':
    143     pprint.pprint(load())
     146    import pprint
     147    pprint.pprint(cpus())
     148    pprint.pprint(overrides())
  • tester/rt/stty.py

    r15a3e06 r7d3350d  
    3838
    3939from rtemstoolkit import error
    40 from rtemstoolkit import options
     40from rtemstoolkit import host
    4141from rtemstoolkit import path
    4242
    4343def save():
    44     if not options.host_windows:
     44    if not host.is_windows:
    4545        try:
    4646            sin = termios.tcgetattr(sys.stdin)
     
    6161
    6262    def __init__(self, dev):
    63         if options.host_windows:
     63        if host.is_windows:
    6464            raise error.general('termios not support on host')
    6565        self.dev = dev
     
    6767        self.fd = None
    6868        self.if_on = False
    69         if options.host_windows:
     69        if host.is_windows:
    7070            raise error.general('TTY consoles not supported on Windows.')
    7171        if not path.exists(dev):
Note: See TracChangeset for help on using the changeset viewer.