7 from lib.config import PLATFORM
8 from lib.util import execute, rm_rf, scoped_env
11 SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
16 'libgnome-keyring-dev',
26 'libc6-dev-armhf-cross',
27 'linux-libc-dev-armhf-cross',
28 'g++-arm-linux-gnueabihf',
33 os.environ['CI'] = '1'
35 if os.environ.has_key('JANKY_SHA1'):
38 # Ignore the CXX and CC env in CI.
46 if os.environ.has_key('TARGET_ARCH'):
47 target_arch = os.environ['TARGET_ARCH']
49 is_travis = (os.getenv('TRAVIS') == 'true')
50 if is_travis and PLATFORM == 'linux':
51 print 'Setup travis CI'
52 execute(['sudo', 'apt-get', 'update'])
54 if target_arch == 'arm':
55 deps += LINUX_DEPS_ARM
56 execute(['sudo', 'apt-get', 'install'] + deps)
58 execute(['sh', '-e', '/etc/init.d/xvfb', 'start'])
60 if PLATFORM == 'linux':
61 os.environ['DISPLAY'] = ':99.0'
63 # CI's npm is not reliable.
64 npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm'
65 execute([npm, 'install', 'npm@2.12.1'])
68 # Add "./node_modules/.bin" to the beginning of $PATH, which will ensure
69 # future "npm" invocations use the right version.
70 node_bin_dir = os.path.join(SOURCE_ROOT, 'node_modules', '.bin')
71 os.environ['PATH'] = os.path.pathsep.join([node_bin_dir,
72 os.environ.get('PATH', '')])
74 is_release = os.environ.has_key('ELECTRON_RELEASE')
75 args = ['--target_arch=' + target_arch]
78 run_script('bootstrap.py', args)
80 if PLATFORM != 'win32':
81 sys.stderr.write('\nRunning `npm run lint`\n')
83 execute([npm, 'run', 'lint'])
85 run_script('build.py', ['-c', 'R'])
86 run_script('create-dist.py')
87 run_script('upload.py')
89 if PLATFORM == 'win32':
90 os.environ['OUTPUT_TO_FILE'] = 'output.log'
91 run_script('build.py', ['-c', 'D'])
92 if PLATFORM == 'win32' or target_arch == 'x64':
93 run_script('test.py', ['--ci'])
96 def run_script(script, args=[]):
97 sys.stderr.write('\nRunning ' + script +'\n')
99 script = os.path.join(SOURCE_ROOT, 'script', script)
100 subprocess.check_call([sys.executable, script] + args)
104 sys.stderr.write('\nnode --version\n')
106 subprocess.call(['node', '--version'])
108 sys.stderr.write('\nnpm --version\n')
110 npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm'
111 subprocess.call([npm, '--version'])
115 if os.path.isdir('/usr/local/share/nodenv'):
116 nodenv_root = os.path.join(os.environ['HOME'], '.nodenv')
117 os.environ['NODENV_ROOT'] = nodenv_root
118 os.environ['PATH'] = nodenv_root + '/bin:' + nodenv_root + '/shims:' + os.environ['PATH']
119 os.environ['NODENV_VERSION'] = 'v4.5.0'
120 subprocess.check_call(['/usr/local/share/nodenv/bin/nodenv', 'install', os.environ['NODENV_VERSION']])
121 subprocess.check_call(['/usr/local/share/nodenv/bin/nodenv', 'rehash'])
124 if __name__ == '__main__':