| 
									
										
										
										
											2013-08-21 11:15:22 +08:00
										 |  |  | #!/usr/bin/env python | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import os | 
					
						
							|  |  |  | import subprocess | 
					
						
							| 
									
										
										
										
											2013-08-21 21:41:34 +08:00
										 |  |  | import sys | 
					
						
							| 
									
										
										
										
											2013-08-21 11:15:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 10:35:40 +08:00
										 |  |  | from lib.config import PLATFORM | 
					
						
							| 
									
										
										
										
											2014-08-09 09:22:06 +08:00
										 |  |  | from lib.util import execute, rm_rf, scoped_env | 
					
						
							| 
									
										
										
										
											2013-11-26 09:39:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-21 11:15:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-21 21:41:34 +08:00
										 |  |  | SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-08 23:32:51 +08:00
										 |  |  | LINUX_DEPS = [ | 
					
						
							| 
									
										
										
										
											2014-10-21 15:01:24 +08:00
										 |  |  |   'libdbus-1-dev', | 
					
						
							| 
									
										
										
										
											2014-11-15 10:37:27 +08:00
										 |  |  |   'libgconf2-dev', | 
					
						
							| 
									
										
										
										
											2014-08-08 23:32:51 +08:00
										 |  |  |   'libgnome-keyring-dev', | 
					
						
							|  |  |  |   'libgtk2.0-dev', | 
					
						
							|  |  |  |   'libnotify-dev', | 
					
						
							| 
									
										
										
										
											2015-07-07 14:42:02 +08:00
										 |  |  |   'libnss3-dev', | 
					
						
							| 
									
										
										
										
											2015-12-08 17:32:42 +08:00
										 |  |  |   'libxtst-dev', | 
					
						
							| 
									
										
										
										
											2017-07-28 12:24:44 -04:00
										 |  |  | ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LINUX_DEPS_NO_ARM = [ | 
					
						
							| 
									
										
										
										
											2015-07-02 05:27:12 +00:00
										 |  |  |   'gcc-multilib', | 
					
						
							|  |  |  |   'g++-multilib', | 
					
						
							| 
									
										
										
										
											2014-08-08 23:32:51 +08:00
										 |  |  | ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 04:47:43 +00:00
										 |  |  | LINUX_DEPS_ARM = [ | 
					
						
							| 
									
										
										
										
											2017-07-28 12:24:44 -04:00
										 |  |  |    'binutils-aarch64-linux-gnu', | 
					
						
							|  |  |  |    'libc6-dev-armhf-cross', | 
					
						
							|  |  |  |    'linux-libc-dev-armhf-cross', | 
					
						
							|  |  |  |    'g++-arm-linux-gnueabihf', | 
					
						
							|  |  |  |    'g++-4.8-multilib-arm-linux-gnueabihf', | 
					
						
							|  |  |  |    'gcc-4.8-multilib-arm-linux-gnueabihf', | 
					
						
							| 
									
										
										
										
											2015-07-02 04:42:36 +00:00
										 |  |  | ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-08 06:59:45 +00:00
										 |  |  | LINUX_DEPS_ARM64 = [ | 
					
						
							|  |  |  |    'binutils-aarch64-linux-gnu', | 
					
						
							|  |  |  |    'libc6-dev-arm64-cross', | 
					
						
							|  |  |  |    'linux-libc-dev-arm64-cross', | 
					
						
							|  |  |  |    'g++-4.8-aarch64-linux-gnu', | 
					
						
							|  |  |  |    'gcc-4.8-aarch64-linux-gnu', | 
					
						
							|  |  |  |    'gcc-aarch64-linux-gnu', | 
					
						
							|  |  |  | ] | 
					
						
							| 
									
										
										
										
											2013-08-21 21:41:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | def main(): | 
					
						
							| 
									
										
										
										
											2014-02-17 17:50:25 +08:00
										 |  |  |   os.environ['CI'] = '1' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-26 19:24:28 +09:00
										 |  |  |   # Ignore the CXX and CC env in CI. | 
					
						
							|  |  |  |   try: | 
					
						
							|  |  |  |     del os.environ['CC'] | 
					
						
							|  |  |  |     del os.environ['CXX'] | 
					
						
							|  |  |  |   except KeyError: | 
					
						
							|  |  |  |     pass | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 04:42:36 +00:00
										 |  |  |   target_arch = 'x64' | 
					
						
							|  |  |  |   if os.environ.has_key('TARGET_ARCH'): | 
					
						
							|  |  |  |     target_arch = os.environ['TARGET_ARCH'] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-21 14:46:22 -07:00
										 |  |  |   if PLATFORM == 'linux' and target_arch == 'x64': | 
					
						
							| 
									
										
										
										
											2017-07-21 14:35:06 -07:00
										 |  |  |     os.environ['DISPLAY'] = ':99.0' | 
					
						
							|  |  |  |     execute(['sh', '-e', '/etc/init.d/xvfb', 'start']) | 
					
						
							| 
									
										
										
										
											2017-07-21 13:28:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 22:45:26 +08:00
										 |  |  |   # CI's npm is not reliable. | 
					
						
							| 
									
										
										
										
											2015-07-03 10:35:40 +08:00
										 |  |  |   npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm' | 
					
						
							| 
									
										
										
										
											2015-07-03 08:54:03 +08:00
										 |  |  |   execute([npm, 'install', 'npm@2.12.1']) | 
					
						
							| 
									
										
										
										
											2015-07-02 22:45:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-07 10:03:16 -07:00
										 |  |  |   log_versions() | 
					
						
							| 
									
										
										
										
											2016-08-21 07:30:14 -03:00
										 |  |  |   # Add "./node_modules/.bin" to the beginning of $PATH, which will ensure | 
					
						
							|  |  |  |   # future "npm" invocations use the right version. | 
					
						
							|  |  |  |   node_bin_dir = os.path.join(SOURCE_ROOT, 'node_modules', '.bin') | 
					
						
							|  |  |  |   os.environ['PATH'] = os.path.pathsep.join([node_bin_dir, | 
					
						
							|  |  |  |                                              os.environ.get('PATH', '')]) | 
					
						
							| 
									
										
										
										
											2016-04-07 10:03:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-21 10:05:12 -07:00
										 |  |  |   is_release = os.environ.get('ELECTRON_RELEASE', '') == '1' | 
					
						
							| 
									
										
										
										
											2015-07-03 10:14:13 +08:00
										 |  |  |   args = ['--target_arch=' + target_arch] | 
					
						
							|  |  |  |   if not is_release: | 
					
						
							|  |  |  |     args += ['--dev'] | 
					
						
							|  |  |  |   run_script('bootstrap.py', args) | 
					
						
							| 
									
										
										
										
											2014-08-09 09:22:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 10:35:40 +08:00
										 |  |  |   if PLATFORM != 'win32': | 
					
						
							| 
									
										
										
										
											2016-03-30 14:21:07 -07:00
										 |  |  |     sys.stderr.write('\nRunning `npm run lint`\n') | 
					
						
							|  |  |  |     sys.stderr.flush() | 
					
						
							|  |  |  |     execute([npm, 'run', 'lint']) | 
					
						
							| 
									
										
										
										
											2017-03-31 21:01:55 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 10:14:13 +08:00
										 |  |  |   if is_release: | 
					
						
							|  |  |  |     run_script('build.py', ['-c', 'R']) | 
					
						
							|  |  |  |     run_script('create-dist.py') | 
					
						
							| 
									
										
										
										
											2015-07-03 13:43:20 +08:00
										 |  |  |     run_script('upload.py') | 
					
						
							| 
									
										
										
										
											2015-08-21 14:18:04 +08:00
										 |  |  |   else: | 
					
						
							| 
									
										
										
										
											2015-07-03 10:14:13 +08:00
										 |  |  |     run_script('build.py', ['-c', 'D']) | 
					
						
							| 
									
										
										
										
											2016-04-30 17:17:23 +09:00
										 |  |  |     if PLATFORM == 'win32' or target_arch == 'x64': | 
					
						
							| 
									
										
										
										
											2017-05-25 15:41:05 -07:00
										 |  |  |       run_script('test.py', ['--ci', '--rebuild_native_modules']) | 
					
						
							| 
									
										
										
										
											2017-03-29 16:23:30 -07:00
										 |  |  |       run_script('verify-ffmpeg.py') | 
					
						
							| 
									
										
										
										
											2013-08-21 21:41:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def run_script(script, args=[]): | 
					
						
							| 
									
										
										
										
											2015-09-03 17:20:48 +09:00
										 |  |  |   sys.stderr.write('\nRunning ' + script +'\n') | 
					
						
							|  |  |  |   sys.stderr.flush() | 
					
						
							| 
									
										
										
										
											2013-08-21 21:41:34 +08:00
										 |  |  |   script = os.path.join(SOURCE_ROOT, 'script', script) | 
					
						
							|  |  |  |   subprocess.check_call([sys.executable, script] + args) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-07 10:03:16 -07:00
										 |  |  | def log_versions(): | 
					
						
							|  |  |  |   sys.stderr.write('\nnode --version\n') | 
					
						
							|  |  |  |   sys.stderr.flush() | 
					
						
							| 
									
										
										
										
											2016-04-07 10:15:31 -07:00
										 |  |  |   subprocess.call(['node', '--version']) | 
					
						
							| 
									
										
										
										
											2016-04-07 10:03:16 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   sys.stderr.write('\nnpm --version\n') | 
					
						
							|  |  |  |   sys.stderr.flush() | 
					
						
							| 
									
										
										
										
											2016-04-07 10:14:47 -07:00
										 |  |  |   npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm' | 
					
						
							| 
									
										
										
										
											2016-04-07 10:15:31 -07:00
										 |  |  |   subprocess.call([npm, '--version']) | 
					
						
							| 
									
										
										
										
											2016-04-07 10:03:16 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-21 21:41:34 +08:00
										 |  |  | if __name__ == '__main__': | 
					
						
							| 
									
										
										
										
											2015-07-03 14:36:45 +08:00
										 |  |  |   sys.exit(main()) |