oss-fuzz/infra/gcb/build_msan_libs.py

64 lines
1.5 KiB
Python
Raw Normal View History

2017-12-07 02:20:01 +00:00
#!/usr/bin/python2
"""Build base images on Google Cloud Builder.
Usage: build_base_images.py
"""
2018-01-19 03:12:44 +00:00
import datetime
2017-12-07 02:20:01 +00:00
import os
import yaml
from oauth2client.client import GoogleCredentials
from googleapiclient.discovery import build
import build_base_images
def main():
options = {}
if "GCB_OPTIONS" in os.environ:
options = yaml.safe_load(os.environ["GCB_OPTIONS"])
2018-01-19 03:12:44 +00:00
image = 'gcr.io/oss-fuzz-base/msan-builder'
2018-02-27 04:35:41 +00:00
steps = build_base_images.get_steps(['base-msan-builder', 'msan-builder'])
2018-01-19 03:12:44 +00:00
ts = datetime.datetime.utcnow().strftime('%Y%m%d%H%M')
upload_name = 'msan-libs-' + ts + '.zip'
steps.extend([{
'name': image,
'args': [
'bash',
'-c',
'cd /msan && zip -r /workspace/libs.zip .',
],
}, {
'name': 'gcr.io/cloud-builders/gsutil',
'args': [
'cp',
'/workspace/libs.zip',
'gs://oss-fuzz-msan-libs/' + upload_name,
],
}])
2017-12-07 02:20:01 +00:00
build_body = {
2018-01-19 03:12:44 +00:00
'steps': steps,
2017-12-07 02:20:01 +00:00
'timeout': str(6 * 3600) + 's',
'options': options,
'images': [
2018-02-27 04:35:41 +00:00
'gcr.io/oss-fuzz-base/base-msan-builder',
2018-01-19 03:12:44 +00:00
image,
],
2017-12-07 02:20:01 +00:00
}
credentials = GoogleCredentials.get_application_default()
cloudbuild = build('cloudbuild', 'v1', credentials=credentials)
build_info = cloudbuild.projects().builds().create(projectId='oss-fuzz-base', body=build_body).execute()
build_id = build_info['metadata']['build']['id']
print build_id
if __name__ == "__main__":
main()