| Index: tools/build_editor.py
|
| ===================================================================
|
| --- tools/build_editor.py (revision 0)
|
| +++ tools/build_editor.py (revision 0)
|
| @@ -0,0 +1,173 @@
|
| +#!/usr/bin/env python
|
| +#
|
| +# Copyright (c) 2012, 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.
|
| +#
|
| +# Usage: ./tools/build.py editor
|
| +# ./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
|
| +BUILDER_CLOBBER = 'BUILDBOT_CLOBBER'
|
| +
|
| +OS_CONFIG = {
|
| + 'win32': 'win32, win32',
|
| + 'linux': 'linux, gtk',
|
| + 'macos': 'macosx, cocoa'
|
| +}
|
| +
|
| +ARCH_CONFIG = {
|
| + 'ia32': 'x86',
|
| + 'x64': 'x86_64'
|
| +}
|
| +
|
| +def Main(argv):
|
| + global OUTPUT
|
| +
|
| + OUTPUT = argv[1]
|
| +
|
| + osName = utils.GuessOS()
|
| + mode = 'release'
|
| + arch = 'ia32'
|
| +
|
| + if 'DebugIA32' in OUTPUT:
|
| + mode = 'debug'
|
| + elif 'ReleaseX64' in OUTPUT:
|
| + arch = 'x64'
|
| + elif 'DebugX64' in OUTPUT:
|
| + mode = 'debug'
|
| + arch = 'x64'
|
| +
|
| + print "\nBuilding the editor"
|
| + print " config : %s, %s, %s" % (osName, arch, mode)
|
| + print " output : %s" % OUTPUT
|
| +
|
| + if GetShouldClobber():
|
| + shutil.rmtree(OUTPUT, True)
|
| + shutil.rmtree(GetDownloadCache(), True)
|
| + shutil.rmtree(GetEditorTemp(), True)
|
| + shutil.rmtree(GetEclipseBuildRoot(), True)
|
| + else:
|
| + DeleteDirContents(OUTPUT)
|
| +
|
| + # 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')
|
| +
|
| +
|
| +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(GetOutputParent(), 'editor.build.temp')
|
| +
|
| +
|
| +def GetDownloadCache():
|
| + return join(os.path.expanduser('~'), '.editor.download.cache')
|
| +
|
| +
|
| +def GetEclipseBuildRoot():
|
| + return join(GetOutputParent(), 'editor.build.cache')
|
| +
|
| +
|
| +def GetSdkPath():
|
| + return join(os.path.dirname(OUTPUT), 'dart-sdk')
|
| +
|
| +
|
| +def GetOutputParent():
|
| + return os.path.dirname(os.path.dirname(OUTPUT))
|
| +
|
| +
|
| +def DeleteDirContents(directory):
|
| + for root, dirs, files in os.walk(directory):
|
| + for f in files:
|
| + os.unlink(join(root, f))
|
| + for d in dirs:
|
| + shutil.rmtree(join(root, d))
|
| +
|
| +
|
| +def GetShouldClobber():
|
| + return os.environ.get(BUILDER_CLOBBER) == "1"
|
| +
|
| +
|
| +if __name__ == '__main__':
|
| + sys.exit(Main(sys.argv))
|
|
|