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

Side by Side Diff: build/build_nexe.py

Issue 1256313004: Use goma only if --gomadir is set. (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | 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 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2012 The Native Client 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 """NEXE building script 6 """NEXE building script
7 7
8 This module will take a set of source files, include paths, library paths, and 8 This module will take a set of source files, include paths, library paths, and
9 additional arguments, and use them to build. 9 additional arguments, and use them to build.
10 """ 10 """
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 if path.startswith('/cygdrive/'): 400 if path.startswith('/cygdrive/'):
401 path = os.path.normpath( 401 path = os.path.normpath(
402 path[len(cygdrive)] + ':' + path[len(cygdrive)+1:]) 402 path[len(cygdrive)] + ':' + path[len(cygdrive)+1:])
403 elif path.startswith('/libexec/'): 403 elif path.startswith('/libexec/'):
404 path = os.path.normpath(os.path.join(self.toolchain, path[1:])) 404 path = os.path.normpath(os.path.join(self.toolchain, path[1:]))
405 return path 405 return path
406 406
407 def GetGomaConfig(self, gomadir, arch, toolname): 407 def GetGomaConfig(self, gomadir, arch, toolname):
408 """Returns a goma config dictionary if goma is available or {}.""" 408 """Returns a goma config dictionary if goma is available or {}."""
409 409
410 # Goma is enabled only if gomadir is given.
411 # We do not use gomacc in GOMA_DIR or PATH anymore.
412 if not gomadir:
413 return {}
414
410 # Start goma support from os/arch/toolname that have been tested. 415 # Start goma support from os/arch/toolname that have been tested.
411 # Set NO_NACL_GOMA=true to force to avoid using goma. 416 # Set NO_NACL_GOMA=true to force to avoid using goma.
412 default_no_nacl_goma = True if pynacl.platform.IsWindows() else False 417 default_no_nacl_goma = True if pynacl.platform.IsWindows() else False
413 if (arch not in ['x86-32', 'x86-64', 'pnacl'] 418 if (arch not in ['x86-32', 'x86-64', 'pnacl']
414 or toolname not in ['newlib', 'glibc'] 419 or toolname not in ['newlib', 'glibc']
415 or IsEnvFlagTrue('NO_NACL_GOMA', default=default_no_nacl_goma) 420 or IsEnvFlagTrue('NO_NACL_GOMA', default=default_no_nacl_goma)
416 or IsEnvFlagTrue('GOMA_DISABLED')): 421 or IsEnvFlagTrue('GOMA_DISABLED')):
417 return {} 422 return {}
418 423
419 goma_config = {}
420 gomacc_base = 'gomacc.exe' if pynacl.platform.IsWindows() else 'gomacc' 424 gomacc_base = 'gomacc.exe' if pynacl.platform.IsWindows() else 'gomacc'
421 # Search order of gomacc: 425 goma_config = {
422 # --gomadir command argument -> GOMA_DIR env. -> PATH env. 426 'gomacc': os.path.join(gomadir, gomacc_base),
423 search_path = [] 427 'burst': IsEnvFlagTrue('NACL_GOMA_BURST'),
424 # 1. --gomadir in the command argument. 428 }
425 if gomadir: 429 default_processes = 100 if pynacl.platform.IsLinux() else 10
426 search_path.append(gomadir) 430 goma_config['processes'] = GetIntegerEnv('NACL_GOMA_PROCESSES',
427 # 2. Use GOMA_DIR environment variable if exist. 431 default=default_processes)
428 goma_dir_env = os.environ.get('GOMA_DIR')
429 if goma_dir_env:
430 search_path.append(goma_dir_env)
431 # 3. Append PATH env.
432 path_env = os.environ.get('PATH')
433 if path_env:
434 search_path.extend(path_env.split(os.path.pathsep))
435
436 for directory in search_path:
437 gomacc = os.path.join(directory, gomacc_base)
438 if os.path.isfile(gomacc):
439 try:
440 port = int(subprocess.Popen(
441 [gomacc, 'port'],
442 stdout=subprocess.PIPE).communicate()[0].strip())
443 status = urllib2.urlopen(
444 'http://127.0.0.1:%d/healthz' % port).read().strip()
445 if status == 'ok':
446 goma_config['gomacc'] = gomacc
447 break
448 except (OSError, ValueError, urllib2.URLError) as e:
449 # Try another gomacc in the search path.
450 self.Log('Strange gomacc %s found, try another one: %s' % (gomacc, e))
451
452 if goma_config:
453 goma_config['burst'] = IsEnvFlagTrue('NACL_GOMA_BURST')
454 default_processes = 100 if pynacl.platform.IsLinux() else 10
455 goma_config['processes'] = GetIntegerEnv('NACL_GOMA_PROCESSES',
456 default=default_processes)
457 return goma_config 432 return goma_config
458 433
459 def NeedsRebuild(self, outd, out, src, rebuilt=False): 434 def NeedsRebuild(self, outd, out, src, rebuilt=False):
460 if not IsFile(self.toolstamp): 435 if not IsFile(self.toolstamp):
461 if rebuilt: 436 if rebuilt:
462 raise Error('Could not find toolchain stamp file %s.' % self.toolstamp) 437 raise Error('Could not find toolchain stamp file %s.' % self.toolstamp)
463 return True 438 return True
464 if not IsFile(self.cmd_file): 439 if not IsFile(self.cmd_file):
465 if rebuilt: 440 if rebuilt:
466 raise Error('Could not find cmd file %s.' % self.cmd_file) 441 raise Error('Could not find cmd file %s.' % self.cmd_file)
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 if build is not None: 1103 if build is not None:
1129 build.EmitDeferredLog() 1104 build.EmitDeferredLog()
1130 return 1 1105 return 1
1131 except: 1106 except:
1132 if build is not None: 1107 if build is not None:
1133 build.EmitDeferredLog() 1108 build.EmitDeferredLog()
1134 raise 1109 raise
1135 1110
1136 if __name__ == '__main__': 1111 if __name__ == '__main__':
1137 sys.exit(Main(sys.argv)) 1112 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698