source: rtems-tools/rtemstoolkit/windows.py @ 7e5cdea

5
Last change on this file since 7e5cdea 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: 6.0 KB
RevLine 
[50fdf12]1#
2# RTEMS Tools Project (http://www.rtems.org/)
[7d3350d]3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
[50fdf12]4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions are met:
10#
11# 1. Redistributions of source code must retain the above copyright notice,
12# this list of conditions and the following disclaimer.
13#
14# 2. Redistributions in binary form must reproduce the above copyright notice,
15# this list of conditions and the following disclaimer in the documentation
16# and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
29#
30
31#
32# Windows specific support and overrides.
33#
34
35import os
36
[7e5cdea]37from rtemstoolkit import error
38from rtemstoolkit import execute
[50fdf12]39
[7d3350d]40def cpus():
41    if os.environ.has_key('NUMBER_OF_PROCESSORS'):
42        ncpus = int(os.environ['NUMBER_OF_PROCESSORS'])
43    else:
44        ncpus = 1
45    return ncpus
46
47def overrides():
[50fdf12]48    # Default to the native Windows Python.
49    uname = 'win32'
50    system = 'mingw32'
51    if os.environ.has_key('HOSTTYPE'):
52        hosttype = os.environ['HOSTTYPE']
53    else:
54        hosttype = 'i686'
55    host_triple = hosttype + '-pc-' + system
56    build_triple = hosttype + '-pc-' + system
57
58    # See if this is actually Cygwin Python
59    if os.name == 'posix':
60        try:
61            uname = os.uname()
62            hosttype = uname[4]
63            uname = uname[0]
64            if uname.startswith('CYGWIN'):
65                if uname.endswith('WOW64'):
66                    uname = 'cygwin'
67                    build_triple = hosttype + '-pc-' + uname
68                    hosttype = 'x86_64'
69                    host_triple = hosttype + '-w64-' + system
70                else:
71                    raise error.general('invalid uname for Windows')
72            else:
73                raise error.general('invalid POSIX python')
74        except:
75            pass
76
[7d3350d]77    ncpus = '%d' % (cpus())
[50fdf12]78
79    defines = {
80        '_ncpus':         ('none',    'none',     ncpus),
81        '_os':            ('none',    'none',     'win32'),
82        '_build':         ('triplet', 'required', build_triple),
83        '_build_vendor':  ('none',    'none',     'microsoft'),
84        '_build_os':      ('none',    'none',     'win32'),
85        '_build_cpu':     ('none',    'none',     hosttype),
86        '_build_alias':   ('none',    'none',     '%{nil}'),
87        '_build_arch':    ('none',    'none',     hosttype),
88        '_host':          ('triplet', 'required', host_triple),
89        '_host_vendor':   ('none',    'none',     'microsoft'),
90        '_host_os':       ('none',    'none',     'win32'),
91        '_host_cpu':      ('none',    'none',     hosttype),
92        '_host_alias':    ('none',    'none',     '%{nil}'),
93        '_host_arch':     ('none',    'none',     hosttype),
94        '_usr':           ('dir',     'optional', '/opt/local'),
95        '_var':           ('dir',     'optional', '/opt/local/var'),
96        '__bash':         ('exe',     'required', 'bash'),
97        '__bzip2':        ('exe',     'required', 'bzip2'),
98        '__bison':        ('exe',     'required', 'bison'),
99        '__cat':          ('exe',     'required', 'cat'),
100        '__cc':           ('exe',     'required', 'gcc'),
101        '__chgrp':        ('exe',     'required', 'chgrp'),
102        '__chmod':        ('exe',     'required', 'chmod'),
103        '__chown':        ('exe',     'required', 'chown'),
104        '__cp':           ('exe',     'required', 'cp'),
105        '__cvs':          ('exe',     'required', 'cvs'),
106        '__cxx':          ('exe',     'required', 'g++'),
107        '__flex':         ('exe',     'required', 'flex'),
108        '__git':          ('exe',     'required', 'git'),
109        '__grep':         ('exe',     'required', 'grep'),
110        '__gzip':         ('exe',     'required', 'gzip'),
111        '__id':           ('exe',     'required', 'id'),
112        '__install':      ('exe',     'required', 'install'),
113        '__install_info': ('exe',     'required', 'install-info'),
114        '__ld':           ('exe',     'required', 'ld'),
115        '__ldconfig':     ('exe',     'none',     ''),
116        '__makeinfo':     ('exe',     'required', 'makeinfo'),
117        '__mkdir':        ('exe',     'required', 'mkdir'),
118        '__mv':           ('exe',     'required', 'mv'),
119        '__nm':           ('exe',     'required', 'nm'),
120        '__nm':           ('exe',     'required', 'nm'),
121        '__objcopy':      ('exe',     'required', 'objcopy'),
122        '__objdump':      ('exe',     'required', 'objdump'),
123        '__patch':        ('exe',     'required', 'patch'),
124        '__patch_bin':    ('exe',     'required', 'patch'),
125        '__rm':           ('exe',     'required', 'rm'),
126        '__sed':          ('exe',     'required', 'sed'),
127        '__sh':           ('exe',     'required', 'sh'),
128        '__tar':          ('exe',     'required', 'bsdtar'),
129        '__touch':        ('exe',     'required', 'touch'),
130        '__unzip':        ('exe',     'required', 'unzip'),
131        '__xz':           ('exe',     'required', 'xz'),
132        '_buildshell':    ('exe',     'required', '%{__sh}'),
133        '___setup_shell': ('exe',     'required', '%{__sh}')
134        }
135    return defines
136
137if __name__ == '__main__':
[7d3350d]138    import pprint
139    pprint.pprint(cpus())
140    pprint.pprint(overrides())
Note: See TracBrowser for help on using the repository browser.