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

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

Issue 19523003: Use a utils.TempDir() decorator for temporary files, to make sure we clean up even in case of excep… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | « editor/build/build.py ('k') | 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
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
9 import sys 8 import sys
10 import tempfile
11 9
12 import bot 10 import bot
13 11
14 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 12 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
15 sys.path.append(os.path.join(SCRIPT_DIR, '..')) 13 sys.path.append(os.path.join(SCRIPT_DIR, '..'))
16 import utils 14 import utils
17 15
18 16
19 GSUTIL = utils.GetBuildbotGSUtilPath() 17 GSUTIL = utils.GetBuildbotGSUtilPath()
20 GCS_DARTIUM_BUCKET = "gs://dartium-archive/continuous" 18 GCS_DARTIUM_BUCKET = "gs://dartium-archive/continuous"
21 GCS_EDITOR_BUCKET = "gs://continuous-editor-archive" 19 GCS_EDITOR_BUCKET = "gs://continuous-editor-archive"
22 20
23 class TempDir(object):
24 def __enter__(self):
25 self._temp_dir = tempfile.mkdtemp('eclipse-workspace')
26 return self._temp_dir
27
28 def __exit__(self, *_):
29 shutil.rmtree(self._temp_dir, ignore_errors = True)
30
31 def GetBuildDirectory(mode, arch): 21 def GetBuildDirectory(mode, arch):
32 configuration_dir = mode + arch.upper() 22 configuration_dir = mode + arch.upper()
33 build_directory_dict = { 23 build_directory_dict = {
34 'linux2' : os.path.join('out', configuration_dir), 24 'linux2' : os.path.join('out', configuration_dir),
35 'darwin' : os.path.join('xcodebuild', configuration_dir), 25 'darwin' : os.path.join('xcodebuild', configuration_dir),
36 'win32' : os.path.join('build', configuration_dir), 26 'win32' : os.path.join('build', configuration_dir),
37 } 27 }
38 if sys.platform == 'darwin': 28 if sys.platform == 'darwin':
39 # TODO(kustermann,ricow): Maybe we're able to get rid of this in the future. 29 # 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 30 # We use ninja on bots which use out/ (i.e. what linux2 does) instead of
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 RunProcess([GSUTIL, 'setacl', 'public-read', uri]) 79 RunProcess([GSUTIL, 'setacl', 'public-read', uri])
90 80
91 def CreateAndUploadMacInstaller(arch): 81 def CreateAndUploadMacInstaller(arch):
92 dart_icns = os.path.join( 82 dart_icns = os.path.join(
93 'editor', 'tools', 'plugins', 'com.google.dart.tools.deploy', 83 'editor', 'tools', 'plugins', 'com.google.dart.tools.deploy',
94 'icons', 'dart.icns') 84 'icons', 'dart.icns')
95 mac_build_bundle_py = os.path.join('tools', 'mac_build_editor_bundle.sh') 85 mac_build_bundle_py = os.path.join('tools', 'mac_build_editor_bundle.sh')
96 mac_build_dmg_py = os.path.join('tools', 'mac_build_editor_dmg.sh') 86 mac_build_dmg_py = os.path.join('tools', 'mac_build_editor_dmg.sh')
97 editor_dir = GetEditorDirectory('Release', arch) 87 editor_dir = GetEditorDirectory('Release', arch)
98 dart_sdk = GetDartSdkDirectory('Release', arch) 88 dart_sdk = GetDartSdkDirectory('Release', arch)
99 with TempDir() as temp_dir: 89 with utils.TempDir('eclipse') as temp_dir:
100 # Get dartium 90 # Get dartium
101 dartium_directory = DownloadDartium(temp_dir, 'dartium-mac.zip') 91 dartium_directory = DownloadDartium(temp_dir, 'dartium-mac.zip')
102 dartium_bundle_dir = os.path.join(dartium_directory, 92 dartium_bundle_dir = os.path.join(dartium_directory,
103 'Chromium.app') 93 'Chromium.app')
104 94
105 # Build the editor bundle 95 # Build the editor bundle
106 darteditor_bundle_dir = os.path.join(temp_dir, 'DartEditor.app') 96 darteditor_bundle_dir = os.path.join(temp_dir, 'DartEditor.app')
107 args = [mac_build_bundle_py, darteditor_bundle_dir, editor_dir, 97 args = [mac_build_bundle_py, darteditor_bundle_dir, editor_dir,
108 dart_sdk, dartium_bundle_dir, dart_icns] 98 dart_sdk, dartium_bundle_dir, dart_icns]
109 RunProcess(args) 99 RunProcess(args)
(...skipping 18 matching lines...) Expand all
128 118
129 for arch in architectures: 119 for arch in architectures:
130 with bot.BuildStep('Build Editor %s' % arch): 120 with bot.BuildStep('Build Editor %s' % arch):
131 args = [sys.executable, build_py, 121 args = [sys.executable, build_py,
132 '-mrelease', '--arch=%s' % arch, 'editor', 'create_sdk'] 122 '-mrelease', '--arch=%s' % arch, 'editor', 'create_sdk']
133 RunProcess(args) 123 RunProcess(args)
134 124
135 for arch in test_architectures: 125 for arch in test_architectures:
136 editor_executable = GetEditorExecutable('Release', arch) 126 editor_executable = GetEditorExecutable('Release', arch)
137 with bot.BuildStep('Test Editor %s' % arch): 127 with bot.BuildStep('Test Editor %s' % arch):
138 with TempDir() as temp_dir: 128 with utils.TempDir('eclipse') as temp_dir:
139 args = [editor_executable, '-consoleLog', '--test', '--auto-exit', 129 args = [editor_executable, '-consoleLog', '--test', '--auto-exit',
140 '-data', temp_dir] 130 '-data', temp_dir]
141 RunProcess(args) 131 RunProcess(args)
142 132
143 # TODO: Permissions need to be clarified 133 # TODO: Permissions need to be clarified
144 for arch in test_architectures: 134 for arch in test_architectures:
145 with bot.BuildStep('Build Installer %s' % arch): 135 with bot.BuildStep('Build Installer %s' % arch):
146 if sys.platform == 'darwin': 136 if sys.platform == 'darwin':
147 CreateAndUploadMacInstaller(arch) 137 CreateAndUploadMacInstaller(arch)
148 else: 138 else:
149 print ("We currently don't build installers for sys.platform=%s" 139 print ("We currently don't build installers for sys.platform=%s"
150 % sys.platform) 140 % sys.platform)
151 return 0 141 return 0
152 142
153 if __name__ == '__main__': 143 if __name__ == '__main__':
154 try: 144 try:
155 sys.exit(main()) 145 sys.exit(main())
156 except OSError as e: 146 except OSError as e:
157 sys.exit(e.errno) 147 sys.exit(e.errno)
OLDNEW
« no previous file with comments | « editor/build/build.py ('k') | tools/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698