Chromium Code Reviews| Index: tools/bots/editor.py |
| diff --git a/tools/bots/editor.py b/tools/bots/editor.py |
| index 80d85d4b02cb4c16a87f5961dc74a987bce9d17d..7b5197ecba5c444e3d142e74d45f4bb25faa23e5 100755 |
| --- a/tools/bots/editor.py |
| +++ b/tools/bots/editor.py |
| @@ -4,12 +4,22 @@ |
| # BSD-style license that can be found in the LICENSE file. |
| import os |
| +import re |
| import shutil |
| import sys |
| import tempfile |
| import bot |
| +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| +sys.path.append(os.path.join(SCRIPT_DIR, '..')) |
| +import utils |
| + |
| + |
| +GSUTIL = utils.GetBuildbotGSUtilPath() |
| +GCS_DARTIUM_BUCKET = "gs://dartium-archive/continuous" |
| +GCS_EDITOR_BUCKET = "gs://continuous-editor-archive" |
| + |
| class TempDir(object): |
| def __enter__(self): |
| self._temp_dir = tempfile.mkdtemp('eclipse-workspace') |
| @@ -18,31 +28,71 @@ class TempDir(object): |
| def __exit__(self, *_): |
| shutil.rmtree(self._temp_dir, ignore_errors = True) |
| -def GetEditorExecutable(mode, arch): |
| +def GetBuildDirectory(mode, arch): |
| configuration_dir = mode + arch.upper() |
| - linux_path = os.path.join('out', configuration_dir, 'editor') |
| - win_path = os.path.join('build', configuration_dir, 'editor') |
| - mac_path = os.path.join('xcodebuild', configuration_dir, 'editor') |
| + build_directory_dict = { |
| + 'linux2' : os.path.join('out', configuration_dir), |
| + 'darwin' : os.path.join('xcodebuild', configuration_dir), |
| + 'win32' : os.path.join('build', configuration_dir), |
| + } |
| + if sys.platform == 'darwin': |
| + # TODO(kustermann,ricow): Maybe we're able to get rid of this in the future. |
| + # We use ninja on bots which use out/ (i.e. what linux2 does) instead of |
| + # xcodebuild/ |
| + if (os.path.exists(build_directory_dict['linux2']) and |
| + 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'.
|
| + return build_directory_dict['linux2'] |
| + return build_directory_dict[sys.platform] |
| + |
| +def GetEditorDirectory(mode, arch): |
| + return os.path.join(GetBuildDirectory(mode, arch), 'editor') |
| +def GetDartSdkDirectory(mode, arch): |
| + return os.path.join(GetBuildDirectory(mode, arch), 'dart-sdk') |
| + |
| +def GetEditorExecutable(mode, arch): |
| + editor_dir = GetEditorDirectory(mode, arch) |
| if sys.platform == 'darwin': |
| executable = os.path.join('DartEditor.app', 'Contents', 'MacOS', |
| 'DartEditor') |
| - # TODO(kustermann,ricow): Maybe we're able to get rid of this in the future. |
| - # We use ninja on bots which use out/ instead of xcodebuild/ |
| - if os.path.exists(linux_path) and os.path.isdir(linux_path): |
| - return os.path.join(linux_path, executable) |
| - else: |
| - return os.path.join(mac_path, executable) |
| elif sys.platform == 'win32': |
| - return os.path.join(win_path, 'DartEditor.exe') |
| + executable = 'DartEditor.exe' |
| elif sys.platform == 'linux2': |
| - return os.path.join(linux_path, 'DartEditor') |
| + executable = 'DartEditor' |
| else: |
| raise Exception('Unknown platform %s' % sys.platform) |
| + return os.path.join(editor_dir, executable) |
| + |
| +def RunProcess(args): |
| + print 'Running: %s' % (' '.join(args)) |
| + sys.stdout.flush() |
| + bot.RunProcess(args) |
| + |
| +def DownloadDartium(temp_dir, zip_file): |
| + """Returns the filename of the unpacked archive""" |
| + local_path = os.path.join(temp_dir, zip_file) |
| + uri = "%s/%s" % (GCS_DARTIUM_BUCKET, zip_file) |
| + RunProcess([GSUTIL, 'cp', uri, local_path]) |
| + RunProcess(['unzip', local_path, '-d', temp_dir]) |
| + for filename in os.listdir(temp_dir): |
| + match = re.search('^dartium-.*-inc-([0-9]+)\.0$', filename) |
| + if match: |
| + return os.path.join(temp_dir, match.group(0)) |
| + raise Exception("Couldn't find dartium archive") |
| +def UploadEditor(dart_editor_dmg, directory): |
|
ricow1
2013/06/20 12:08:30
UploadEditor -> UploadInstaller
kustermann
2013/06/20 14:04:33
Done.
|
| + directory = directory % {'revision' : utils.GetSVNRevision()} |
| + uri = '%s/%s' % (GCS_EDITOR_BUCKET, directory) |
| + RunProcess([GSUTIL, 'cp', dart_editor_dmg, uri]) |
| def main(): |
| build_py = os.path.join('tools', 'build.py') |
| + mac_build_bundle_py = os.path.join('tools', 'mac_build_editor_bundle.sh') |
| + mac_build_dmg_py = os.path.join('tools', 'mac_build_editor_dmg.sh') |
| + dart_icns = os.path.join( |
| + 'editor', 'tools', 'plugins', 'com.google.dart.tools.deploy', |
| + 'icons', 'dart.icns') |
| + |
| architectures = ['ia32', 'x64'] |
| test_architectures = ['x64'] |
| if sys.platform == 'win32': |
| @@ -52,19 +102,45 @@ def main(): |
| for arch in architectures: |
| with bot.BuildStep('Build Editor %s' % arch): |
| args = [sys.executable, build_py, |
| - '-mrelease', '--arch=%s' % arch, 'editor'] |
| - print 'Running: %s' % (' '.join(args)) |
| - sys.stdout.flush() |
| - bot.RunProcess(args) |
| + '-mrelease', '--arch=%s' % arch, 'editor', 'create_sdk'] |
| + RunProcess(args) |
| for arch in test_architectures: |
| editor_executable = GetEditorExecutable('Release', arch) |
| with bot.BuildStep('Test Editor %s' % arch): |
| with TempDir() as temp_dir: |
| args = [editor_executable, '--test', '--auto-exit', '-data', temp_dir] |
| - print 'Running: %s' % (' '.join(args)) |
| - sys.stdout.flush() |
| - bot.RunProcess(args) |
| + RunProcess(args) |
| + |
| + # TODO: Permissions need to be clarified |
| + for arch in test_architectures: |
| + editor_dir = GetEditorDirectory('Release', arch) |
| + dart_sdk = GetDartSdkDirectory('Release', arch) |
| + with bot.BuildStep('Build Installer %s' % arch): |
| + if sys.platform == 'darwin': |
| + 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.
|
| + # Get dartium |
| + dartium_directory = DownloadDartium(temp_dir, 'dartium-mac.zip') |
| + dartium_bundle_dir = os.path.join(dartium_directory, |
| + 'Chromium.app') |
| + |
| + # Build the editor bundle |
| + darteditor_bundle_dir = os.path.join(temp_dir, 'DartEditor.app') |
| + args = [mac_build_bundle_py, darteditor_bundle_dir, editor_dir, |
| + dart_sdk, dartium_bundle_dir, dart_icns] |
| + RunProcess(args) |
| + |
| + # Build the dmg installer from the editor bundle |
| + dart_editor_dmg = os.path.join(temp_dir, 'DartEditor.dmg') |
| + args = [mac_build_dmg_py, dart_editor_dmg, darteditor_bundle_dir, |
| + dart_icns, 'Dart Editor'] |
| + RunProcess(args) |
| + |
| + # Upload the dmg installer |
| + UploadEditor(dart_editor_dmg, 'dart-editor-mac-%(revision)s.dmg') |
| + else: |
| + print ("We currently don't build installers for sys.platform=%s" |
| + % sys.platform) |
| return 0 |
| if __name__ == '__main__': |