| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-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 = [ | 
					
						
							| 
									
										
										
										
											2015-07-02 04:42:36 +00:00
										 |  |  |   'libc6-dev-armhf-cross', | 
					
						
							|  |  |  |   'linux-libc-dev-armhf-cross', | 
					
						
							|  |  |  |   'g++-arm-linux-gnueabihf', | 
					
						
							|  |  |  | ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-21 21:41:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | def main(): | 
					
						
							| 
									
										
										
										
											2014-02-17 17:50:25 +08:00
										 |  |  |   os.environ['CI'] = '1' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 04:42:36 +00:00
										 |  |  |   target_arch = 'x64' | 
					
						
							|  |  |  |   if os.environ.has_key('TARGET_ARCH'): | 
					
						
							|  |  |  |     target_arch = os.environ['TARGET_ARCH'] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-09 09:22:06 +08:00
										 |  |  |   is_travis = (os.getenv('TRAVIS') == 'true') | 
					
						
							|  |  |  |   if is_travis and sys.platform == 'linux2': | 
					
						
							| 
									
										
										
										
											2014-08-09 09:48:37 +08:00
										 |  |  |     print 'Setup travis CI' | 
					
						
							| 
									
										
										
										
											2014-08-09 09:22:06 +08:00
										 |  |  |     execute(['sudo', 'apt-get', 'update']) | 
					
						
							| 
									
										
										
										
											2015-07-02 04:42:36 +00:00
										 |  |  |     deps = LINUX_DEPS | 
					
						
							|  |  |  |     if target_arch == 'arm': | 
					
						
							| 
									
										
										
										
											2015-07-02 04:47:43 +00:00
										 |  |  |       deps += LINUX_DEPS_ARM | 
					
						
							| 
									
										
										
										
											2015-07-02 04:42:36 +00:00
										 |  |  |     execute(['sudo', 'apt-get', 'install'] + deps) | 
					
						
							| 
									
										
										
										
											2014-08-09 09:48:37 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     os.environ['DISPLAY'] = ':99.0' | 
					
						
							|  |  |  |     execute(['sh', '-e', '/etc/init.d/xvfb', 'start']) | 
					
						
							| 
									
										
										
										
											2014-08-08 23:10:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-26 09:39:24 +08:00
										 |  |  |   rm_rf(os.path.join(SOURCE_ROOT, 'out')) | 
					
						
							| 
									
										
										
										
											2013-12-16 15:15:33 +08:00
										 |  |  |   rm_rf(os.path.join(SOURCE_ROOT, 'node_modules')) | 
					
						
							| 
									
										
										
										
											2014-02-02 19:58:25 +08:00
										 |  |  |   rm_rf(os.path.join(SOURCE_ROOT, 'frameworks')) | 
					
						
							| 
									
										
										
										
											2014-05-18 23:35:07 +08:00
										 |  |  |   rm_rf(os.path.join(SOURCE_ROOT, 'external_binaries')) | 
					
						
							| 
									
										
										
										
											2014-03-11 00:01:06 +08:00
										 |  |  |   rm_rf(os.path.join(SOURCE_ROOT, 'vendor', 'apm', 'node_modules')) | 
					
						
							| 
									
										
										
										
											2013-11-26 11:04:37 +08:00
										 |  |  |   rm_rf(os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor', 'download', | 
					
						
							|  |  |  |                      'libchromiumcontent')) | 
					
						
							| 
									
										
										
										
											2013-11-26 09:39:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 22:45:26 +08:00
										 |  |  |   # CI's npm is not reliable. | 
					
						
							|  |  |  |   npm = 'npm.cmd' if sys.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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 03:08:29 +00:00
										 |  |  |   run_script('bootstrap.py', ['--dev', '--target_arch=' + target_arch]) | 
					
						
							| 
									
										
										
										
											2014-08-09 09:22:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-21 21:41:34 +08:00
										 |  |  |   run_script('cpplint.py') | 
					
						
							| 
									
										
										
										
											2014-03-03 11:31:45 +00:00
										 |  |  |   if sys.platform != 'win32': | 
					
						
							|  |  |  |     run_script('pylint.py') | 
					
						
							| 
									
										
										
										
											2013-09-27 10:49:55 +08:00
										 |  |  |   run_script('coffeelint.py') | 
					
						
							| 
									
										
										
										
											2014-05-18 23:52:14 +08:00
										 |  |  |   run_script('build.py', ['-c', 'Debug']) | 
					
						
							| 
									
										
										
										
											2015-07-02 05:18:05 +00:00
										 |  |  |   if target_arch == 'x64': | 
					
						
							|  |  |  |     run_script('test.py', ['--ci']) | 
					
						
							| 
									
										
										
										
											2013-08-21 21:41:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def run_script(script, args=[]): | 
					
						
							| 
									
										
										
										
											2014-05-09 10:17:02 +08:00
										 |  |  |   print 'Running', script | 
					
						
							| 
									
										
										
										
											2013-08-21 21:41:34 +08:00
										 |  |  |   script = os.path.join(SOURCE_ROOT, 'script', script) | 
					
						
							|  |  |  |   subprocess.check_call([sys.executable, script] + args) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  |   sys.exit(main()) |