electron/script/bootstrap.py

100 lines
2.7 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 os
import subprocess
import sys
2013-04-12 01:46:58 +00:00
2014-01-31 04:18:30 +00:00
from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL
from lib.util import scoped_cwd
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')
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()
2014-02-28 12:44:57 +00:00
update_submodules()
update_apm()
update_node_modules()
bootstrap_brightray(args.url)
if sys.platform == '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)
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'])
def bootstrap_brightray(url):
bootstrap = os.path.join(VENDOR_DIR, 'brightray', 'script', 'bootstrap')
subprocess.check_call([sys.executable, bootstrap, '--commit',
LIBCHROMIUMCONTENT_COMMIT, url])
2013-06-19 06:32:41 +00:00
def update_apm():
2013-08-20 14:37:02 +00:00
## NB: Without this, subprocess incorrectly searches for npm.exe
npm_cmd = 'npm'
2013-11-19 12:43:30 +00:00
if sys.platform in ['win32', 'cygwin']:
2013-08-20 14:37:02 +00:00
npm_cmd += '.cmd'
with scoped_cwd(os.path.join('vendor', 'apm')):
2013-08-20 14:37:02 +00:00
subprocess.check_call([npm_cmd, 'install', '.'])
def update_node_modules():
2014-03-16 01:27:15 +00:00
for dirname in ['atom/browser/default_app', '.']:
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())