2014-01-31 04:18:30 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2015-04-11 10:26:15 +00:00
|
|
|
import errno
|
2015-04-11 09:58:19 +00:00
|
|
|
import os
|
2014-06-04 15:24:38 +00:00
|
|
|
import platform
|
|
|
|
import sys
|
|
|
|
|
2017-11-21 10:22:31 +00:00
|
|
|
# URL to the mips64el sysroot image.
|
2018-09-16 17:24:07 +00:00
|
|
|
MIPS64EL_SYSROOT_URL = 'https://github.com/electron' \
|
|
|
|
+ '/debian-sysroot-image-creator/releases/download' \
|
|
|
|
+ '/v0.5.0/debian_jessie_mips64-sysroot.tar.bz2'
|
2017-11-21 10:22:31 +00:00
|
|
|
# URL to the mips64el toolchain.
|
|
|
|
MIPS64EL_GCC = 'gcc-4.8.3-d197-n64-loongson'
|
2018-09-16 17:24:07 +00:00
|
|
|
MIPS64EL_GCC_URL = 'http://ftp.loongnix.org/toolchain/gcc/release/' \
|
|
|
|
+ MIPS64EL_GCC + '.tar.gz'
|
2015-04-11 09:58:19 +00:00
|
|
|
|
2015-07-03 03:45:23 +00:00
|
|
|
BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
|
2016-12-16 07:04:13 +00:00
|
|
|
'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
|
2014-06-04 15:24:38 +00:00
|
|
|
|
2015-04-11 09:30:52 +00:00
|
|
|
PLATFORM = {
|
2014-06-04 15:24:38 +00:00
|
|
|
'cygwin': 'win32',
|
|
|
|
'darwin': 'darwin',
|
|
|
|
'linux2': 'linux',
|
|
|
|
'win32': 'win32',
|
|
|
|
}[sys.platform]
|
2014-12-08 17:00:35 +00:00
|
|
|
|
|
|
|
verbose_mode = False
|
|
|
|
|
2015-04-11 09:58:19 +00:00
|
|
|
|
2015-09-29 02:59:52 +00:00
|
|
|
def get_platform_key():
|
|
|
|
if os.environ.has_key('MAS_BUILD'):
|
|
|
|
return 'mas'
|
|
|
|
else:
|
|
|
|
return PLATFORM
|
|
|
|
|
|
|
|
|
2015-04-11 09:58:19 +00:00
|
|
|
def get_target_arch():
|
2015-07-01 07:47:21 +00:00
|
|
|
try:
|
|
|
|
target_arch_path = os.path.join(__file__, '..', '..', '..', 'vendor',
|
2017-05-10 22:55:00 +00:00
|
|
|
'download', 'libchromiumcontent',
|
|
|
|
'.target_arch')
|
2015-07-01 07:47:21 +00:00
|
|
|
with open(os.path.normpath(target_arch_path)) as f:
|
|
|
|
return f.read().strip()
|
|
|
|
except IOError as e:
|
|
|
|
if e.errno != errno.ENOENT:
|
|
|
|
raise
|
|
|
|
|
2016-05-20 21:20:48 +00:00
|
|
|
return 'x64'
|
2015-04-11 09:58:19 +00:00
|
|
|
|
|
|
|
|
2016-05-25 00:33:44 +00:00
|
|
|
def get_env_var(name):
|
|
|
|
value = os.environ.get('ELECTRON_' + name, '')
|
|
|
|
if not value:
|
|
|
|
# TODO Remove ATOM_SHELL_* fallback values
|
|
|
|
value = os.environ.get('ATOM_SHELL_' + name, '')
|
|
|
|
if value:
|
|
|
|
print 'Warning: Use $ELECTRON_' + name + ' instead of $ATOM_SHELL_' + name
|
|
|
|
return value
|
|
|
|
|
2015-07-08 04:32:47 +00:00
|
|
|
|
2015-04-12 04:00:02 +00:00
|
|
|
def s3_config():
|
2016-05-25 00:33:44 +00:00
|
|
|
config = (get_env_var('S3_BUCKET'),
|
|
|
|
get_env_var('S3_ACCESS_KEY'),
|
|
|
|
get_env_var('S3_SECRET_KEY'))
|
2016-05-24 17:27:46 +00:00
|
|
|
message = ('Error: Please set the $ELECTRON_S3_BUCKET, '
|
|
|
|
'$ELECTRON_S3_ACCESS_KEY, and '
|
|
|
|
'$ELECTRON_S3_SECRET_KEY environment variables')
|
2015-04-12 04:00:02 +00:00
|
|
|
assert all(len(c) for c in config), message
|
|
|
|
return config
|
|
|
|
|
|
|
|
|
2014-12-08 17:00:35 +00:00
|
|
|
def enable_verbose_mode():
|
|
|
|
print 'Running in verbose mode'
|
|
|
|
global verbose_mode
|
|
|
|
verbose_mode = True
|
|
|
|
|
2015-04-11 09:58:19 +00:00
|
|
|
|
2014-12-08 17:00:35 +00:00
|
|
|
def is_verbose_mode():
|
|
|
|
return verbose_mode
|
2016-08-26 00:50:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_zip_name(name, version, suffix=''):
|
2016-08-26 00:51:37 +00:00
|
|
|
arch = get_target_arch()
|
2016-09-01 12:00:29 +00:00
|
|
|
if arch == 'arm':
|
2016-08-26 00:51:37 +00:00
|
|
|
arch += 'v7l'
|
|
|
|
zip_name = '{0}-{1}-{2}-{3}'.format(name, version, get_platform_key(), arch)
|
2016-08-26 00:50:12 +00:00
|
|
|
if suffix:
|
|
|
|
zip_name += '-' + suffix
|
|
|
|
return zip_name + '.zip'
|
2017-11-22 10:29:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
def build_env():
|
|
|
|
env = os.environ.copy()
|
|
|
|
if get_target_arch() == "mips64el":
|
2018-09-16 17:24:07 +00:00
|
|
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(
|
|
|
|
os.path.dirname(os.path.dirname(__file__))))
|
2017-11-22 10:29:39 +00:00
|
|
|
VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
|
|
|
|
gcc_dir = os.path.join(VENDOR_DIR, MIPS64EL_GCC)
|
|
|
|
ldlib_dirs = [
|
|
|
|
gcc_dir + '/usr/x86_64-unknown-linux-gnu/mips64el-redhat-linux/lib',
|
|
|
|
gcc_dir + '/usr/lib64',
|
|
|
|
gcc_dir + '/usr/mips64el-redhat-linux/lib64',
|
|
|
|
gcc_dir + '/usr/mips64el-redhat-linux/sysroot/lib64',
|
|
|
|
gcc_dir + '/usr/mips64el-redhat-linux/sysroot/usr/lib64',
|
|
|
|
]
|
|
|
|
env['LD_LIBRARY_PATH'] = os.pathsep.join(ldlib_dirs)
|
|
|
|
env['PATH'] = os.pathsep.join([gcc_dir + '/usr/bin', env['PATH']])
|
|
|
|
return env
|