[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 | |
---|
| 35 | import os |
---|
| 36 | |
---|
[7e5cdea] | 37 | from rtemstoolkit import error |
---|
| 38 | from rtemstoolkit import execute |
---|
[50fdf12] | 39 | |
---|
[7d3350d] | 40 | def cpus(): |
---|
[6d30de6] | 41 | if 'NUMBER_OF_PROCESSORS' in os.environ: |
---|
[7d3350d] | 42 | ncpus = int(os.environ['NUMBER_OF_PROCESSORS']) |
---|
| 43 | else: |
---|
| 44 | ncpus = 1 |
---|
| 45 | return ncpus |
---|
| 46 | |
---|
| 47 | def overrides(): |
---|
[50fdf12] | 48 | # Default to the native Windows Python. |
---|
| 49 | uname = 'win32' |
---|
| 50 | system = 'mingw32' |
---|
[6d30de6] | 51 | if 'HOSTTYPE' in os.environ: |
---|
[50fdf12] | 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 | '__cxx': ('exe', 'required', 'g++'), |
---|
| 106 | '__flex': ('exe', 'required', 'flex'), |
---|
| 107 | '__git': ('exe', 'required', 'git'), |
---|
| 108 | '__grep': ('exe', 'required', 'grep'), |
---|
| 109 | '__gzip': ('exe', 'required', 'gzip'), |
---|
| 110 | '__id': ('exe', 'required', 'id'), |
---|
| 111 | '__install': ('exe', 'required', 'install'), |
---|
| 112 | '__install_info': ('exe', 'required', 'install-info'), |
---|
| 113 | '__ld': ('exe', 'required', 'ld'), |
---|
| 114 | '__ldconfig': ('exe', 'none', ''), |
---|
| 115 | '__makeinfo': ('exe', 'required', 'makeinfo'), |
---|
| 116 | '__mkdir': ('exe', 'required', 'mkdir'), |
---|
| 117 | '__mv': ('exe', 'required', 'mv'), |
---|
| 118 | '__nm': ('exe', 'required', 'nm'), |
---|
| 119 | '__nm': ('exe', 'required', 'nm'), |
---|
| 120 | '__objcopy': ('exe', 'required', 'objcopy'), |
---|
| 121 | '__objdump': ('exe', 'required', 'objdump'), |
---|
| 122 | '__patch': ('exe', 'required', 'patch'), |
---|
| 123 | '__patch_bin': ('exe', 'required', 'patch'), |
---|
| 124 | '__rm': ('exe', 'required', 'rm'), |
---|
| 125 | '__sed': ('exe', 'required', 'sed'), |
---|
| 126 | '__sh': ('exe', 'required', 'sh'), |
---|
| 127 | '__tar': ('exe', 'required', 'bsdtar'), |
---|
| 128 | '__touch': ('exe', 'required', 'touch'), |
---|
| 129 | '__unzip': ('exe', 'required', 'unzip'), |
---|
| 130 | '__xz': ('exe', 'required', 'xz'), |
---|
| 131 | '_buildshell': ('exe', 'required', '%{__sh}'), |
---|
| 132 | '___setup_shell': ('exe', 'required', '%{__sh}') |
---|
| 133 | } |
---|
| 134 | return defines |
---|
| 135 | |
---|
| 136 | if __name__ == '__main__': |
---|
[7d3350d] | 137 | import pprint |
---|
| 138 | pprint.pprint(cpus()) |
---|
| 139 | pprint.pprint(overrides()) |
---|