electron/script/bootstrap.py

106 lines
2.9 KiB
Python
Raw Normal View History

2013-06-19 06:32:41 +00:00
#!/usr/bin/env python
2013-04-12 01:46:58 +00:00
2013-06-19 06:32:41 +00:00
import argparse
import errno
import os
import subprocess
import sys
2013-04-12 01:46:58 +00:00
from lib.util import *
2013-04-12 01:46:58 +00:00
2013-06-19 06:32:41 +00:00
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
2013-08-03 08:16:32 +00:00
NODE_VERSION = 'v0.10.15'
2013-06-19 06:32:41 +00:00
BASE_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent'
PYTHON_26_URL = 'https://chromium.googlesource.com/chromium/deps/python_26'
2013-04-12 01:46:58 +00:00
2013-06-19 06:32:41 +00:00
def main():
os.chdir(SOURCE_ROOT)
2013-04-12 01:46:58 +00:00
2013-06-19 06:32:41 +00:00
args = parse_args()
if not args.skip_network:
update_submodules()
2013-08-03 08:16:32 +00:00
update_node()
update_apm()
update_node_modules()
bootstrap_brightray(args.url)
2013-08-03 08:16:32 +00:00
if sys.platform is 'cygwin':
update_win32_python()
touch_config_gypi()
2013-06-19 06:32:41 +00:00
update_atom_shell()
2013-04-12 01:46:58 +00:00
2013-04-14 14:48:35 +00:00
2013-06-19 06:32:41 +00:00
def parse_args():
parser = argparse.ArgumentParser(description='Bootstrap this project')
parser.add_argument('-u', '--url',
2013-06-19 06:32:41 +00:00
help='The base URL from which to download '
'libchromiumcontent (i.e., the URL you passed to '
'libchromiumcontent\'s script/upload script',
default=BASE_URL,
required=False)
parser.add_argument('-s', '--skip-network',
help='Skip operations require networking',
action='store_true')
2013-06-19 06:32:41 +00:00
return parser.parse_args()
2013-04-12 01:46:58 +00:00
2013-06-19 06:32:41 +00:00
def update_submodules():
subprocess.check_call(['git', 'submodule', 'sync', '--quiet'])
subprocess.check_call(['git', 'submodule', 'update', '--init',
'--recursive'])
2013-08-03 08:16:32 +00:00
def update_node():
un = os.path.join('script', 'update-node.py')
subprocess.check_call([sys.executable, un, '--version', NODE_VERSION])
2013-06-19 06:32:41 +00:00
def bootstrap_brightray(url):
bootstrap = os.path.join(VENDOR_DIR, 'brightray', 'script', 'bootstrap')
subprocess.check_call([sys.executable, bootstrap, url])
def update_apm():
with scoped_cwd(os.path.join('vendor', 'apm')):
subprocess.check_call(['npm', 'install', '.'])
def update_node_modules():
for dirname in ['.', 'browser/default_app', 'spec']:
update_node_modules_for_dir(dirname);
def update_node_modules_for_dir(dirname):
with scoped_cwd(dirname):
apm = os.path.join(SOURCE_ROOT, 'vendor', 'apm', 'bin', 'apm')
2013-08-06 12:14:28 +00:00
subprocess.check_call(['node', os.path.relpath(apm), 'install'])
def update_win32_python():
with scoped_cwd(VENDOR_DIR):
if not os.path.exists('python_26'):
subprocess.check_call(['git', 'clone', PYTHON_26_URL])
else:
with scoped_cwd('python_26'):
2013-07-24 10:33:49 +00:00
subprocess.check_call(['git', 'pull', '--rebase', 'origin', 'master'])
def touch_config_gypi():
config_gypi = os.path.join(SOURCE_ROOT, 'vendor', 'node', 'config.gypi')
with open(config_gypi, 'w+') as f:
content = '\n{}'
if f.read() != content:
f.write(content)
2013-06-19 06:32:41 +00:00
def update_atom_shell():
2013-06-24 07:24:30 +00:00
update = os.path.join(SOURCE_ROOT, 'script', 'update.py')
subprocess.check_call([sys.executable, update])
2013-06-19 06:32:41 +00:00
if __name__ == '__main__':
sys.exit(main())