source: rtems-tools/rtemstoolkit/solaris.py @ 3618a62

Last change on this file since 3618a62 was 7d3350d, checked in by Chris Johns <chrisj@…>, on Apr 24, 2017 at 2:31:44 PM

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.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#
21# This code is based on what ever doco about spec files I could find and
22# RTEMS project's spec files.
23#
24
25import os
26
27try:
28    from . import check
29    from . import error
30    from . import execute
31except (ValueError, SystemError):
32    import check
33    import error
34    import execute
35
36def cpus():
37    psrinfo = '/sbin/psrinfo|wc -l'
38    e = execute.capture_execution()
39    exit_code, proc, output = e.shell(psrinfo)
40    if exit_code == 0:
41        ncpus = int(output)
42    else:
43        ncpus = 1
44    return ncpus
45
46def overrides():
47    uname = os.uname()
48    ncpus = '%d' % (cpus())
49    if uname[4] == 'i86pc':
50        cpu = 'i386'
51    else:
52        cpu = uname[4]
53    version = uname[2]
54    if version.find('-') > 0:
55        version = version.split('-')[0]
56    defines = {
57        '_ncpus':           ('none',    'none',     ncpus),
58        '_os':              ('none',    'none',     'solaris'),
59        '_host':            ('triplet', 'required', cpu + '-pc-solaris2'),
60        '_host_vendor':     ('none',    'none',     'pc'),
61        '_host_os':         ('none',    'none',     'solaris'),
62        '_host_os_version': ('none',    'none',     version),
63        '_host_cpu':        ('none',    'none',     cpu),
64        '_host_alias':      ('none',    'none',     '%{nil}'),
65        '_host_arch':       ('none',    'none',     cpu),
66        '_usr':             ('dir',     'required', '/usr'),
67        '_var':             ('dir',     'optional', '/var'),
68        '__bash':           ('exe',     'optional', '/usr/bin/bash'),
69        '__bison':          ('exe',     'required', '/usr/bin/bison'),
70        '__git':            ('exe',     'required', '/usr/bin/git'),
71        '__svn':            ('exe',     'required', '/usr/bin/svn'),
72        '__cvs':            ('exe',     'required', '/usr/bin/cvs'),
73        '__xz':             ('exe',     'optional', '/usr/bin/xz'),
74        '__make':           ('exe',     'required', 'gmake'),
75        '__patch_opts':     ('none',     'none',    '-E'),
76        '__chown':          ('exe',     'required', '/usr/bin/chown'),
77        '__install':        ('exe',     'required', '/usr/bin/ginstall'),
78        '__cc':             ('exe',     'required', '/usr/bin/gcc'),
79        '__cxx':            ('exe',     'required', '/usr/bin/g++'),
80        'with_iconv':       ('none',    'none',     '0')
81        }
82
83    defines['_build']        = defines['_host']
84    defines['_build_vendor'] = defines['_host_vendor']
85    defines['_build_os']     = defines['_host_os']
86    defines['_build_cpu']    = defines['_host_cpu']
87    defines['_build_alias']  = defines['_host_alias']
88    defines['_build_arch']   = defines['_host_arch']
89
90    return defines
91
92if __name__ == '__main__':
93    import pprint
94    pprint.pprint(cpus())
95    pprint.pprint(overrides())
Note: See TracBrowser for help on using the repository browser.