Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: native_client_sdk/src/tools/getos.py

Issue 118553007: [NaCl SDK] Use nacl_config.py in common.mk build system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « native_client_sdk/src/tools/common.mk ('k') | native_client_sdk/src/tools/nacl_config.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 raise Error("Error running objdump on: %s" % chrome_path) 165 raise Error("Error running objdump on: %s" % chrome_path)
166 166
167 arch = match.group(2) 167 arch = match.group(2)
168 if 'arm' in arch: 168 if 'arm' in arch:
169 return 'arm' 169 return 'arm'
170 if '64' in arch: 170 if '64' in arch:
171 return 'x86_64' 171 return 'x86_64'
172 return 'x86_32' 172 return 'x86_32'
173 173
174 174
175 def GetLoaderPath(platform):
176 sdk_path = GetSDKPath()
177 arch = GetNaClArch(platform)
178 sel_ldr = os.path.join(sdk_path, 'tools', 'sel_ldr_' + arch)
179 if not os.path.exists(sel_ldr):
180 raise Error("sel_ldr not found: %s" % sel_ldr)
181 return sel_ldr
182
183
184 def GetHelperPath(platform):
185 sdk_path = GetSDKPath()
186 if platform != 'linux':
187 return ''
188 arch = GetNaClArch(platform)
189 helper = os.path.join(sdk_path, 'tools', 'nacl_helper_bootstrap_' + arch)
190 if not os.path.exists(helper):
191 raise Error("helper not found: %s" % helper)
192 return helper
193
194
195 def GetIrtBinPath(platform):
196 sdk_path = GetSDKPath()
197 arch = GetNaClArch(platform)
198 irt = os.path.join(sdk_path, 'tools', 'irt_core_%s.nexe' % arch)
199 if not os.path.exists(irt):
200 raise Error("irt not found: %s" % irt)
201 return irt
202
203
204 def ParseVersion(version): 175 def ParseVersion(version):
205 if '.' in version: 176 if '.' in version:
206 version = version.split('.') 177 version = version.split('.')
207 else: 178 else:
208 version = (version, '0') 179 version = (version, '0')
209 180
210 try: 181 try:
211 return tuple(int(x) for x in version) 182 return tuple(int(x) for x in version)
212 except ValueError: 183 except ValueError:
213 raise Error('error parsing SDK version: %s' % version) 184 raise Error('error parsing SDK version: %s' % version)
214 185
215 186
216 def main(args): 187 def main(args):
217 parser = optparse.OptionParser() 188 parser = optparse.OptionParser()
218 parser.add_option('--arch', action='store_true', 189 parser.add_option('--arch', action='store_true',
219 help='Print architecture of current machine (x86_32, x86_64 or arm).') 190 help='Print architecture of current machine (x86_32, x86_64 or arm).')
220 parser.add_option('--chrome', action='store_true', 191 parser.add_option('--chrome', action='store_true',
221 help='Print the path chrome (by first looking in $CHROME_PATH and ' 192 help='Print the path chrome (by first looking in $CHROME_PATH and '
222 'then $PATH).') 193 'then $PATH).')
223 parser.add_option('--nacl-arch', action='store_true', 194 parser.add_option('--nacl-arch', action='store_true',
224 help='Print architecture used by NaCl on the current machine.') 195 help='Print architecture used by NaCl on the current machine.')
225 parser.add_option('--helper', action='store_true',
226 help='Print chrome helper path.')
227 parser.add_option('--irtbin', action='store_true',
228 help='Print irt binary path.')
229 parser.add_option('--loader', action='store_true',
230 help='Print NEXE loader path.')
231 parser.add_option('--sdk-version', action='store_true', 196 parser.add_option('--sdk-version', action='store_true',
232 help='Print major version of the NaCl SDK.') 197 help='Print major version of the NaCl SDK.')
233 parser.add_option('--sdk-revision', action='store_true', 198 parser.add_option('--sdk-revision', action='store_true',
234 help='Print revision number of the NaCl SDK.') 199 help='Print revision number of the NaCl SDK.')
235 parser.add_option('--check-version', 200 parser.add_option('--check-version',
236 help='Check that the SDK version is at least as great as the ' 201 help='Check that the SDK version is at least as great as the '
237 'version passed in.') 202 'version passed in.')
238 203
239 options, _ = parser.parse_args(args) 204 options, _ = parser.parse_args(args)
240 205
241 platform = GetPlatform() 206 platform = GetPlatform()
242 207
243 if len(args) > 1: 208 if len(args) > 1:
244 parser.error('Only one option can be specified at a time.') 209 parser.error('Only one option can be specified at a time.')
245 210
246 if not args: 211 if not args:
247 print platform 212 print platform
248 return 0 213 return 0
249 214
250 if options.arch: 215 if options.arch:
251 out = GetSystemArch(platform) 216 out = GetSystemArch(platform)
252 elif options.nacl_arch: 217 elif options.nacl_arch:
253 out = GetNaClArch(platform) 218 out = GetNaClArch(platform)
254 elif options.chrome: 219 elif options.chrome:
255 out = GetChromePath(platform) 220 out = GetChromePath(platform)
256 elif options.helper:
257 out = GetHelperPath(platform)
258 elif options.irtbin:
259 out = GetIrtBinPath(platform)
260 elif options.loader:
261 out = GetLoaderPath(platform)
262 elif options.sdk_version: 221 elif options.sdk_version:
263 out = GetSDKVersion()[0] 222 out = GetSDKVersion()[0]
264 elif options.sdk_revision: 223 elif options.sdk_revision:
265 out = GetSDKVersion()[1] 224 out = GetSDKVersion()[1]
266 elif options.check_version: 225 elif options.check_version:
267 required_version = ParseVersion(options.check_version) 226 required_version = ParseVersion(options.check_version)
268 version = GetSDKVersion() 227 version = GetSDKVersion()
269 if version < required_version: 228 if version < required_version:
270 raise Error("SDK version too old (current: %s.%s, required: %s.%s)" 229 raise Error("SDK version too old (current: %s.%s, required: %s.%s)"
271 % (version[0], version[1], 230 % (version[0], version[1],
272 required_version[0], required_version[1])) 231 required_version[0], required_version[1]))
273 out = None 232 out = None
274 233
275 if out: 234 if out:
276 print out 235 print out
277 return 0 236 return 0
278 237
279 238
280 if __name__ == '__main__': 239 if __name__ == '__main__':
281 try: 240 try:
282 sys.exit(main(sys.argv[1:])) 241 sys.exit(main(sys.argv[1:]))
283 except Error as e: 242 except Error as e:
284 sys.stderr.write(str(e) + '\n') 243 sys.stderr.write(str(e) + '\n')
285 sys.exit(1) 244 sys.exit(1)
OLDNEW
« no previous file with comments | « native_client_sdk/src/tools/common.mk ('k') | native_client_sdk/src/tools/nacl_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698