cibuild 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/usr/bin/env python
  2. import os
  3. import subprocess
  4. import sys
  5. from lib.config import PLATFORM
  6. from lib.util import execute, rm_rf, scoped_env
  7. SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
  8. LINUX_DEPS = [
  9. 'libdbus-1-dev',
  10. 'libgconf2-dev',
  11. 'libgnome-keyring-dev',
  12. 'libgtk-3-dev',
  13. 'libnotify-dev',
  14. 'libnss3-dev',
  15. 'libxtst-dev',
  16. ]
  17. LINUX_DEPS_NO_ARM = [
  18. 'gcc-multilib',
  19. 'g++-multilib',
  20. ]
  21. LINUX_DEPS_ARM = [
  22. 'binutils-aarch64-linux-gnu',
  23. 'libc6-dev-armhf-cross',
  24. 'linux-libc-dev-armhf-cross',
  25. 'g++-arm-linux-gnueabihf',
  26. 'g++-4.8-multilib-arm-linux-gnueabihf',
  27. 'gcc-4.8-multilib-arm-linux-gnueabihf',
  28. ]
  29. LINUX_DEPS_ARM64 = [
  30. 'binutils-aarch64-linux-gnu',
  31. 'libc6-dev-arm64-cross',
  32. 'linux-libc-dev-arm64-cross',
  33. 'g++-4.8-aarch64-linux-gnu',
  34. 'gcc-4.8-aarch64-linux-gnu',
  35. 'gcc-aarch64-linux-gnu',
  36. ]
  37. def main():
  38. os.environ['CI'] = '1'
  39. # Ignore the CXX and CC env in CI.
  40. try:
  41. del os.environ['CC']
  42. del os.environ['CXX']
  43. except KeyError:
  44. pass
  45. target_arch = 'x64'
  46. if os.environ.has_key('TARGET_ARCH'):
  47. target_arch = os.environ['TARGET_ARCH']
  48. if PLATFORM == 'linux' and target_arch == 'x64':
  49. os.environ['DISPLAY'] = ':99.0'
  50. execute(['sh', '-e', '/etc/init.d/xvfb', 'start'])
  51. # CI's npm is not reliable.
  52. npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm'
  53. execute([npm, 'install', '[email protected]'])
  54. log_versions()
  55. # Add "./node_modules/.bin" to the beginning of $PATH, which will ensure
  56. # future "npm" invocations use the right version.
  57. node_bin_dir = os.path.join(SOURCE_ROOT, 'node_modules', '.bin')
  58. os.environ['PATH'] = os.path.pathsep.join([node_bin_dir,
  59. os.environ.get('PATH', '')])
  60. is_release = os.environ.get('ELECTRON_RELEASE', '') == '1'
  61. args = ['--target_arch=' + target_arch]
  62. if not is_release:
  63. args += ['--dev']
  64. run_script('bootstrap.py', args)
  65. if PLATFORM != 'win32':
  66. sys.stderr.write('\nRunning `npm run lint`\n')
  67. sys.stderr.flush()
  68. execute([npm, 'run', 'lint'])
  69. if is_release:
  70. run_script('build.py', ['-c', 'R'])
  71. run_script('create-dist.py')
  72. run_script('upload.py')
  73. else:
  74. run_script('build.py', ['-c', 'D'])
  75. if PLATFORM == 'win32' or target_arch == 'x64':
  76. run_script('test.py', ['--ci', '--rebuild_native_modules'])
  77. run_script('verify-ffmpeg.py')
  78. def run_script(script, args=[]):
  79. sys.stderr.write('\nRunning ' + script +'\n')
  80. sys.stderr.flush()
  81. script = os.path.join(SOURCE_ROOT, 'script', script)
  82. subprocess.check_call([sys.executable, script] + args)
  83. def log_versions():
  84. sys.stderr.write('\nnode --version\n')
  85. sys.stderr.flush()
  86. subprocess.call(['node', '--version'])
  87. sys.stderr.write('\nnpm --version\n')
  88. sys.stderr.flush()
  89. npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm'
  90. subprocess.call([npm, '--version'])
  91. if __name__ == '__main__':
  92. sys.exit(main())