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 sys
|
2013-04-12 01:46:58 +00:00
|
|
|
|
2015-04-11 09:30:52 +00:00
|
|
|
from lib.config import LIBCHROMIUMCONTENT_COMMIT, BASE_URL, PLATFORM, \
|
2015-04-11 10:26:15 +00:00
|
|
|
enable_verbose_mode, is_verbose_mode, get_target_arch
|
2015-04-12 04:45:18 +00:00
|
|
|
from lib.util import execute_stdout, get_atom_shell_version, scoped_cwd
|
2013-07-01 07:21:27 +00:00
|
|
|
|
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-07-01 07:21:27 +00:00
|
|
|
PYTHON_26_URL = 'https://chromium.googlesource.com/chromium/deps/python_26'
|
2014-04-29 03:07:02 +00:00
|
|
|
NPM = 'npm.cmd' if sys.platform in ['win32', 'cygwin'] else 'npm'
|
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()
|
2015-04-11 09:30:52 +00:00
|
|
|
if not args.yes and PLATFORM != 'win32':
|
2015-03-17 07:19:49 +00:00
|
|
|
check_root()
|
2014-08-12 12:23:59 +00:00
|
|
|
if args.verbose:
|
2014-12-08 17:03:48 +00:00
|
|
|
enable_verbose_mode()
|
2014-12-12 02:33:39 +00:00
|
|
|
if sys.platform == 'cygwin':
|
|
|
|
update_win32_python()
|
2013-07-01 08:12:31 +00:00
|
|
|
|
2015-07-01 06:27:15 +00:00
|
|
|
if PLATFORM != 'win32':
|
|
|
|
update_clang()
|
|
|
|
|
2015-07-02 02:56:56 +00:00
|
|
|
update_submodules()
|
|
|
|
update_node_modules('.')
|
|
|
|
bootstrap_brightray(args.dev, args.url, args.target_arch)
|
|
|
|
|
2015-07-01 09:22:40 +00:00
|
|
|
if args.target_arch == 'arm':
|
|
|
|
download_arm_sysroot()
|
|
|
|
|
2014-06-25 01:05:10 +00:00
|
|
|
create_chrome_version_h()
|
2013-07-02 01:16:56 +00:00
|
|
|
touch_config_gypi()
|
2015-04-12 13:55:17 +00:00
|
|
|
run_update()
|
|
|
|
update_electron_modules('spec', args.target_arch)
|
2013-04-12 01:46:58 +00:00
|
|
|
|
2014-08-12 12:28:18 +00:00
|
|
|
|
2013-06-19 06:32:41 +00:00
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser(description='Bootstrap this project')
|
2013-07-01 08:12:31 +00:00
|
|
|
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)
|
2014-08-12 12:23:59 +00:00
|
|
|
parser.add_argument('-v', '--verbose',
|
|
|
|
action='store_true',
|
|
|
|
help='Prints the output of the subprocesses')
|
2015-04-07 15:40:36 +00:00
|
|
|
parser.add_argument('-d', '--dev', action='store_true',
|
|
|
|
help='Do not download static_library build')
|
2015-03-17 07:19:49 +00:00
|
|
|
parser.add_argument('-y', '--yes', '--assume-yes',
|
|
|
|
action='store_true',
|
|
|
|
help='Run non-interactively by assuming "yes" to all ' \
|
|
|
|
'prompts.')
|
2015-04-11 10:26:15 +00:00
|
|
|
parser.add_argument('--target_arch', default=get_target_arch(),
|
2015-04-11 08:59:44 +00:00
|
|
|
help='Manually specify the arch to build for')
|
2013-06-19 06:32:41 +00:00
|
|
|
return parser.parse_args()
|
2013-04-12 01:46:58 +00:00
|
|
|
|
2015-04-11 08:59:44 +00:00
|
|
|
|
2015-03-17 07:01:33 +00:00
|
|
|
def check_root():
|
|
|
|
if os.geteuid() == 0:
|
|
|
|
print "We suggest not running this as root, unless you're really sure."
|
|
|
|
choice = raw_input("Do you want to continue? [y/N]: ")
|
|
|
|
if choice not in ('y', 'Y'):
|
|
|
|
sys.exit(0)
|
|
|
|
|
2014-08-12 12:28:18 +00:00
|
|
|
|
2013-06-19 06:32:41 +00:00
|
|
|
def update_submodules():
|
2014-12-07 23:47:05 +00:00
|
|
|
execute_stdout(['git', 'submodule', 'sync'])
|
|
|
|
execute_stdout(['git', 'submodule', 'update', '--init', '--recursive'])
|
2013-06-19 06:32:41 +00:00
|
|
|
|
|
|
|
|
2015-04-11 08:59:44 +00:00
|
|
|
def bootstrap_brightray(is_dev, url, target_arch):
|
2013-06-19 06:32:41 +00:00
|
|
|
bootstrap = os.path.join(VENDOR_DIR, 'brightray', 'script', 'bootstrap')
|
2015-04-11 08:59:44 +00:00
|
|
|
args = [
|
|
|
|
'--commit', LIBCHROMIUMCONTENT_COMMIT,
|
|
|
|
'--target_arch', target_arch,
|
|
|
|
url,
|
|
|
|
]
|
2015-04-07 15:40:36 +00:00
|
|
|
if is_dev:
|
|
|
|
args = ['--dev'] + args
|
|
|
|
execute_stdout([sys.executable, bootstrap] + args)
|
2013-06-19 06:32:41 +00:00
|
|
|
|
|
|
|
|
2015-04-12 05:15:11 +00:00
|
|
|
def update_node_modules(dirname, env=None):
|
|
|
|
if env is None:
|
|
|
|
env = os.environ
|
2015-07-02 02:56:56 +00:00
|
|
|
if PLATFORM == 'linux':
|
|
|
|
llvm_dir = os.path.join(SOURCE_ROOT, 'vendor', 'llvm-build',
|
|
|
|
'Release+Asserts', 'bin')
|
|
|
|
env['CC'] = os.path.join(llvm_dir, 'clang')
|
|
|
|
env['CXX'] = os.path.join(llvm_dir, 'clang++')
|
|
|
|
env['npm_config_clang'] = '1'
|
2014-04-28 02:05:22 +00:00
|
|
|
with scoped_cwd(dirname):
|
2014-12-08 17:03:48 +00:00
|
|
|
if is_verbose_mode():
|
2015-04-12 04:45:18 +00:00
|
|
|
execute_stdout([NPM, 'install', '--verbose'], env)
|
2014-12-07 23:52:13 +00:00
|
|
|
else:
|
2015-04-12 04:45:18 +00:00
|
|
|
execute_stdout([NPM, 'install'], env)
|
2013-07-17 08:29:40 +00:00
|
|
|
|
|
|
|
|
2015-04-12 13:55:17 +00:00
|
|
|
def update_electron_modules(dirname, target_arch):
|
2015-04-12 04:45:18 +00:00
|
|
|
env = os.environ.copy()
|
|
|
|
env['npm_config_arch'] = target_arch
|
|
|
|
env['npm_config_target'] = get_atom_shell_version()
|
|
|
|
env['npm_config_disturl'] = 'https://atom.io/download/atom-shell'
|
|
|
|
update_node_modules(dirname, env)
|
2013-07-01 08:06:37 +00:00
|
|
|
|
|
|
|
|
2013-07-01 07:21:27 +00:00
|
|
|
def update_win32_python():
|
|
|
|
with scoped_cwd(VENDOR_DIR):
|
|
|
|
if not os.path.exists('python_26'):
|
2014-12-07 23:47:05 +00:00
|
|
|
execute_stdout(['git', 'clone', PYTHON_26_URL])
|
2013-07-01 07:21:27 +00:00
|
|
|
|
2015-07-01 06:27:15 +00:00
|
|
|
|
|
|
|
def update_clang():
|
|
|
|
execute_stdout([os.path.join(SOURCE_ROOT, 'script', 'update-clang.sh')])
|
|
|
|
|
|
|
|
|
2015-07-01 09:22:40 +00:00
|
|
|
def download_arm_sysroot():
|
2015-07-02 00:47:14 +00:00
|
|
|
execute_stdout([os.path.join(SOURCE_ROOT, 'script', 'install-sysroot.py'),
|
2015-07-01 09:22:40 +00:00
|
|
|
'--arch', 'arm'])
|
|
|
|
|
|
|
|
|
2014-06-25 01:05:10 +00:00
|
|
|
def create_chrome_version_h():
|
|
|
|
version_file = os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor',
|
|
|
|
'libchromiumcontent', 'VERSION')
|
|
|
|
target_file = os.path.join(SOURCE_ROOT, 'atom', 'common', 'chrome_version.h')
|
|
|
|
template_file = os.path.join(SOURCE_ROOT, 'script', 'chrome_version.h.in')
|
|
|
|
|
|
|
|
with open(version_file, 'r') as f:
|
|
|
|
version = f.read()
|
|
|
|
with open(template_file, 'r') as f:
|
|
|
|
template = f.read()
|
2014-12-22 01:39:59 +00:00
|
|
|
if sys.platform in ['win32', 'cygwin']:
|
|
|
|
open_mode = 'wb+'
|
|
|
|
else:
|
|
|
|
open_mode = 'w+'
|
|
|
|
with open(target_file, open_mode) as f:
|
2014-06-25 01:05:10 +00:00
|
|
|
content = template.replace('{PLACEHOLDER}', version.strip())
|
|
|
|
if f.read() != content:
|
|
|
|
f.write(content)
|
|
|
|
|
|
|
|
|
2013-07-02 01:16:56 +00:00
|
|
|
def touch_config_gypi():
|
|
|
|
config_gypi = os.path.join(SOURCE_ROOT, 'vendor', 'node', 'config.gypi')
|
2013-07-02 14:32:14 +00:00
|
|
|
with open(config_gypi, 'w+') as f:
|
|
|
|
content = '\n{}'
|
|
|
|
if f.read() != content:
|
|
|
|
f.write(content)
|
2013-07-02 01:16:56 +00:00
|
|
|
|
|
|
|
|
2015-04-12 13:55:17 +00:00
|
|
|
def run_update():
|
2013-06-24 07:24:30 +00:00
|
|
|
update = os.path.join(SOURCE_ROOT, 'script', 'update.py')
|
2014-12-07 23:47:05 +00:00
|
|
|
execute_stdout([sys.executable, update])
|
2013-06-19 06:32:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|