config.py 2.9 KB

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