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

Side by Side Diff: tools/bots/editor.py

Issue 16831019: Initial support for mac installers. Currently only on our editor builders on FYI (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months 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 | « no previous file | tools/build.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 shutil 8 import shutil
8 import sys 9 import sys
9 import tempfile 10 import tempfile
10 11
11 import bot 12 import bot
12 13
14 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
15 sys.path.append(os.path.join(SCRIPT_DIR, '..'))
16 import utils
17
18
19 GSUTIL = utils.GetBuildbotGSUtilPath()
20 GCS_DARTIUM_BUCKET = "gs://dartium-archive/continuous"
21 GCS_EDITOR_BUCKET = "gs://continuous-editor-archive"
22
13 class TempDir(object): 23 class TempDir(object):
14 def __enter__(self): 24 def __enter__(self):
15 self._temp_dir = tempfile.mkdtemp('eclipse-workspace') 25 self._temp_dir = tempfile.mkdtemp('eclipse-workspace')
16 return self._temp_dir 26 return self._temp_dir
17 27
18 def __exit__(self, *_): 28 def __exit__(self, *_):
19 shutil.rmtree(self._temp_dir, ignore_errors = True) 29 shutil.rmtree(self._temp_dir, ignore_errors = True)
20 30
31 def GetBuildDirectory(mode, arch):
32 configuration_dir = mode + arch.upper()
33 build_directory_dict = {
34 'linux2' : os.path.join('out', configuration_dir),
35 'darwin' : os.path.join('xcodebuild', configuration_dir),
36 'win32' : os.path.join('build', configuration_dir),
37 }
38 if sys.platform == 'darwin':
39 # TODO(kustermann,ricow): Maybe we're able to get rid of this in the future.
40 # We use ninja on bots which use out/ (i.e. what linux2 does) instead of
41 # xcodebuild/
42 if (os.path.exists(build_directory_dict['linux2']) and
43 os.path.isdir(build_directory_dict['linux2'])):
44 return build_directory_dict['linux2']
45 return build_directory_dict[sys.platform]
46
47 def GetEditorDirectory(mode, arch):
48 return os.path.join(GetBuildDirectory(mode, arch), 'editor')
49
50 def GetDartSdkDirectory(mode, arch):
51 return os.path.join(GetBuildDirectory(mode, arch), 'dart-sdk')
52
21 def GetEditorExecutable(mode, arch): 53 def GetEditorExecutable(mode, arch):
22 configuration_dir = mode + arch.upper() 54 editor_dir = GetEditorDirectory(mode, arch)
23 linux_path = os.path.join('out', configuration_dir, 'editor')
24 win_path = os.path.join('build', configuration_dir, 'editor')
25 mac_path = os.path.join('xcodebuild', configuration_dir, 'editor')
26
27 if sys.platform == 'darwin': 55 if sys.platform == 'darwin':
28 executable = os.path.join('DartEditor.app', 'Contents', 'MacOS', 56 executable = os.path.join('DartEditor.app', 'Contents', 'MacOS',
29 'DartEditor') 57 'DartEditor')
30 # TODO(kustermann,ricow): Maybe we're able to get rid of this in the future.
31 # We use ninja on bots which use out/ instead of xcodebuild/
32 if os.path.exists(linux_path) and os.path.isdir(linux_path):
33 return os.path.join(linux_path, executable)
34 else:
35 return os.path.join(mac_path, executable)
36 elif sys.platform == 'win32': 58 elif sys.platform == 'win32':
37 return os.path.join(win_path, 'DartEditor.exe') 59 executable = 'DartEditor.exe'
38 elif sys.platform == 'linux2': 60 elif sys.platform == 'linux2':
39 return os.path.join(linux_path, 'DartEditor') 61 executable = 'DartEditor'
40 else: 62 else:
41 raise Exception('Unknown platform %s' % sys.platform) 63 raise Exception('Unknown platform %s' % sys.platform)
64 return os.path.join(editor_dir, executable)
42 65
66 def RunProcess(args):
67 print 'Running: %s' % (' '.join(args))
68 sys.stdout.flush()
69 bot.RunProcess(args)
70
71 def DownloadDartium(temp_dir, zip_file):
72 """Returns the filename of the unpacked archive"""
73 local_path = os.path.join(temp_dir, zip_file)
74 uri = "%s/%s" % (GCS_DARTIUM_BUCKET, zip_file)
75 RunProcess([GSUTIL, 'cp', uri, local_path])
76 RunProcess(['unzip', local_path, '-d', temp_dir])
77 for filename in os.listdir(temp_dir):
78 match = re.search('^dartium-.*-inc-([0-9]+)\.0$', filename)
79 if match:
80 return os.path.join(temp_dir, match.group(0))
81 raise Exception("Couldn't find dartium archive")
82
83 def UploadInstaller(dart_editor_dmg, directory):
84 directory = directory % {'revision' : utils.GetSVNRevision()}
85 uri = '%s/%s' % (GCS_EDITOR_BUCKET, directory)
86 RunProcess([GSUTIL, 'cp', dart_editor_dmg, uri])
87
88 def CreateAndUploadMacInstaller(arch):
89 dart_icns = os.path.join(
90 'editor', 'tools', 'plugins', 'com.google.dart.tools.deploy',
91 'icons', 'dart.icns')
92 mac_build_bundle_py = os.path.join('tools', 'mac_build_editor_bundle.sh')
93 mac_build_dmg_py = os.path.join('tools', 'mac_build_editor_dmg.sh')
94 editor_dir = GetEditorDirectory('Release', arch)
95 dart_sdk = GetDartSdkDirectory('Release', arch)
96 with TempDir() as temp_dir:
97 # Get dartium
98 dartium_directory = DownloadDartium(temp_dir, 'dartium-mac.zip')
99 dartium_bundle_dir = os.path.join(dartium_directory,
100 'Chromium.app')
101
102 # Build the editor bundle
103 darteditor_bundle_dir = os.path.join(temp_dir, 'DartEditor.app')
104 args = [mac_build_bundle_py, darteditor_bundle_dir, editor_dir,
105 dart_sdk, dartium_bundle_dir, dart_icns]
106 RunProcess(args)
107
108 # Build the dmg installer from the editor bundle
109 dart_editor_dmg = os.path.join(temp_dir, 'DartEditor.dmg')
110 args = [mac_build_dmg_py, dart_editor_dmg, darteditor_bundle_dir,
111 dart_icns, 'Dart Editor']
112 RunProcess(args)
113
114 # Upload the dmg installer
115 UploadInstaller(dart_editor_dmg, 'dart-editor-mac-%(revision)s.dmg')
43 116
44 def main(): 117 def main():
45 build_py = os.path.join('tools', 'build.py') 118 build_py = os.path.join('tools', 'build.py')
119
46 architectures = ['ia32', 'x64'] 120 architectures = ['ia32', 'x64']
47 test_architectures = ['x64'] 121 test_architectures = ['x64']
48 if sys.platform == 'win32': 122 if sys.platform == 'win32':
49 # Our windows bots pull in only a 32 bit JVM. 123 # Our windows bots pull in only a 32 bit JVM.
50 test_architectures = ['ia32'] 124 test_architectures = ['ia32']
51 125
52 for arch in architectures: 126 for arch in architectures:
53 with bot.BuildStep('Build Editor %s' % arch): 127 with bot.BuildStep('Build Editor %s' % arch):
54 args = [sys.executable, build_py, 128 args = [sys.executable, build_py,
55 '-mrelease', '--arch=%s' % arch, 'editor'] 129 '-mrelease', '--arch=%s' % arch, 'editor', 'create_sdk']
56 print 'Running: %s' % (' '.join(args)) 130 RunProcess(args)
57 sys.stdout.flush()
58 bot.RunProcess(args)
59 131
60 for arch in test_architectures: 132 for arch in test_architectures:
61 editor_executable = GetEditorExecutable('Release', arch) 133 editor_executable = GetEditorExecutable('Release', arch)
62 with bot.BuildStep('Test Editor %s' % arch): 134 with bot.BuildStep('Test Editor %s' % arch):
63 with TempDir() as temp_dir: 135 with TempDir() as temp_dir:
64 args = [editor_executable, '--test', '--auto-exit', '-data', temp_dir] 136 args = [editor_executable, '--test', '--auto-exit', '-data', temp_dir]
65 print 'Running: %s' % (' '.join(args)) 137 RunProcess(args)
66 sys.stdout.flush() 138
67 bot.RunProcess(args) 139 # TODO: Permissions need to be clarified
140 for arch in test_architectures:
141 with bot.BuildStep('Build Installer %s' % arch):
142 if sys.platform == 'darwin':
143 CreateAndUploadMacInstaller(arch)
144 else:
145 print ("We currently don't build installers for sys.platform=%s"
146 % sys.platform)
68 return 0 147 return 0
69 148
70 if __name__ == '__main__': 149 if __name__ == '__main__':
71 try: 150 try:
72 sys.exit(main()) 151 sys.exit(main())
73 except OSError as e: 152 except OSError as e:
74 sys.exit(e.errno) 153 sys.exit(e.errno)
OLDNEW
« no previous file with comments | « no previous file | tools/build.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698