source: rtems-source-builder/source-builder/sb/windows.py @ a84249d

4.104.114.95
Last change on this file since a84249d was a84249d, checked in by Chris Johns <chrisj@…>, on 03/03/15 at 09:20:10

Windows fixes to build with MSYS2.

The path handling has been cleaned up and support for file names
longer than 256 characters.

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