OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Determine OS and various other system properties. | 6 """Determine OS and various other system properties. |
7 | 7 |
8 Determine the name of the platform used and other system properties such as | 8 Determine the name of the platform used and other system properties such as |
9 the location of Chrome. This is used, for example, to determine the correct | 9 the location of Chrome. This is used, for example, to determine the correct |
10 Toolchain to invoke. | 10 Toolchain to invoke. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 # On Mac the nacl arch is currently always 32-bit. | 137 # On Mac the nacl arch is currently always 32-bit. |
138 return 'x86_32' | 138 return 'x86_32' |
139 | 139 |
140 # On linux the nacl arch matches to chrome arch, so we inspect the chrome | 140 # On linux the nacl arch matches to chrome arch, so we inspect the chrome |
141 # binary using objdump | 141 # binary using objdump |
142 chrome_path = GetChromePath(platform) | 142 chrome_path = GetChromePath(platform) |
143 | 143 |
144 # If CHROME_PATH is set to point to google-chrome or google-chrome | 144 # If CHROME_PATH is set to point to google-chrome or google-chrome |
145 # was found in the PATH and we are running on UNIX then google-chrome | 145 # was found in the PATH and we are running on UNIX then google-chrome |
146 # is a bash script that points to 'chrome' in the same folder. | 146 # is a bash script that points to 'chrome' in the same folder. |
147 if os.path.basename(chrome_path) == 'google-chrome': | 147 # |
148 # When running beta or dev branch, the name is google-chrome-{beta,dev}. | |
149 if os.path.basename(chrome_path).startswith('google-chrome'): | |
148 chrome_path = os.path.join(os.path.dirname(chrome_path), 'chrome') | 150 chrome_path = os.path.join(os.path.dirname(chrome_path), 'chrome') |
Sam Clegg
2014/07/23 19:57:44
Can we also check that it exists and is executable
binji
2014/07/23 20:58:28
Done.
| |
149 | 151 |
150 try: | 152 try: |
151 pobj = subprocess.Popen(['objdump', '-f', chrome_path], | 153 pobj = subprocess.Popen(['objdump', '-f', chrome_path], |
152 stdout=subprocess.PIPE, | 154 stdout=subprocess.PIPE, |
153 stderr=subprocess.PIPE) | 155 stderr=subprocess.PIPE) |
154 output, stderr = pobj.communicate() | 156 output, stderr = pobj.communicate() |
155 # error out here if objdump failed | 157 # error out here if objdump failed |
156 if pobj.returncode: | 158 if pobj.returncode: |
157 raise Error(output + stderr.strip()) | 159 raise Error(output + stderr.strip()) |
158 except OSError as e: | 160 except OSError as e: |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 print out | 237 print out |
236 return 0 | 238 return 0 |
237 | 239 |
238 | 240 |
239 if __name__ == '__main__': | 241 if __name__ == '__main__': |
240 try: | 242 try: |
241 sys.exit(main(sys.argv[1:])) | 243 sys.exit(main(sys.argv[1:])) |
242 except Error as e: | 244 except Error as e: |
243 sys.stderr.write(str(e) + '\n') | 245 sys.stderr.write(str(e) + '\n') |
244 sys.exit(1) | 246 sys.exit(1) |
OLD | NEW |