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