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

Side by Side Diff: lib/naclports/util.py

Issue 1393343002: Improve emscripten download, install and auto-detection (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « lib/naclports/source_package.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Native Client Authors. All rights reserved. 1 # Copyright 2014 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import fcntl 5 import fcntl
6 import hashlib 6 import hashlib
7 import os 7 import os
8 import shutil 8 import shutil
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 else: 243 else:
244 raise error.Error('$EMSCRIPTEN not set and %s does not exist.' % 244 raise error.Error('$EMSCRIPTEN not set and %s does not exist.' %
245 local_root) 245 local_root)
246 246
247 if not os.path.isdir(emscripten): 247 if not os.path.isdir(emscripten):
248 raise error.Error('$EMSCRIPTEN environment variable does not point' 248 raise error.Error('$EMSCRIPTEN environment variable does not point'
249 ' to a directory: %s' % emscripten) 249 ' to a directory: %s' % emscripten)
250 return emscripten 250 return emscripten
251 251
252 252
253 def SetupEmscripten():
254 if 'EMSCRIPTEN' in os.environ:
255 return
256
257 local_root = GetEmscriptenRoot()
258 os.environ['EMSCRIPTEN'] = local_root
259 os.environ['EM_CONFIG'] = os.path.join(os.path.dirname(local_root),
260 '.emscripten')
261 try:
262 FindInPath('node')
263 except error.Error:
264 node_bin = os.path.join(paths.OUT_DIR, 'node', 'bin')
265 if not os.path.isdir(node_bin):
266 raise error.Error('node not found in path and default path not found: %s'
267 % node_bin)
268
269 os.environ['PATH'] += ':' + node_bin
270 FindInPath('node')
271
272
253 @Memoize 273 @Memoize
254 def GetSDKVersion(): 274 def GetSDKVersion():
255 """Returns the version (as a string) of the current SDK.""" 275 """Returns the version (as a string) of the current SDK."""
256 getos = os.path.join(GetSDKRoot(), 'tools', 'getos.py') 276 getos = os.path.join(GetSDKRoot(), 'tools', 'getos.py')
257 version = subprocess.check_output([getos, '--sdk-version']).strip() 277 version = subprocess.check_output([getos, '--sdk-version']).strip()
258 return version 278 return version
259 279
260 280
261 def CheckSDKVersion(version): 281 def CheckSDKVersion(version):
262 """Returns True if the currently configured SDK is 'version' or above.""" 282 """Returns True if the currently configured SDK is 'version' or above."""
263 return int(GetSDKVersion()) >= int(version) 283 return int(GetSDKVersion()) >= int(version)
264 284
265 285
266 @Memoize 286 @Memoize
267 def GetSDKRevision(): 287 def GetSDKRevision():
268 """Returns the revision of the currently configured Native Client SDK.""" 288 """Returns the revision of the currently configured Native Client SDK."""
269 getos = os.path.join(GetSDKRoot(), 'tools', 'getos.py') 289 getos = os.path.join(GetSDKRoot(), 'tools', 'getos.py')
270 version = subprocess.check_output([getos, '--sdk-revision']).strip() 290 version = subprocess.check_output([getos, '--sdk-revision']).strip()
271 return int(version) 291 return int(version)
272 292
273 293
274 @Memoize 294 @Memoize
275 def GetPlatform(): 295 def GetPlatform():
276 """Returns the current platform name according getos.py.""" 296 """Returns the current platform name according getos.py."""
277 getos = os.path.join(GetSDKRoot(), 'tools', 'getos.py') 297 getos = os.path.join(GetSDKRoot(), 'tools', 'getos.py')
278 platform = subprocess.check_output([getos]).strip() 298 platform = subprocess.check_output([getos]).strip()
279 return platform 299 return platform
280 300
281
282 @Memoize 301 @Memoize
283 def GetToolchainRoot(config): 302 def GetToolchainRoot(config):
284 """Returns the toolchain folder for a given NaCl toolchain.""" 303 """Returns the toolchain folder for a given NaCl toolchain."""
285 if config.toolchain == 'emscripten': 304 if config.toolchain == 'emscripten':
286 return GetEmscriptenRoot() 305 return GetEmscriptenRoot()
287 306
288 platform = GetPlatform() 307 platform = GetPlatform()
289 if config.toolchain in ('pnacl', 'clang-newlib'): 308 if config.toolchain in ('pnacl', 'clang-newlib'):
290 tc_dir = os.path.join('%s_pnacl' % platform) 309 tc_dir = os.path.join('%s_pnacl' % platform)
291 else: 310 else:
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 480
462 class InstallLock(Lock): 481 class InstallLock(Lock):
463 """Lock used when installing/uninstalling package""" 482 """Lock used when installing/uninstalling package"""
464 483
465 def __init__(self, config): 484 def __init__(self, config):
466 root = GetInstallRoot(config) 485 root = GetInstallRoot(config)
467 super(InstallLock, self).__init__(root) 486 super(InstallLock, self).__init__(root)
468 487
469 488
470 CheckStdoutForColorSupport() 489 CheckStdoutForColorSupport()
OLDNEW
« no previous file with comments | « lib/naclports/source_package.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698