source: rtems-tools/rtemstoolkit/windows.py @ 31e22e3

5
Last change on this file since 31e22e3 was b0fa2ae, checked in by Chris Johns <chrisj@…>, on 03/03/16 at 05:46:18

Update rtems-tool to support Python 2 and 3.

Add solaris and netbsd.

Close #2619.

  • Property mode set to 100644
File size: 6.1 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2016 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# 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 pprint
36import os
37
38#
39# Support to handle use in a package and as a unit test.
40# If there is a better way to let us know.
41#
42try:
43    from . import error
44    from . import execute
45except (ValueError, SystemError):
46    import error
47    import execute
48
49def load():
50    # Default to the native Windows Python.
51    uname = 'win32'
52    system = 'mingw32'
53    if os.environ.has_key('HOSTTYPE'):
54        hosttype = os.environ['HOSTTYPE']
55    else:
56        hosttype = 'i686'
57    host_triple = hosttype + '-pc-' + system
58    build_triple = hosttype + '-pc-' + system
59
60    # See if this is actually Cygwin Python
61    if os.name == 'posix':
62        try:
63            uname = os.uname()
64            hosttype = uname[4]
65            uname = uname[0]
66            if uname.startswith('CYGWIN'):
67                if uname.endswith('WOW64'):
68                    uname = 'cygwin'
69                    build_triple = hosttype + '-pc-' + uname
70                    hosttype = 'x86_64'
71                    host_triple = hosttype + '-w64-' + system
72                else:
73                    raise error.general('invalid uname for Windows')
74            else:
75                raise error.general('invalid POSIX python')
76        except:
77            pass
78
79    if os.environ.has_key('NUMBER_OF_PROCESSORS'):
80        ncpus = os.environ['NUMBER_OF_PROCESSORS']
81    else:
82        ncpus = '1'
83
84    defines = {
85        '_ncpus':         ('none',    'none',     ncpus),
86        '_os':            ('none',    'none',     'win32'),
87        '_build':         ('triplet', 'required', build_triple),
88        '_build_vendor':  ('none',    'none',     'microsoft'),
89        '_build_os':      ('none',    'none',     'win32'),
90        '_build_cpu':     ('none',    'none',     hosttype),
91        '_build_alias':   ('none',    'none',     '%{nil}'),
92        '_build_arch':    ('none',    'none',     hosttype),
93        '_host':          ('triplet', 'required', host_triple),
94        '_host_vendor':   ('none',    'none',     'microsoft'),
95        '_host_os':       ('none',    'none',     'win32'),
96        '_host_cpu':      ('none',    'none',     hosttype),
97        '_host_alias':    ('none',    'none',     '%{nil}'),
98        '_host_arch':     ('none',    'none',     hosttype),
99        '_usr':           ('dir',     'optional', '/opt/local'),
100        '_var':           ('dir',     'optional', '/opt/local/var'),
101        '__bash':         ('exe',     'required', 'bash'),
102        '__bzip2':        ('exe',     'required', 'bzip2'),
103        '__bison':        ('exe',     'required', 'bison'),
104        '__cat':          ('exe',     'required', 'cat'),
105        '__cc':           ('exe',     'required', 'gcc'),
106        '__chgrp':        ('exe',     'required', 'chgrp'),
107        '__chmod':        ('exe',     'required', 'chmod'),
108        '__chown':        ('exe',     'required', 'chown'),
109        '__cp':           ('exe',     'required', 'cp'),
110        '__cvs':          ('exe',     'required', 'cvs'),
111        '__cxx':          ('exe',     'required', 'g++'),
112        '__flex':         ('exe',     'required', 'flex'),
113        '__git':          ('exe',     'required', 'git'),
114        '__grep':         ('exe',     'required', 'grep'),
115        '__gzip':         ('exe',     'required', 'gzip'),
116        '__id':           ('exe',     'required', 'id'),
117        '__install':      ('exe',     'required', 'install'),
118        '__install_info': ('exe',     'required', 'install-info'),
119        '__ld':           ('exe',     'required', 'ld'),
120        '__ldconfig':     ('exe',     'none',     ''),
121        '__makeinfo':     ('exe',     'required', 'makeinfo'),
122        '__mkdir':        ('exe',     'required', 'mkdir'),
123        '__mv':           ('exe',     'required', 'mv'),
124        '__nm':           ('exe',     'required', 'nm'),
125        '__nm':           ('exe',     'required', 'nm'),
126        '__objcopy':      ('exe',     'required', 'objcopy'),
127        '__objdump':      ('exe',     'required', 'objdump'),
128        '__patch':        ('exe',     'required', 'patch'),
129        '__patch_bin':    ('exe',     'required', 'patch'),
130        '__rm':           ('exe',     'required', 'rm'),
131        '__sed':          ('exe',     'required', 'sed'),
132        '__sh':           ('exe',     'required', 'sh'),
133        '__tar':          ('exe',     'required', 'bsdtar'),
134        '__touch':        ('exe',     'required', 'touch'),
135        '__unzip':        ('exe',     'required', 'unzip'),
136        '__xz':           ('exe',     'required', 'xz'),
137        '_buildshell':    ('exe',     'required', '%{__sh}'),
138        '___setup_shell': ('exe',     'required', '%{__sh}')
139        }
140    return defines
141
142if __name__ == '__main__':
143    pprint.pprint(load())
Note: See TracBrowser for help on using the repository browser.