source: rtems-tools/rtemstoolkit/netbsd.py

Last change on this file was 7e5cdea, checked in by Chris Johns <chrisj@…>, on 11/23/18 at 04:02:52

rtemstoolkit: Add unit testing for the python modules

  • Add support to run the unit tests for the rtemstoolkit python modules from waf. Enter './waf test' for the tests to be run on python2 and python3.
  • Update the importing of rtemstoolkit modules to the standard method which works on python2 and python3.
  • Update the README.
  • Property mode set to 100644
File size: 3.5 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# RTEMS Tools is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# RTEMS Tools is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with RTEMS Tools.  If not, see <http://www.gnu.org/licenses/>.
20#
21
22#
23# This code is based on what ever doco about spec files I could find and
24# RTEMS project's spec files.
25#
26
27import os
28
29from rtemstoolkit import check
30from rtemstoolkit import execute
31
32def cpus():
33    sysctl = '/sbin/sysctl '
34    e = execute.capture_execution()
35    exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
36    if exit_code == 0:
37        ncpus = int(output.split(' ')[1].strip())
38    else:
39        ncpus = 1
40    return ncpus
41
42def overrides():
43    uname = os.uname()
44    ncpus = '%d' % (cpus())
45    if uname[4] == 'amd64':
46        cpu = 'x86_64'
47    else:
48        cpu = uname[4]
49    version = uname[2]
50    if version.find('-') > 0:
51        version = version.split('-')[0]
52    defines = {
53        '_ncpus':            ('none',    'none',    '1'),
54        '_os':               ('none',    'none',     'netbsd'),
55        '_host':             ('triplet', 'required', cpu + '-netbsd' + version),
56        '_host_vendor':      ('none',    'none',     'pc'),
57        '_host_os':          ('none',    'none',     'netbsd'),
58        '_host_os_version':  ('none',    'none',     version),
59        '_host_cpu':         ('none',    'none',     cpu),
60        '_host_alias':       ('none',    'none',     '%{nil}'),
61        '_host_arch':        ('none',    'none',     cpu),
62        '_usr':              ('dir',     'required', '/usr'),
63        '_var':              ('dir',     'optional', '/var'),
64        'optincludes_build': ('none',    'none',     '-I/usr/pkg/include -L/usr/pkg/lib'),
65        '__bash':            ('exe',     'optional', '/usr/pkg/bin/bash'),
66        '__bison':           ('exe',     'required', '/usr/pkg/bin/bison'),
67        '__git':             ('exe',     'required', '/usr/pkg/bin/git'),
68        '__svn':             ('exe',     'required', '/usr/pkg/bin/svn'),
69        '__xz':              ('exe',     'optional', '/usr/pkg/bin/xz'),
70        '__make':            ('exe',     'required', 'gmake'),
71        '__patch_opts':      ('none',     'none',    '-E')
72        }
73
74    defines['_build']        = defines['_host']
75    defines['_build_vendor'] = defines['_host_vendor']
76    defines['_build_os']     = defines['_host_os']
77    defines['_build_cpu']    = defines['_host_cpu']
78    defines['_build_alias']  = defines['_host_alias']
79    defines['_build_arch']   = defines['_host_arch']
80
81    for gv in ['47', '48', '49']:
82        gcc = '%s-portbld-netbsd%s-gcc%s' % (cpu, version, gv)
83        if check.check_exe(gcc, gcc):
84            defines['__cc'] = gcc
85            break
86    for gv in ['47', '48', '49']:
87        gxx = '%s-portbld-netbsd%s-g++%s' % (cpu, version, gv)
88        if check.check_exe(gxx, gxx):
89            defines['__cxx'] = gxx
90            break
91
92    return defines
93
94if __name__ == '__main__':
95    import pprint
96    pprint.pprint(cpus())
97    pprint.pprint(overrides())
Note: See TracBrowser for help on using the repository browser.