download_nacl_toolchains.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env python
  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
  4. # found in the LICENSE file.
  5. """Shim to run nacl toolchain download script only if there is a nacl dir."""
  6. import os
  7. import sys
  8. def Main(args):
  9. # Exit early if disable_nacl=1.
  10. if 'disable_nacl=1' in os.environ.get('GYP_DEFINES', ''):
  11. return 0
  12. script_dir = os.path.dirname(os.path.abspath(__file__))
  13. src_dir = os.path.dirname(script_dir)
  14. nacl_dir = os.path.join(src_dir, 'native_client')
  15. nacl_build_dir = os.path.join(nacl_dir, 'build')
  16. download_script = os.path.join(nacl_build_dir, 'download_toolchains.py')
  17. if not os.path.exists(download_script):
  18. print "Can't find '%s'" % download_script
  19. print 'Presumably you are intentionally building without NativeClient.'
  20. print 'Skipping NativeClient toolchain download.'
  21. sys.exit(0)
  22. sys.path.insert(0, nacl_build_dir)
  23. import download_toolchains
  24. # TODO (robertm): Finish getting PNaCl ready for prime time.
  25. # BUG:
  26. # We remove this --optional-pnacl argument, and instead replace it with
  27. # --no-pnacl for most cases. However, if the bot name is the pnacl_sdk
  28. # bot then we will go ahead and download it. This prevents increasing the
  29. # gclient sync time for developers, or standard Chrome bots.
  30. if '--optional-pnacl' in args:
  31. args.remove('--optional-pnacl')
  32. # By default we don't use PNaCl toolchain yet, unless on ARM, where
  33. # there is no other toolchain to build untrusted code at the moment.
  34. # So analyze if we're building for ARM, or on SDK buildbot.
  35. # TODO(olonho): we need to invent more reliable way to get build
  36. # configuration info, to know if we're building for ARM.
  37. use_pnacl = False
  38. if 'target_arch=arm' in os.environ.get('GYP_DEFINES', ''):
  39. use_pnacl = True
  40. buildbot_name = os.environ.get('BUILDBOT_BUILDERNAME', '')
  41. if buildbot_name.find('pnacl') >= 0 and buildbot_name.find('sdk') >= 0:
  42. use_pnacl = True
  43. if use_pnacl:
  44. print '\n*** DOWNLOADING PNACL TOOLCHAIN ***\n'
  45. else:
  46. args.append('--no-pnacl')
  47. # Append the name of the file to use as a version and hash source.
  48. # NOTE: While not recommended, it is possible to redirect this file to
  49. # a chrome location to avoid branching NaCl if just a toolchain needs
  50. # to be bumped.
  51. args.append(os.path.join(nacl_dir,'TOOL_REVISIONS'))
  52. download_toolchains.main(args)
  53. return 0
  54. if __name__ == '__main__':
  55. sys.exit(Main(sys.argv[1:]))