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