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

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') | tools/mac_build_editor_bundle.sh » ('J')
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.exists(build_directory_dict['linux2'])):
ricow1 2013/06/20 12:08:30 this if does not make sense to me, you check if th
kustermann 2013/06/20 14:04:33 Yes, it was supposed to be 'os.path.isdir'.
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 UploadEditor(dart_editor_dmg, directory):
ricow1 2013/06/20 12:08:30 UploadEditor -> UploadInstaller
kustermann 2013/06/20 14:04:33 Done.
84 directory = directory % {'revision' : utils.GetSVNRevision()}
85 uri = '%s/%s' % (GCS_EDITOR_BUCKET, directory)
86 RunProcess([GSUTIL, 'cp', dart_editor_dmg, uri])
43 87
44 def main(): 88 def main():
45 build_py = os.path.join('tools', 'build.py') 89 build_py = os.path.join('tools', 'build.py')
90 mac_build_bundle_py = os.path.join('tools', 'mac_build_editor_bundle.sh')
91 mac_build_dmg_py = os.path.join('tools', 'mac_build_editor_dmg.sh')
92 dart_icns = os.path.join(
93 'editor', 'tools', 'plugins', 'com.google.dart.tools.deploy',
94 'icons', 'dart.icns')
95
46 architectures = ['ia32', 'x64'] 96 architectures = ['ia32', 'x64']
47 test_architectures = ['x64'] 97 test_architectures = ['x64']
48 if sys.platform == 'win32': 98 if sys.platform == 'win32':
49 # Our windows bots pull in only a 32 bit JVM. 99 # Our windows bots pull in only a 32 bit JVM.
50 test_architectures = ['ia32'] 100 test_architectures = ['ia32']
51 101
52 for arch in architectures: 102 for arch in architectures:
53 with bot.BuildStep('Build Editor %s' % arch): 103 with bot.BuildStep('Build Editor %s' % arch):
54 args = [sys.executable, build_py, 104 args = [sys.executable, build_py,
55 '-mrelease', '--arch=%s' % arch, 'editor'] 105 '-mrelease', '--arch=%s' % arch, 'editor', 'create_sdk']
56 print 'Running: %s' % (' '.join(args)) 106 RunProcess(args)
57 sys.stdout.flush()
58 bot.RunProcess(args)
59 107
60 for arch in test_architectures: 108 for arch in test_architectures:
61 editor_executable = GetEditorExecutable('Release', arch) 109 editor_executable = GetEditorExecutable('Release', arch)
62 with bot.BuildStep('Test Editor %s' % arch): 110 with bot.BuildStep('Test Editor %s' % arch):
63 with TempDir() as temp_dir: 111 with TempDir() as temp_dir:
64 args = [editor_executable, '--test', '--auto-exit', '-data', temp_dir] 112 args = [editor_executable, '--test', '--auto-exit', '-data', temp_dir]
65 print 'Running: %s' % (' '.join(args)) 113 RunProcess(args)
66 sys.stdout.flush() 114
67 bot.RunProcess(args) 115 # TODO: Permissions need to be clarified
116 for arch in test_architectures:
117 editor_dir = GetEditorDirectory('Release', arch)
118 dart_sdk = GetDartSdkDirectory('Release', arch)
119 with bot.BuildStep('Build Installer %s' % arch):
120 if sys.platform == 'darwin':
121 with TempDir() as temp_dir:
ricow1 2013/06/20 12:08:30 how about extracting the body here to a seperate f
kustermann 2013/06/20 14:04:33 Done.
122 # Get dartium
123 dartium_directory = DownloadDartium(temp_dir, 'dartium-mac.zip')
124 dartium_bundle_dir = os.path.join(dartium_directory,
125 'Chromium.app')
126
127 # Build the editor bundle
128 darteditor_bundle_dir = os.path.join(temp_dir, 'DartEditor.app')
129 args = [mac_build_bundle_py, darteditor_bundle_dir, editor_dir,
130 dart_sdk, dartium_bundle_dir, dart_icns]
131 RunProcess(args)
132
133 # Build the dmg installer from the editor bundle
134 dart_editor_dmg = os.path.join(temp_dir, 'DartEditor.dmg')
135 args = [mac_build_dmg_py, dart_editor_dmg, darteditor_bundle_dir,
136 dart_icns, 'Dart Editor']
137 RunProcess(args)
138
139 # Upload the dmg installer
140 UploadEditor(dart_editor_dmg, 'dart-editor-mac-%(revision)s.dmg')
141 else:
142 print ("We currently don't build installers for sys.platform=%s"
143 % sys.platform)
68 return 0 144 return 0
69 145
70 if __name__ == '__main__': 146 if __name__ == '__main__':
71 try: 147 try:
72 sys.exit(main()) 148 sys.exit(main())
73 except OSError as e: 149 except OSError as e:
74 sys.exit(e.errno) 150 sys.exit(e.errno)
OLDNEW
« no previous file with comments | « no previous file | tools/build.py » ('j') | tools/mac_build_editor_bundle.sh » ('J')

Powered by Google App Engine
This is Rietveld 408576698