Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import hashlib | |
| 7 import json | |
| 6 import os | 8 import os |
| 7 import sys | 9 import sys |
| 8 | 10 |
| 9 import buildbot_common | 11 import buildbot_common |
| 10 import build_utils | 12 import build_utils |
| 11 | 13 |
| 12 | 14 |
| 15 def build_and_upload_mono(sdk_revision, pepper_revision, sdk_url, upload_path): | |
| 16 install_dir = 'naclmono' | |
| 17 buildbot_common.RemoveDir(install_dir) | |
| 18 | |
| 19 revision_opt = ['--sdk-revision', sdk_revision] if sdk_revision else [] | |
| 20 url_opt = ['--sdk-url', sdk_url] if sdk_url else [] | |
| 21 | |
| 22 buildbot_common.Run([sys.executable, 'nacl-mono-builder.py', | |
| 23 '--arch', 'x86-32', '--install-dir', install_dir] + | |
| 24 revision_opt + url_opt + args) | |
| 25 buildbot_common.Run([sys.executable, 'nacl-mono-builder.py', | |
| 26 '--arch', 'x86-64', '--install-dir', install_dir] + | |
| 27 revision_opt + url_opt + args) | |
| 28 buildbot_common.Run([sys.executable, 'nacl-mono-archive.py', | |
| 29 '--upload-path', upload_path, | |
| 30 '--pepper-revision', pepper_revision, | |
| 31 '--install-dir', install_dir] + args) | |
| 32 | |
| 33 def get_sdk_build_info(): | |
| 34 '''Returns a list of dictionaries for versions of NaCl Mono to build which are | |
| 35 out of date compared to the SDKs available to naclsdk''' | |
| 36 | |
| 37 # Get a copy of the naclsdk manifest file | |
| 38 buildbot_common.Run([buildbot_common.GetGsutil(), 'cp', | |
| 39 'gs://nativeclient-mirror/nacl/nacl_sdk/naclsdk_manifest2.json', '.']) | |
| 40 manifest_file = open('naclsdk_manifest2.json', 'r') | |
| 41 sdk_manifest = json.loads(manifest_file.read()) | |
| 42 manifest_file.close() | |
| 43 | |
| 44 pepper_infos = [] | |
| 45 for key, value in sdk_manifest.items(): | |
| 46 if key == 'bundles': | |
| 47 # Pick current pepper_* bundles, need pepper_19 or greater to build Mono | |
| 48 bundles = filter(lambda b: (b['stability'] in ['stable', 'beta', 'dev'] | |
| 49 and 'pepper_' in b['name']) | |
| 50 and b['version'] >= 19, value) | |
| 51 for b in bundles: | |
| 52 newdict = {} | |
| 53 newdict['pepper_revision'] = str(b['version']) | |
| 54 linux_arch = filter(lambda u: u['host_os'] == 'linux', b['archives']) | |
| 55 newdict['sdk_url'] = linux_arch[0]['url'] | |
| 56 newdict['sdk_revision'] = b['revision'] | |
| 57 newdict['stability'] = b['stability'] | |
| 58 newdict['naclmono_name'] = 'naclmono_' + newdict['pepper_revision'] | |
| 59 pepper_infos.append(newdict) | |
| 60 | |
| 61 # Get a copy of the naclmono manifest file | |
| 62 buildbot_common.Run([buildbot_common.GetGsutil(), 'cp', | |
| 63 'gs://nativeclient-mirror/nacl/nacl_sdk/naclmono_manifest.json', '.']) | |
|
binji
2012/04/20 17:55:17
could you make globals for these paths, I didn't r
elijahtaylor1
2012/04/20 18:52:50
Done.
| |
| 64 manifest_file = open('naclmono_manifest.json', 'r') | |
| 65 mono_manifest = json.loads(manifest_file.read()) | |
| 66 manifest_file.close() | |
| 67 | |
| 68 ret = [] | |
| 69 # Check to see if we need to rebuild mono based on sdk revision | |
| 70 for key, value in mono_manifest.items(): | |
| 71 if key == 'bundles': | |
| 72 for info in pepper_infos: | |
| 73 bundle = filter(lambda b: b['name'] == info['naclmono_name'], value) | |
| 74 if len(bundle) == 0: | |
| 75 info['naclmono_rev'] = '1' | |
| 76 ret.append(info) | |
| 77 else: | |
| 78 if info['sdk_revision'] != bundle[0]['sdk_revision']: | |
| 79 info['naclmono_rev'] = str(bundle[0]['revision']+1) | |
|
binji
2012/04/20 17:55:17
why +1?
elijahtaylor1
2012/04/20 18:52:50
Added a comment
| |
| 80 ret.append(info) | |
| 81 | |
| 82 return ret | |
| 83 | |
| 84 def update_mono_sdk_json(infos): | |
| 85 '''Update the naclmono manifest with the newly built packages''' | |
| 86 if len(infos) == 0: | |
| 87 return | |
| 88 | |
| 89 manifest_file = open('naclmono_manifest.json', 'r') | |
| 90 mono_manifest = json.loads(manifest_file.read()) | |
| 91 manifest_file.close() | |
| 92 | |
| 93 newbundles = {} | |
| 94 for info in infos: | |
| 95 bundle = {} | |
| 96 bundle['name'] = info['naclmono_name'] | |
| 97 bundle['description'] = 'Mono for Native Client' | |
| 98 bundle['stability'] = info['stability'] | |
| 99 bundle['recommended'] = 'no' | |
| 100 bundle['version'] = 'experimental' | |
| 101 archive = {} | |
| 102 sha1_hash = hashlib.sha1() | |
| 103 f = open(info['naclmono_name'] + '.bz2', 'rb') | |
| 104 sha1_hash.update(f.read()) | |
| 105 archive['size'] = f.tell() | |
| 106 f.close() | |
| 107 archive['checksum'] = { 'sha1': sha1_hash.hexdigest() } | |
| 108 archive['host_os'] = 'all' | |
| 109 archive['url'] = ('https://commondatastorage.googleapis.com/' | |
|
binji
2012/04/20 17:55:17
I don't think this is the right path.
This will be
elijahtaylor1
2012/04/20 18:52:50
Added a comment below to show where this naclmono_
| |
| 110 'nativeclient-mirror/nacl/nacl_sdk/%s/%s/%s.bz2' | |
| 111 % (info['naclmono_name'], info['naclmono_rev'], | |
| 112 info['naclmono_name'])) | |
| 113 bundle['archives'] = [archive] | |
| 114 bundle['revision'] = int(info['naclmono_rev']) | |
| 115 bundle['sdk_revision'] = int(info['sdk_revision']) | |
| 116 | |
| 117 # Insert this new bundle into the manifest, | |
| 118 # probably overwriting an existing bundle. | |
| 119 for key, value in mono_manifest.items(): | |
| 120 if key == 'bundles': | |
| 121 existing = filter(lambda b: b['name'] == info['naclmono_name'], value) | |
| 122 if len(existing) > 0: | |
| 123 loc = value.index(existing) | |
| 124 value[loc] = bundle | |
| 125 else: | |
| 126 value.append(bundle) | |
| 127 | |
| 128 # Write out the file locally, then upload to its known location. | |
| 129 manifest_file = open('naclmono_manifest.json', 'w') | |
| 130 manifest_file.write(json.dumps(mono_manifest, sort_keys=False, indent=2)) | |
| 131 manifest_file.close() | |
| 132 buildbot_common.Run([buildbot_common.GetGsutil(), 'cp', | |
| 133 'naclmono_manifest.json', 'gs://nativeclient-mirror/nacl/nacl_sdk/']) | |
| 134 | |
| 135 | |
| 13 def main(args): | 136 def main(args): |
| 14 args = args[1:] | 137 args = args[1:] |
| 15 | 138 |
| 16 buildbot_revision = os.environ.get('BUILDBOT_REVISION', '') | 139 buildbot_revision = os.environ.get('BUILDBOT_REVISION', '') |
| 17 assert buildbot_revision | 140 buildername = os.environ.get('BUILDBOT_BUILDERNAME', '') |
| 18 sdk_revision = buildbot_revision.split(':')[0] | |
| 19 pepper_revision = build_utils.ChromeMajorVersion() | |
| 20 | 141 |
| 21 install_dir = 'naclmono' | 142 if buildername == 'linux-sdk-mono32': |
| 22 buildbot_common.RemoveDir(install_dir) | 143 assert buildbot_revision |
| 23 | 144 sdk_revision = buildbot_revision.split(':')[0] |
| 24 buildbot_common.Run([sys.executable, 'nacl-mono-builder.py', | 145 pepper_revision = build_utils.ChromeMajorVersion() |
| 25 '--arch', 'x86-32', '--install-dir', install_dir] + args) | 146 build_and_upload_mono(sdk_revision, pepper_revision, None, sdk_revision) |
|
binji
2012/04/20 17:55:17
There is a discrepancy here:
the mono tarballs are
elijahtaylor1
2012/04/20 18:52:50
I could be wrong, but I think maybe trunk.<rev> is
| |
| 26 buildbot_common.Run([sys.executable, 'nacl-mono-builder.py', | 147 elif buildername == 'linux-sdk-mono64': |
| 27 '--arch', 'x86-64', '--install-dir', install_dir] + args) | 148 infos = get_sdk_build_info() |
| 28 buildbot_common.Run([sys.executable, 'nacl-mono-archive.py', | 149 for info in infos: |
| 29 '--sdk-revision', sdk_revision, | 150 build_and_upload_mono(None, info['pepper_revision'], info['sdk_url'], |
| 30 '--pepper-revision', pepper_revision, | 151 info['naclmono_name'] + '/' + info['naclmono_rev']) |
| 31 '--install-dir', install_dir] + args) | 152 update_mono_sdk_json(infos) |
| 153 | |
| 32 | 154 |
| 33 | 155 |
| 34 if __name__ == '__main__': | 156 if __name__ == '__main__': |
| 35 sys.exit(main(sys.argv)) | 157 sys.exit(main(sys.argv)) |
| OLD | NEW |