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') |
149 | 151 |
152 if not os.path.exists(chrome_path): | |
153 raise Error("File %s does not exist." % chrome_path) | |
154 | |
155 if not os.access(chrome_path, os.X_OK): | |
156 raise Error("File %s is not executable" % chrome_path) | |
157 | |
Sam Clegg
2014/07/23 21:11:49
I was thinking we of doing this before we replace
| |
150 try: | 158 try: |
151 pobj = subprocess.Popen(['objdump', '-f', chrome_path], | 159 pobj = subprocess.Popen(['objdump', '-f', chrome_path], |
152 stdout=subprocess.PIPE, | 160 stdout=subprocess.PIPE, |
153 stderr=subprocess.PIPE) | 161 stderr=subprocess.PIPE) |
154 output, stderr = pobj.communicate() | 162 output, stderr = pobj.communicate() |
155 # error out here if objdump failed | 163 # error out here if objdump failed |
156 if pobj.returncode: | 164 if pobj.returncode: |
157 raise Error(output + stderr.strip()) | 165 raise Error(output + stderr.strip()) |
158 except OSError as e: | 166 except OSError as e: |
159 # This will happen if objdump is not installed | 167 # This will happen if objdump is not installed |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 print out | 243 print out |
236 return 0 | 244 return 0 |
237 | 245 |
238 | 246 |
239 if __name__ == '__main__': | 247 if __name__ == '__main__': |
240 try: | 248 try: |
241 sys.exit(main(sys.argv[1:])) | 249 sys.exit(main(sys.argv[1:])) |
242 except Error as e: | 250 except Error as e: |
243 sys.stderr.write(str(e) + '\n') | 251 sys.stderr.write(str(e) + '\n') |
244 sys.exit(1) | 252 sys.exit(1) |
OLD | NEW |