config.py 3.0 KB

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