config.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/usr/bin/env python
  2. import errno
  3. import os
  4. import platform
  5. import sys
  6. # URL to the mips64el sysroot image.
  7. MIPS64EL_SYSROOT_URL = 'https://github.com/electron' \
  8. + '/debian-sysroot-image-creator/releases/download' \
  9. + '/v0.5.0/debian_jessie_mips64-sysroot.tar.bz2'
  10. # URL to the mips64el toolchain.
  11. MIPS64EL_GCC = 'gcc-4.8.3-d197-n64-loongson'
  12. MIPS64EL_GCC_URL = 'http://ftp.loongnix.org/toolchain/gcc/release/' \
  13. + MIPS64EL_GCC + '.tar.gz'
  14. BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
  15. 'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
  16. PLATFORM = {
  17. 'cygwin': 'win32',
  18. 'darwin': 'darwin',
  19. 'linux2': 'linux',
  20. 'win32': 'win32',
  21. }[sys.platform]
  22. verbose_mode = False
  23. def get_platform_key():
  24. if os.environ.has_key('MAS_BUILD'):
  25. return 'mas'
  26. else:
  27. return PLATFORM
  28. def get_target_arch():
  29. arch = os.environ.get('TARGET_ARCH')
  30. if arch is None:
  31. return 'x64'
  32. return arch
  33. def get_env_var(name):
  34. value = os.environ.get('ELECTRON_' + name, '')
  35. if not value:
  36. # TODO Remove ATOM_SHELL_* fallback values
  37. value = os.environ.get('ATOM_SHELL_' + name, '')
  38. if value:
  39. print 'Warning: Use $ELECTRON_' + name + ' instead of $ATOM_SHELL_' + name
  40. return value
  41. def s3_config():
  42. config = (get_env_var('S3_BUCKET'),
  43. get_env_var('S3_ACCESS_KEY'),
  44. get_env_var('S3_SECRET_KEY'))
  45. message = ('Error: Please set the $ELECTRON_S3_BUCKET, '
  46. '$ELECTRON_S3_ACCESS_KEY, and '
  47. '$ELECTRON_S3_SECRET_KEY environment variables')
  48. assert all(len(c) for c in config), message
  49. return config
  50. def enable_verbose_mode():
  51. print 'Running in verbose mode'
  52. global verbose_mode
  53. verbose_mode = True
  54. def is_verbose_mode():
  55. return verbose_mode
  56. def get_zip_name(name, version, suffix=''):
  57. arch = get_target_arch()
  58. if arch == 'arm':
  59. arch += 'v7l'
  60. zip_name = '{0}-{1}-{2}-{3}'.format(name, version, get_platform_key(), arch)
  61. if suffix:
  62. zip_name += '-' + suffix
  63. return zip_name + '.zip'
  64. def build_env():
  65. env = os.environ.copy()
  66. if get_target_arch() == "mips64el":
  67. SOURCE_ROOT = os.path.abspath(os.path.dirname(
  68. os.path.dirname(os.path.dirname(__file__))))
  69. VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
  70. gcc_dir = os.path.join(VENDOR_DIR, MIPS64EL_GCC)
  71. ldlib_dirs = [
  72. gcc_dir + '/usr/x86_64-unknown-linux-gnu/mips64el-redhat-linux/lib',
  73. gcc_dir + '/usr/lib64',
  74. gcc_dir + '/usr/mips64el-redhat-linux/lib64',
  75. gcc_dir + '/usr/mips64el-redhat-linux/sysroot/lib64',
  76. gcc_dir + '/usr/mips64el-redhat-linux/sysroot/usr/lib64',
  77. ]
  78. env['LD_LIBRARY_PATH'] = os.pathsep.join(ldlib_dirs)
  79. env['PATH'] = os.pathsep.join([gcc_dir + '/usr/bin', env['PATH']])
  80. return env