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

Unified Diff: tools/create_editor.py

Issue 11343027: Make the editor build callable from tools/build.py (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « editor/tools/features/com.google.dart.tools.deploy.feature_releng/build_rcp.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/create_editor.py
===================================================================
--- tools/create_editor.py (revision 0)
+++ tools/create_editor.py (revision 0)
@@ -0,0 +1,165 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+#
+# A script which will be invoked from gyp to create a build of the editor.
+#
+# TODO(devoncarew): currently this script is not callable from tools/build.py
+# Usage: ./tools/build.py editor
+# -or-
+# Usage: ./tools/build_editor.py <output>
+
+import glob
+import os
+import shutil
+import subprocess
+import sys
+import utils
+import zipfile
+
+from os.path import join
+
+OUTPUT = None
+
+OS_CONFIG = {
+ 'win32': 'win32, win32',
+ 'linux': 'linux, gtk',
+ 'macos': 'macosx, cocoa'
+}
+
+ARCH_CONFIG = {
+ 'ia32': 'x86',
+ 'x64': 'x86_64'
+}
+
+def AntPath():
+ parent = join('third_party', 'apache_ant', 'v1_7_1', 'bin')
+ if utils.IsWindows():
+ return join(parent, 'ant.bat')
+ else:
+ return join(parent, 'ant')
+
+
+def ProcessEditorArchive(archive, outDir):
+ tempDir = join(GetEditorTemp(), 'editor.out')
+ os.makedirs(tempDir)
+
+ if utils.IsWindows():
+ f = zipfile.ZipFile(archive)
+ f.extractall(tempDir)
+ else:
+ subprocess.call(['unzip', '-q', archive, '-d', tempDir])
+
+ for src in glob.glob(join(tempDir, 'dart', '*')):
+ shutil.move(src, outDir)
+
+ shutil.rmtree(tempDir)
+ os.unlink(archive)
+
+
+def GetEditorTemp():
+ return join(GetBuildRoot(), 'editor.build.temp')
+
+
+def GetDownloadCache():
+ return GetEclipseBuildRoot()
+
+
+def GetBuildRoot():
+ root = utils.GetBuildRoot(utils.GuessOS())
+ if os.path.isabs(root):
ricow1 2013/01/10 13:23:12 can you just return os.path.abspath(root) I assume
devoncarew 2013/01/11 17:08:48 I tried it and this works fine - removed the isabs
+ return root
+ else:
+ return os.path.abspath(root)
+
+
+def GetEclipseBuildRoot():
+ return join(GetBuildRoot(), 'editor.build.cache')
+
+
+def GetSdkPath():
+ return join(os.path.dirname(OUTPUT), 'dart-sdk')
+
+
+def GetOutputParent():
+ return os.path.dirname(os.path.dirname(OUTPUT))
+
+
+def Main(argv):
+ global OUTPUT
+
+ if len(argv) != 2:
+ print 'usage: tools/create_editor.py <output>'
+ return 0
+
+ OUTPUT = argv[1]
+ if not os.path.isabs(OUTPUT):
+ OUTPUT = os.path.abspath(OUTPUT)
+
+ osName = utils.GuessOS()
+ mode = ('release', 'debug')['Debug' in OUTPUT]
+ arch = ('ia32', 'x64')['X64' in OUTPUT]
+
+ print "\nBuilding the editor"
+ print " config : %s, %s, %s" % (osName, arch, mode)
+ print " output : %s" % OUTPUT
+
+ print 'cleaning %s' % OUTPUT
+ shutil.rmtree(OUTPUT, True)
+
+ # These are the valid eclipse build configurations that we can produce.
+ # We synthesize these up from the OS_CONFIG and ARCH_CONFIG information.
+ # macosx, cocoa, x86 & macosx, cocoa, x86_64
+ # win32, win32, x86 & win32, win32, x86_64
+ # linux, gtk, x86 & linux, gtk, x86_64
+
+ buildConfig = OS_CONFIG[osName] + ', ' + ARCH_CONFIG[arch]
+
+ print "\ninvoking build_rcp.xml with buildConfig = [%s]\n" % buildConfig
+
+ sys.stdout.flush()
+ sys.stderr.flush()
+
+ buildScript = join('editor', 'tools', 'features',
+ 'com.google.dart.tools.deploy.feature_releng',
+ 'build_rcp.xml')
+
+ buildRcpStatus = subprocess.call(
+ [AntPath(),
+ '-lib',
+ join('third_party', 'bzip2', 'bzip2.jar'),
+ '-Dbuild.out=' + OUTPUT,
+ '-Dbuild.configs=' + buildConfig,
+ '-Dbuild.revision=' + utils.GetSVNRevision(),
+ '-Ddart.version.full=' + utils.GetVersion(),
+ '-Dbuild.root=' + GetEclipseBuildRoot(),
+ '-Dbuild.downloads=' + GetDownloadCache(),
+ '-Dbuild.source=' + os.path.abspath('editor'),
+ '-Dbuild.dart.sdk=' + GetSdkPath(),
+ '-Dbuild.no.properties=true',
+ '-buildfile',
+ buildScript],
+ shell=utils.IsWindows())
+
+ if buildRcpStatus != 0:
+ sys.exit(buildRcpStatus)
+
+ # build_rcp.xml will put the built editor archive in the OUTPUT directory
+ # (dart-editor-macosx.cocoa.x86.zip). It contains the editor application in a
+ # dart/ subdirectory. We unzip the contents of the archive into OUTPUT. It
+ # will use the ../dart-sdk directory as its SDK.
+ archives = glob.glob(join(OUTPUT, '*.zip'))
+
+ if (archives):
+ ProcessEditorArchive(archives[0], OUTPUT)
+
+ if os.path.exists(GetEditorTemp()):
+ shutil.rmtree(GetEditorTemp())
+
+ print('\nEditor build successful')
+
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))
« no previous file with comments | « editor/tools/features/com.google.dart.tools.deploy.feature_releng/build_rcp.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698