| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # This zips the SDK and uploads it to Google Storage when run on a buildbot. | 7 # This zips the SDK and uploads it to Google Storage when run on a buildbot. |
| 8 # | 8 # |
| 9 # Usage: upload_sdk.py path_to_sdk | 9 # Usage: upload_sdk.py path_to_sdk |
| 10 | 10 |
| 11 import os | 11 import os |
| 12 import os.path | 12 import os.path |
| 13 import subprocess | 13 import subprocess |
| 14 import sys | 14 import sys |
| 15 import utils | 15 import utils |
| 16 | 16 |
| 17 | 17 |
| 18 GSUTIL = '/b/build/scripts/slave/gsutil' | 18 GSUTIL = '/b/build/scripts/slave/gsutil' |
| 19 GS_SITE = 'gs://' | 19 GS_SITE = 'gs://' |
| 20 GS_DIR = 'dart-dump-render-tree' | 20 GS_DIR = 'dart-dump-render-tree' |
| 21 GS_SDK_DIR = 'sdk' | 21 GS_SDK_DIR = 'sdk' |
| 22 SDK_LOCAL_ZIP = "dart-sdk.zip" |
| 22 | 23 |
| 23 def ExecuteCommand(cmd): | 24 def ExecuteCommand(cmd): |
| 24 """Execute a command in a subprocess. | 25 """Execute a command in a subprocess. |
| 25 """ | 26 """ |
| 26 print 'Executing: ' + ' '.join(cmd) | 27 print 'Executing: ' + ' '.join(cmd) |
| 27 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 28 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 28 output = pipe.communicate() | 29 output = pipe.communicate() |
| 29 if pipe.returncode != 0: | 30 if pipe.returncode != 0: |
| 30 print 'Execution failed: ' + str(output) | 31 print 'Execution failed: ' + str(output) |
| 31 return (pipe.returncode, output) | 32 return (pipe.returncode, output) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #If we are not on a buildbot then fail silently. | 77 #If we are not on a buildbot then fail silently. |
| 77 exit(0) | 78 exit(0) |
| 78 revision = GetSVNRevision() | 79 revision = GetSVNRevision() |
| 79 if revision is None: | 80 if revision is None: |
| 80 sys.stderr.write('Unable to find SVN revision.\n') | 81 sys.stderr.write('Unable to find SVN revision.\n') |
| 81 return 1 | 82 return 1 |
| 82 os.chdir(os.path.dirname(argv[1])) | 83 os.chdir(os.path.dirname(argv[1])) |
| 83 with open(os.path.join(os.path.basename(argv[1]), 'revision'), 'w') as f: | 84 with open(os.path.join(os.path.basename(argv[1]), 'revision'), 'w') as f: |
| 84 f.write(revision + '\n') | 85 f.write(revision + '\n') |
| 85 | 86 |
| 87 if (os.path.basename(os.path.dirname(argv[1])) == |
| 88 utils.GetBuildConf('release', 'ia32')): |
| 89 sdk_suffix = '' |
| 90 else: |
| 91 sdk_suffix = '-debug' |
| 86 # TODO(dgrove) - deal with architectures that are not ia32. | 92 # TODO(dgrove) - deal with architectures that are not ia32. |
| 87 sdk_file = 'dart-%s-%s.zip' % (utils.GuessOS(), revision) | 93 sdk_file = 'dart-%s-%s%s.zip' % (utils.GuessOS(), revision, sdk_suffix) |
| 88 ExecuteCommand(['zip', '-yr', sdk_file, os.path.basename(argv[1])]) | 94 if (os.path.exists(SDK_LOCAL_ZIP)): |
| 89 UploadArchive(sdk_file, | 95 os.remove(SDK_LOCAL_ZIP) |
| 96 ExecuteCommand(['zip', '-yr', SDK_LOCAL_ZIP, os.path.basename(argv[1])]) |
| 97 UploadArchive(SDK_LOCAL_ZIP, |
| 90 GS_SITE + os.path.join(gsdir, GS_SDK_DIR, sdk_file)) | 98 GS_SITE + os.path.join(gsdir, GS_SDK_DIR, sdk_file)) |
| 91 latest_name = 'dart-' + utils.GuessOS() + '-latest' + '.zip' | 99 latest_name = 'dart-%s-latest%s.zip' % (utils.GuessOS(), sdk_suffix) |
| 92 UploadArchive(sdk_file, | 100 UploadArchive(SDK_LOCAL_ZIP, |
| 93 GS_SITE + os.path.join(gsdir, GS_SDK_DIR, latest_name)) | 101 GS_SITE + os.path.join(gsdir, GS_SDK_DIR, latest_name)) |
| 94 | 102 |
| 95 | 103 |
| 96 if __name__ == '__main__': | 104 if __name__ == '__main__': |
| 97 sys.exit(main(sys.argv)) | 105 sys.exit(main(sys.argv)) |
| OLD | NEW |