electron/brightray/script/bootstrap

107 lines
4.3 KiB
Text
Raw Normal View History

#!/usr/bin/env python
2013-03-13 19:12:05 +00:00
import argparse
import errno
import os
import subprocess
import sys
2013-03-13 19:12:05 +00:00
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
DOWNLOAD_DIR = os.path.join(VENDOR_DIR, 'download')
2013-03-13 19:12:05 +00:00
def main():
args = parse_args()
if (args.libcc_source_path != None and
args.libcc_shared_library_path != None and
args.libcc_static_library_path != None):
if (not os.path.isdir(args.libcc_source_path)):
print "Error: Directory does not exist:", args.libcc_source_path
sys.exit(0)
elif (not os.path.isdir(args.libcc_shared_library_path)):
print "Error: Directory does not exist:", args.libcc_shared_library_path
sys.exit(0)
elif (not os.path.isdir(args.libcc_static_library_path)):
print "Error: Directory does not exist:", args.libcc_static_library_path
sys.exit(0)
elif (args.libcc_source_path != None or
args.libcc_shared_library_path != None or
args.libcc_static_library_path != None):
2015-11-10 14:26:42 +00:00
print "Error: All options of libchromiumcontent are required OR let " \
"brightray choose it"
sys.exit(0)
update_submodules()
setup_libchromiumcontent(args.dev, args.commit, args.target_arch, args.url,
args.libcc_source_path,
args.libcc_shared_library_path,
args.libcc_static_library_path)
2013-03-13 19:12:05 +00:00
def parse_args():
parser = argparse.ArgumentParser(description='Bootstrap this project')
parser.add_argument('-c', '--commit', required=True,
help='The commit of libchromiumcontent to download.')
parser.add_argument('-d', '--dev', action='store_true',
help='Do not download static_library build')
2015-04-11 10:25:47 +00:00
parser.add_argument('--target_arch', required=True,
help='The arch of libchromiumcontent to download.')
parser.add_argument('url', help='The base URL from which to download '
'libchromiumcontent (i.e., the URL you passed to '
'libchromiumcontent\'s script/upload script')
parser.add_argument('--libcc_source_path', required=False,
2015-11-10 14:26:42 +00:00
help='The source path of libchromiumcontent. ' \
'NOTE: All options of libchromiumcontent are '
'required OR let brightray choose it')
parser.add_argument('--libcc_shared_library_path', required=False,
2015-11-10 14:26:42 +00:00
help='The shared library path of libchromiumcontent. ' \
'NOTE: All options of libchromiumcontent are ' \
'required OR let brightray choose it')
parser.add_argument('--libcc_static_library_path', required=False,
2015-11-10 14:26:42 +00:00
help='The static library path of libchromiumcontent. ' \
'NOTE: All options of libchromiumcontent are ' \
'required OR let brightray choose it')
return parser.parse_args()
def update_submodules():
return (subprocess.call(['git', 'submodule', 'sync', '--quiet']) or
subprocess.call(['git', 'submodule', 'update', '--init',
'--recursive']))
def setup_libchromiumcontent(is_dev, commit, target_arch, url,
libcc_source_path,
libcc_shared_library_path,
libcc_static_library_path):
target_dir = os.path.join(DOWNLOAD_DIR, 'libchromiumcontent')
download = os.path.join(VENDOR_DIR, 'libchromiumcontent', 'script',
'download')
args = ['-f', '-c', commit, '--target_arch', target_arch, url, target_dir]
if (libcc_source_path != None and
libcc_shared_library_path != None and
libcc_static_library_path != None):
2015-11-10 14:26:42 +00:00
args += ['--libcc_source_path', libcc_source_path,
'--libcc_shared_library_path', libcc_shared_library_path,
'--libcc_static_library_path', libcc_static_library_path]
mkdir_p(target_dir)
else:
mkdir_p(DOWNLOAD_DIR)
if is_dev:
subprocess.check_call([sys.executable, download] + args)
else:
subprocess.check_call([sys.executable, download, '-s'] + args)
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
raise
if __name__ == '__main__':
sys.exit(main())