2013-04-28 19:59:12 +04:00
|
|
|
#!/usr/bin/env python
|
2013-02-28 17:53:18 +04:00
|
|
|
|
2017-11-08 23:49:48 +03:00
|
|
|
import argparse
|
2013-04-28 19:59:12 +04:00
|
|
|
import os
|
2014-10-10 13:54:26 +04:00
|
|
|
import platform
|
2013-04-28 19:59:12 +04:00
|
|
|
import subprocess
|
|
|
|
import sys
|
2013-03-07 17:43:45 +04:00
|
|
|
|
2016-05-08 04:44:18 +03:00
|
|
|
from lib.util import get_vs_env
|
|
|
|
|
2013-03-07 17:43:45 +04:00
|
|
|
|
2013-04-28 19:59:12 +04:00
|
|
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
2013-05-09 17:06:13 +04:00
|
|
|
# We're in JENKINS_ROOT/workspace/libchromiumcontent. Walk up to JENKINS_ROOT.
|
|
|
|
JENKINS_ROOT = os.path.dirname(os.path.dirname(SOURCE_ROOT))
|
|
|
|
S3_CREDENTIALS_FILE = os.path.join(JENKINS_ROOT, 'config', 's3credentials')
|
2013-03-07 17:43:45 +04:00
|
|
|
|
|
|
|
|
2013-04-28 19:59:12 +04:00
|
|
|
def main():
|
2017-11-08 23:49:48 +03:00
|
|
|
args = parse_args()
|
|
|
|
skip_upload = args.skip_upload
|
2017-08-22 20:20:35 +03:00
|
|
|
|
2017-11-08 23:49:48 +03:00
|
|
|
if (not skip_upload and
|
|
|
|
not 'LIBCHROMIUMCONTENT_S3_ACCESS_KEY' in os.environ and
|
2017-08-22 20:20:35 +03:00
|
|
|
not 'LIBCHROMIUMCONTENT_S3_BUCKET' in os.environ and
|
|
|
|
not 'LIBCHROMIUMCONTENT_S3_SECRET_KEY' in os.environ):
|
2017-11-08 23:49:48 +03:00
|
|
|
if os.path.isfile(S3_CREDENTIALS_FILE):
|
|
|
|
copy_to_environment(S3_CREDENTIALS_FILE)
|
|
|
|
else:
|
|
|
|
skip_upload = True
|
|
|
|
if (skip_upload):
|
|
|
|
print 'WARNING: Upload to S3 will be skipped.'
|
2017-07-13 19:16:22 +03:00
|
|
|
# Use by gclient to distinguish bot builds
|
|
|
|
os.environ['CHROME_HEADLESS'] = '1'
|
|
|
|
|
2017-01-04 21:02:46 +03:00
|
|
|
if 'TARGET_ARCH' in os.environ:
|
2017-11-08 23:49:48 +03:00
|
|
|
return run_ci(['-t', os.environ['TARGET_ARCH']], skip_upload)
|
2017-01-04 21:02:46 +03:00
|
|
|
|
2014-10-11 19:46:29 +04:00
|
|
|
if sys.platform in ['win32', 'cygwin']:
|
2017-11-08 23:49:48 +03:00
|
|
|
return (run_ci(['-t', 'x64'], skip_upload) or
|
|
|
|
run_ci(['-t', 'ia32'], skip_upload))
|
2015-07-08 05:19:02 +03:00
|
|
|
elif sys.platform == 'linux2':
|
2017-11-08 23:49:48 +03:00
|
|
|
return (run_ci(['-t', 'x64'], skip_upload) or
|
|
|
|
run_ci(['-t', 'ia32'], skip_upload) or
|
|
|
|
run_ci(['-t', 'arm'], skip_upload) or
|
|
|
|
run_ci(['-t', 'arm64'], skip_upload))
|
2015-06-09 12:09:30 +03:00
|
|
|
else:
|
2017-11-08 23:49:48 +03:00
|
|
|
return run_ci([], skip_upload)
|
2013-03-07 17:43:45 +04:00
|
|
|
|
2017-11-08 23:49:48 +03:00
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser(description='Run CI build')
|
|
|
|
parser.add_argument('-s', '--skip_upload', action='store_true',
|
|
|
|
help='Skip uploading to S3')
|
|
|
|
return parser.parse_args()
|
2013-02-28 17:53:18 +04:00
|
|
|
|
2013-04-28 19:59:12 +04:00
|
|
|
def copy_to_environment(credentials_file):
|
|
|
|
with open(credentials_file, 'r') as f:
|
|
|
|
for line in f:
|
|
|
|
key, value = line.strip().split('=')
|
|
|
|
key = key.replace('JANKY_ARTIFACTS_', 'LIBCHROMIUMCONTENT_')
|
|
|
|
value = value.strip("'")
|
|
|
|
os.environ[key] = value
|
|
|
|
|
|
|
|
|
2014-10-10 13:54:26 +04:00
|
|
|
def os_version():
|
|
|
|
if sys.platform in ['win32', 'cygwin']:
|
|
|
|
return platform.system() + ' ' + platform.release() + ' ' + platform.version()
|
|
|
|
elif sys.platform == 'darwin':
|
|
|
|
mac_ver = platform.mac_ver()
|
|
|
|
return 'Mac OS X ' + mac_ver[0] + ' ' + mac_ver[2]
|
|
|
|
else:
|
|
|
|
return platform.platform()
|
|
|
|
|
|
|
|
|
2017-11-08 23:49:48 +03:00
|
|
|
def run_ci(args, skip_upload):
|
2016-05-08 04:44:18 +03:00
|
|
|
if sys.platform in ['win32', 'cygwin']:
|
|
|
|
target_arch = args[1]
|
|
|
|
# Set build env for VS.
|
|
|
|
if target_arch == 'x64':
|
|
|
|
vs_env = get_vs_env('14.0', 'x86_amd64')
|
|
|
|
elif target_arch == 'ia32':
|
|
|
|
vs_env = get_vs_env('14.0', 'amd64_x86')
|
|
|
|
os.environ.update(vs_env)
|
|
|
|
|
2015-06-09 12:09:30 +03:00
|
|
|
return (run_script('bootstrap') or
|
2017-06-27 01:44:24 +03:00
|
|
|
run_script('update', ['--clean'] + args) or
|
2015-06-09 12:09:30 +03:00
|
|
|
run_script('build', args) or
|
|
|
|
run_script('create-dist', args) or
|
2017-11-08 23:49:48 +03:00
|
|
|
run_script('upload', args, skip_upload))
|
2015-06-09 12:09:30 +03:00
|
|
|
|
|
|
|
|
2017-11-08 23:49:48 +03:00
|
|
|
def run_script(script, args=[], skip_run=False):
|
|
|
|
if skip_run:
|
|
|
|
return True
|
2014-10-11 19:46:29 +04:00
|
|
|
script = os.path.join('script', script)
|
|
|
|
sys.stderr.write('+ {0}\n'.format(script))
|
|
|
|
sys.stderr.flush()
|
|
|
|
return subprocess.call([sys.executable, script] + args)
|
2013-04-28 19:59:12 +04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|