OLD | NEW |
1 # Copyright 2008 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
11 # with the distribution. | 11 # with the distribution. |
12 # * Neither the name of Google Inc. nor the names of its | 12 # * Neither the name of Google Inc. nor the names of its |
13 # contributors may be used to endorse or promote products derived | 13 # contributors may be used to endorse or promote products derived |
14 # from this software without specific prior written permission. | 14 # from this software without specific prior written permission. |
15 # | 15 # |
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 | 28 |
| 29 import os |
| 30 from os.path import exists |
| 31 from os.path import isdir |
| 32 from os.path import join |
29 import platform | 33 import platform |
30 import re | 34 import re |
31 | 35 |
32 | 36 |
33 # Reads a .list file into an array of strings | 37 def GetSuitePaths(test_root): |
| 38 def IsSuite(path): |
| 39 return isdir(path) and exists(join(path, 'testcfg.py')) |
| 40 return [ f for f in os.listdir(test_root) if IsSuite(join(test_root, f)) ] |
| 41 |
| 42 |
| 43 # Reads a file into an array of strings |
34 def ReadLinesFrom(name): | 44 def ReadLinesFrom(name): |
35 list = [] | 45 lines = [] |
36 for line in open(name): | 46 with open(name) as f: |
37 if '#' in line: | 47 for line in f: |
38 line = line[:line.find('#')] | 48 if line.startswith('#'): continue |
39 line = line.strip() | 49 if '#' in line: |
40 if len(line) == 0: | 50 line = line[:line.find('#')] |
41 continue | 51 line = line.strip() |
42 list.append(line) | 52 if not line: continue |
43 return list | 53 lines.append(line) |
| 54 return lines |
44 | 55 |
45 | 56 |
46 def GuessOS(): | 57 def GuessOS(): |
47 id = platform.system() | 58 system = platform.system() |
48 if id == 'Linux': | 59 if system == 'Linux': |
49 return 'linux' | 60 return 'linux' |
50 elif id == 'Darwin': | 61 elif system == 'Darwin': |
51 return 'macos' | 62 return 'macos' |
52 elif id.find('CYGWIN') >= 0: | 63 elif system.find('CYGWIN') >= 0: |
53 return 'cygwin' | 64 return 'cygwin' |
54 elif id == 'Windows' or id == 'Microsoft': | 65 elif system == 'Windows' or system == 'Microsoft': |
55 # On Windows Vista platform.system() can return 'Microsoft' with some | 66 # On Windows Vista platform.system() can return 'Microsoft' with some |
56 # versions of Python, see http://bugs.python.org/issue1082 | 67 # versions of Python, see http://bugs.python.org/issue1082 |
57 return 'win32' | 68 return 'win32' |
58 elif id == 'FreeBSD': | 69 elif system == 'FreeBSD': |
59 return 'freebsd' | 70 return 'freebsd' |
60 elif id == 'OpenBSD': | 71 elif system == 'OpenBSD': |
61 return 'openbsd' | 72 return 'openbsd' |
62 elif id == 'SunOS': | 73 elif system == 'SunOS': |
63 return 'solaris' | 74 return 'solaris' |
64 elif id == 'NetBSD': | 75 elif system == 'NetBSD': |
65 return 'netbsd' | 76 return 'netbsd' |
66 else: | 77 else: |
67 return None | 78 return None |
68 | 79 |
69 | 80 |
70 # This will default to building the 32 bit VM even on machines that are capable | 81 # This will default to building the 32 bit VM even on machines that are |
71 # of running the 64 bit VM. Use the scons option --arch=x64 to force it to buil
d | 82 # capable of running the 64 bit VM. |
72 # the 64 bit VM. | 83 def DefaultArch(): |
73 def GuessArchitecture(): | 84 machine = platform.machine() |
74 id = platform.machine() | 85 machine = machine.lower() # Windows 7 capitalizes 'AMD64'. |
75 id = id.lower() # Windows 7 capitalizes 'AMD64'. | 86 if machine.startswith('arm'): |
76 if id.startswith('arm'): | |
77 return 'arm' | 87 return 'arm' |
78 elif (not id) or (not re.match('(x|i[3-6])86$', id) is None): | 88 elif (not machine) or (not re.match('(x|i[3-6])86$', machine) is None): |
79 return 'ia32' | 89 return 'ia32' |
80 elif id == 'i86pc': | 90 elif machine == 'i86pc': |
81 return 'ia32' | 91 return 'ia32' |
82 elif id == 'x86_64': | 92 elif machine == 'x86_64': |
83 return 'ia32' | 93 return 'ia32' |
84 elif id == 'amd64': | 94 elif machine == 'amd64': |
85 return 'ia32' | 95 return 'ia32' |
86 else: | 96 else: |
87 return None | 97 return None |
88 | 98 |
89 | 99 |
90 def GuessWordsize(): | 100 def GuessWordsize(): |
91 if '64' in platform.machine(): | 101 if '64' in platform.machine(): |
92 return '64' | 102 return '64' |
93 else: | 103 else: |
94 return '32' | 104 return '32' |
95 | 105 |
96 | 106 |
97 def IsWindows(): | 107 def IsWindows(): |
98 return GuessOS() == 'win32' | 108 return GuessOS() == 'win32' |
OLD | NEW |