Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: dart/tools/upload_sdk.py

Issue 84703004: Removed dart.gyp:upload_sdk target and tools/upload_sdk.py (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/pkg/docgen/bin/upload_docgen.py ('k') | dart/tools/utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2
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
5 # found in the LICENSE file.
6
7 # This zips the SDK and uploads it to Google Storage when run on a buildbot.
8 #
9 # Usage: upload_sdk.py path_to_sdk
10
11 import os
12 import os.path
13 import platform
14 import subprocess
15 import sys
16 import utils
17
18
19 GSUTIL = utils.GetBuildbotGSUtilPath()
20 HAS_SHELL = False
21 if platform.system() == 'Windows':
22 HAS_SHELL = True
23 GS_SITE = 'gs://'
24 GS_DIR = 'dart-dump-render-tree'
25 GS_SDK_DIR = 'sdk'
26 SDK_LOCAL_ZIP = "dart-sdk.zip"
27 SDK_LOCAL_TARGZ = "dart-sdk.tar.gz"
28
29 def ExecuteCommand(cmd):
30 """Execute a command in a subprocess.
31 """
32 print 'Executing: ' + ' '.join(cmd)
33 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
34 shell=HAS_SHELL)
35 output = pipe.communicate()
36 if pipe.returncode != 0:
37 print 'Execution failed: ' + str(output)
38 return (pipe.returncode, output)
39
40
41 def UploadArchive(source, target):
42 """Upload an archive zip file to Google storage.
43 """
44 # Upload file.
45 cmd = [GSUTIL, 'cp', source, target]
46 (status, output) = ExecuteCommand(cmd)
47 if status != 0:
48 return status
49 print 'Uploaded: ' + output[0]
50
51 cmd = [GSUTIL, 'setacl', 'public-read', target]
52 (status, output) = ExecuteCommand(cmd)
53 return status
54
55
56 def Usage(progname):
57 sys.stderr.write('Usage: %s path_to_sdk\n' % progname)
58
59
60 def main(argv):
61 #allow local editor builds to deploy to a different bucket
62 if os.environ.has_key('DART_LOCAL_BUILD'):
63 gsdir = os.environ['DART_LOCAL_BUILD']
64 else:
65 gsdir = GS_DIR
66
67 if not os.path.exists(argv[1]):
68 sys.stderr.write('Path not found: %s\n' % argv[1])
69 Usage(argv[0])
70 return 1
71
72 if not os.path.exists(GSUTIL):
73 #TODO: Determine where we are running, if we're running on a buildbot we
74 #should fail with a message.
75 #If we are not on a buildbot then fail silently.
76 utils.Touch(os.path.join(argv[1], 'upload.stamp'))
77 exit(0)
78
79 revision = utils.GetSVNRevision()
80 if revision is None:
81 sys.stderr.write('Unable to find SVN revision.\n')
82 return 1
83
84 os.chdir(os.path.dirname(argv[1]))
85
86 if (os.path.basename(os.path.dirname(argv[1])) ==
87 utils.GetBuildConf('release', 'ia32')):
88 sdk_suffix = ''
89 else:
90 sdk_suffix = '-debug'
91 # TODO(dgrove) - deal with architectures that are not ia32.
92 sdk_file_zip = 'dart-%s-%s%s.zip' % (utils.GuessOS(), revision, sdk_suffix)
93 sdk_file_targz = 'dart-%s-%s%s.tar.gz' % (utils.GuessOS(), revision,
94 sdk_suffix)
95 if (os.path.exists(SDK_LOCAL_ZIP)):
96 os.remove(SDK_LOCAL_ZIP)
97 if (os.path.exists(SDK_LOCAL_TARGZ)):
98 os.remove(SDK_LOCAL_TARGZ)
99 if platform.system() == 'Windows':
100 # Windows does not have zip. We use the 7 zip utility in third party.
101 ExecuteCommand([os.path.join('..', 'third_party', '7zip', '7za'), 'a',
102 '-tzip', SDK_LOCAL_ZIP, os.path.basename(argv[1])])
103 else:
104 ExecuteCommand(['zip', '-yr', SDK_LOCAL_ZIP, os.path.basename(argv[1])])
105 ExecuteCommand(['tar', 'czf', SDK_LOCAL_TARGZ, os.path.basename(argv[1])])
106 UploadArchive(SDK_LOCAL_ZIP,
107 GS_SITE + '/'.join([gsdir, GS_SDK_DIR, sdk_file_zip]))
108 if (os.path.exists(SDK_LOCAL_TARGZ)):
109 UploadArchive(SDK_LOCAL_TARGZ,
110 GS_SITE + '/'.join([gsdir, GS_SDK_DIR, sdk_file_targz]))
111 latest_name_zip = 'dart-%s-latest%s.zip' % (utils.GuessOS(), sdk_suffix)
112 latest_name_targz = 'dart-%s-latest%s.tar.gz' % (utils.GuessOS(), sdk_suffix)
113 UploadArchive(SDK_LOCAL_ZIP,
114 GS_SITE + '/'.join([gsdir, GS_SDK_DIR, latest_name_zip]))
115 if (os.path.exists(SDK_LOCAL_TARGZ)):
116 UploadArchive(SDK_LOCAL_TARGZ,
117 GS_SITE + '/'.join([gsdir, GS_SDK_DIR, latest_name_targz]))
118 utils.Touch('upload.stamp')
119
120
121 if __name__ == '__main__':
122 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « dart/pkg/docgen/bin/upload_docgen.py ('k') | dart/tools/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698