Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 import shutil | 8 import shutil |
| 9 import sys | 9 import sys |
| 10 import tempfile | 10 import tempfile |
| 11 | 11 |
| 12 import bot | 12 import bot |
| 13 | 13 |
| 14 GCS_BUCKET = 'gs://dart-cross-compiled-binaries' | 14 GCS_BUCKET = 'gs://dart-cross-compiled-binaries' |
| 15 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 15 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 16 sys.path.append(os.path.join(SCRIPT_DIR, '..')) | 16 sys.path.append(os.path.join(SCRIPT_DIR, '..')) |
| 17 | 17 |
| 18 import utils | 18 import utils |
| 19 | 19 |
| 20 CROSS_VM = r'cross-(arm)-vm-linux-(release)' | 20 CROSS_VM = r'cross-(arm)-vm-linux-(release)' |
| 21 TARGET_VM = r'target-(arm)-vm-linux-(release)' | 21 TARGET_VM = r'target-(arm)-vm-linux-(release)' |
| 22 GSUTIL = utils.GetBuildbotGSUtilPath() | 22 GSUTIL = utils.GetBuildbotGSUtilPath() |
| 23 | 23 |
| 24 def run(args): | 24 def run(args): |
| 25 print 'Running: %s' % (' '.join(args)) | 25 print 'Running: %s' % (' '.join(args)) |
| 26 sys.stdout.flush() | 26 sys.stdout.flush() |
| 27 bot.RunProcess(args) | 27 bot.RunProcess(args) |
| 28 | 28 |
| 29 def tarball_name(arch, mode): | |
| 30 return 'cross_build_%s_%s.tar.bz2' % (arch, mode) | |
| 31 | |
| 32 def record_names(name, arch, mode): | |
| 33 return ('record_%s_%s_%s.json' % (name, arch, mode), | |
| 34 'record_output_%s_%s_%s.json' % (name, arch, mode)) | |
|
ricow1
2013/05/28 13:25:52
add blank line
kustermann
2013/05/28 13:39:09
Done.
| |
| 29 def main(): | 35 def main(): |
| 30 name, is_buildbot = bot.GetBotName() | 36 name, is_buildbot = bot.GetBotName() |
| 31 build_py = os.path.join('tools', 'build.py') | 37 build_py = os.path.join('tools', 'build.py') |
| 32 test_py = os.path.join('tools', 'test.py') | 38 test_py = os.path.join('tools', 'test.py') |
| 39 execute_testcases_py = os.path.join('tools', 'execute_recorded_testcases.py') | |
| 40 test_args = [sys.executable, test_py, '--progress=line', '--report', | |
| 41 '--time', '--compiler=none', '--runtime=vm', '--write-debug-log'] | |
| 33 | 42 |
| 34 cross_vm_pattern_match = re.match(CROSS_VM, name) | 43 cross_vm_pattern_match = re.match(CROSS_VM, name) |
| 35 target_vm_pattern_match = re.match(TARGET_VM, name) | 44 target_vm_pattern_match = re.match(TARGET_VM, name) |
| 36 if cross_vm_pattern_match: | 45 if cross_vm_pattern_match: |
| 37 arch = cross_vm_pattern_match.group(1) | 46 arch = cross_vm_pattern_match.group(1) |
| 38 mode = cross_vm_pattern_match.group(2) | 47 mode = cross_vm_pattern_match.group(2) |
| 39 | 48 |
| 49 tarball = tarball_name(arch, mode) | |
| 50 (recording, recording_out) = record_names('tests', arch, mode) | |
| 51 (checked_recording, checked_recording_out) = record_names( | |
| 52 'checked_tests', arch, mode) | |
| 53 | |
| 54 temporary_files = [tarball, recording, recording_out, checked_recording, | |
| 55 checked_recording_out] | |
| 40 bot.Clobber() | 56 bot.Clobber() |
| 41 with bot.BuildStep('Build %s %s' % (arch, mode)): | 57 try: |
| 42 args = [sys.executable, build_py, | 58 num_run = int(os.environ['BUILDBOT_ANNOTATED_STEPS_RUN']) |
| 43 '-m%s' % mode, '--arch=%s' % arch, 'runtime'] | 59 if num_run == 1: |
| 44 run(args) | 60 # FIXME(kustermann/ricow): Remove this hack as soon as our bots are |
|
ricow1
2013/05/28 13:25:52
how about extracting the body of both the branches
kustermann
2013/05/28 13:39:09
Done.
| |
| 61 # running on precise (i.e. then we can install the normal crosscompiler) | |
| 62 os.environ['TARGET_TOOLCHAIN_PREFIX'] = ('/home/chrome-bot/codesourcery' | |
| 63 '/bin/arm-none-linux-gnueabi') | |
| 64 with bot.BuildStep('Build %s %s' % (arch, mode)): | |
| 65 args = [sys.executable, build_py, | |
| 66 '-m%s' % mode, '--arch=%s' % arch, 'runtime'] | |
| 45 | 67 |
| 46 tarball = 'cross_build_%s_%s.tar.bz2' % (arch, mode) | 68 run(args) |
| 47 try: | 69 with bot.BuildStep('Create build tarball'): |
| 48 with bot.BuildStep('Create build tarball'): | 70 run(['tar', '-cjf', tarball, '--exclude=**/obj', |
| 49 run(['tar', '-cjf', tarball, '--exclude=**/obj', | 71 '--exclude=**/obj.host', '--exclude=**/obj.target', |
| 50 '--exclude=**/obj.host', '--exclude=**/obj.target', | 72 '--exclude=**/*analyzer*', 'out/']) |
| 51 '--exclude=**/*analyzer*', 'out/']) | |
| 52 | 73 |
| 53 with bot.BuildStep('Upload build tarball'): | 74 with bot.BuildStep('Upload build tarball'): |
| 54 uri = "%s/%s" % (GCS_BUCKET, tarball) | 75 uri = "%s/%s" % (GCS_BUCKET, tarball) |
| 55 run([GSUTIL, 'cp', tarball, uri]) | 76 run([GSUTIL, 'cp', tarball, uri]) |
| 56 run([GSUTIL, 'setacl', 'public-read', uri]) | 77 run([GSUTIL, 'setacl', 'public-read', uri]) |
| 78 | |
| 79 with bot.BuildStep('prepare tests'): | |
| 80 uri = "%s/%s" % (GCS_BUCKET, recording) | |
| 81 run(test_args + ['--mode=' + mode, '--arch=' + arch, | |
| 82 '--record_to_file=' + recording]) | |
| 83 run([GSUTIL, 'cp', recording, uri]) | |
| 84 run([GSUTIL, 'setacl', 'public-read', uri]) | |
| 85 | |
| 86 with bot.BuildStep('prepare checked_tests'): | |
| 87 uri = "%s/%s" % (GCS_BUCKET, checked_recording) | |
| 88 run(test_args + ['--mode=' + mode, '--arch=' + arch, '--checked', | |
| 89 '--record_to_file=' + checked_recording]) | |
| 90 run([GSUTIL, 'cp', checked_recording, uri]) | |
| 91 run([GSUTIL, 'setacl', 'public-read', uri]) | |
| 92 elif num_run == 2: | |
| 93 with bot.BuildStep('tests'): | |
| 94 uri = "%s/%s" % (GCS_BUCKET, recording) | |
| 95 run([GSUTIL, 'cp', uri, recording]) | |
| 96 run(test_args + ['--mode=' + mode, '--arch=' + arch, | |
| 97 '--replay_from_file=' + recording_out]) | |
| 98 | |
| 99 with bot.BuildStep('checked_tests'): | |
| 100 uri = "%s/%s" % (GCS_BUCKET, checked_recording) | |
| 101 run([GSUTIL, 'cp', uri, checked_recording]) | |
| 102 run(test_args + ['--mode=' + mode, '--arch=' + arch, '--checked', | |
| 103 '--replay_from_file=' + checked_recording_out]) | |
| 104 else: | |
| 105 raise Exception("Invalid annotated steps run") | |
| 57 finally: | 106 finally: |
| 58 if os.path.exists(tarball): | 107 for path in temporary_files: |
| 59 os.remove(tarball) | 108 if os.path.exists(path): |
| 109 pass | |
| 110 os.remove(path) | |
| 60 elif target_vm_pattern_match: | 111 elif target_vm_pattern_match: |
| 61 arch = target_vm_pattern_match.group(1) | 112 arch = target_vm_pattern_match.group(1) |
| 62 mode = target_vm_pattern_match.group(2) | 113 mode = target_vm_pattern_match.group(2) |
| 63 | 114 |
| 115 tarball = tarball_name(arch, mode) | |
| 116 (recording, recording_out) = record_names('tests', arch, mode) | |
| 117 (checked_recording, checked_recording_out) = record_names( | |
| 118 'checked_tests', arch, mode) | |
| 119 | |
| 120 temporary_files = [tarball, recording, recording_out, checked_recording, | |
| 121 checked_recording_out] | |
| 64 bot.Clobber() | 122 bot.Clobber() |
| 65 tarball = 'cross_build_%s_%s.tar.bz2' % (arch, mode) | |
| 66 try: | 123 try: |
| 67 test_args = [sys.executable, test_py, '--progress=line', '--report', | |
| 68 '--time', '--mode=' + mode, '--arch=' + arch, '--compiler=none', | |
| 69 '--runtime=vm', '--write-debug-log'] | |
| 70 | 124 |
| 71 with bot.BuildStep('Fetch build tarball'): | 125 with bot.BuildStep('Fetch build tarball'): |
| 72 run([GSUTIL, 'cp', "%s/%s" % (GCS_BUCKET, tarball), tarball]) | 126 run([GSUTIL, 'cp', "%s/%s" % (GCS_BUCKET, tarball), tarball]) |
| 73 | 127 |
| 74 with bot.BuildStep('Unpack build tarball'): | 128 with bot.BuildStep('Unpack build tarball'): |
| 75 run(['tar', '-xjf', tarball]) | 129 run(['tar', '-xjf', tarball]) |
| 76 | 130 |
| 77 with bot.BuildStep('tests'): | 131 with bot.BuildStep('execute tests'): |
| 78 run(test_args) | 132 uri = "%s/%s" % (GCS_BUCKET, recording) |
| 133 uri_out = "%s/%s" % (GCS_BUCKET, recording_out) | |
| 134 run([GSUTIL, 'cp', uri, recording]) | |
| 135 run(['python', execute_testcases_py, recording, recording_out]) | |
| 136 run([GSUTIL, 'cp', recording_out, uri_out]) | |
| 137 run([GSUTIL, 'setacl', 'public-read', uri_out]) | |
| 79 | 138 |
| 80 with bot.BuildStep('checked_tests'): | 139 with bot.BuildStep('execute checked_tests'): |
| 81 run(test_args + ['--checked']) | 140 uri = "%s/%s" % (GCS_BUCKET, checked_recording) |
| 141 uri_out = "%s/%s" % (GCS_BUCKET, checked_recording_out) | |
| 142 run([GSUTIL, 'cp', uri, checked_recording]) | |
| 143 run(['python', execute_testcases_py, checked_recording, | |
| 144 checked_recording_out]) | |
| 145 run([GSUTIL, 'cp', recording_out, uri_out]) | |
| 146 run([GSUTIL, 'setacl', 'public-read', uri_out]) | |
| 82 finally: | 147 finally: |
| 83 if os.path.exists(tarball): | 148 for path in : |
| 84 os.remove(tarball) | 149 if os.path.exists(path): |
| 150 pass | |
| 151 os.remove(path) | |
| 85 else: | 152 else: |
| 86 raise Exception("Unknown builder name %s" % name) | 153 raise Exception("Unknown builder name %s" % name) |
| 87 | 154 |
| 88 if __name__ == '__main__': | 155 if __name__ == '__main__': |
| 89 sys.exit(main()) | 156 sys.exit(main()) |
| OLD | NEW |