Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
|
ricow1
2013/01/08 07:08:26
Since this is a new file - 2013
devoncarew
2013/01/09 21:08:09
Done.
| |
| 4 # for details. All rights reserved. Use of this source code is governed by a | |
| 5 # BSD-style license that can be found in the LICENSE file. | |
| 6 # | |
| 7 # A script which will be invoked from gyp to create a build of the editor. | |
| 8 # | |
| 9 # Usage: ./tools/build.py editor | |
|
ricow1
2013/01/08 07:08:26
I do not think this is valid with the current cl (
devoncarew
2013/01/09 21:08:09
I'll add a TODO: here saying that it doesn't work
| |
| 10 # ./tools/build_editor.py <output> | |
| 11 | |
| 12 import glob | |
|
ricow1
2013/01/08 07:08:26
could we order these alphabetically
devoncarew
2013/01/09 21:08:09
I think they are already.
| |
| 13 import os | |
| 14 import shutil | |
| 15 import subprocess | |
| 16 import sys | |
| 17 import utils | |
| 18 import zipfile | |
| 19 | |
| 20 from os.path import join | |
| 21 | |
| 22 OUTPUT = None | |
| 23 BUILDER_CLOBBER = 'BUILDBOT_CLOBBER' | |
| 24 | |
| 25 OS_CONFIG = { | |
| 26 'win32': 'win32, win32', | |
| 27 'linux': 'linux, gtk', | |
| 28 'macos': 'macosx, cocoa' | |
| 29 } | |
| 30 | |
| 31 ARCH_CONFIG = { | |
| 32 'ia32': 'x86', | |
| 33 'x64': 'x86_64' | |
| 34 } | |
| 35 | |
| 36 def Main(argv): | |
|
ricow1
2013/01/08 07:08:26
move Main method down right above
if __name__ == '
devoncarew
2013/01/09 21:08:09
Done.
| |
| 37 global OUTPUT | |
| 38 | |
| 39 if len(argv) != 2: | |
| 40 print 'usage: tools/create_editor.py <output>' | |
| 41 return 0 | |
| 42 | |
| 43 OUTPUT = argv[1] | |
|
ricow1
2013/01/08 07:08:26
why not use utils.GetBuildDir (see below, we also
| |
| 44 if not os.path.isabs(OUTPUT): | |
| 45 OUTPUT = os.path.abspath(OUTPUT) | |
|
ricow1
2013/01/08 07:08:26
Verify that this is a valid directory (or even bet
| |
| 46 | |
| 47 osName = utils.GuessOS() | |
|
ricow1
2013/01/08 07:08:26
can you do this, I think you need to import our ut
devoncarew
2013/01/09 21:08:09
We are importing it...
| |
| 48 mode = ('release', 'debug')['Debug' in OUTPUT] | |
|
ricow1
2013/01/08 07:08:26
could we add a --mode option instead, defaulting t
devoncarew
2013/01/09 21:08:09
My goal is for this to be callable from our normal
ricow1
2013/01/10 13:23:12
My only concern here is: when we change the name o
devoncarew
2013/01/11 17:08:48
Gotcha, and that makes perfect sense to me. I'll k
| |
| 49 arch = ('ia32', 'x64')['X64' in OUTPUT] | |
|
ricow1
2013/01/08 07:08:26
same as for --mode
| |
| 50 | |
| 51 print "\nBuilding the editor" | |
| 52 print " config : %s, %s, %s" % (osName, arch, mode) | |
| 53 print " output : %s" % OUTPUT | |
| 54 | |
| 55 if GetShouldClobber(): | |
|
ricow1
2013/01/08 07:08:26
I think this still belongs in the annotated steps
devoncarew
2013/01/09 21:08:09
Ah, from looking at tools/clean_output_directory.p
| |
| 56 shutil.rmtree(OUTPUT, True) | |
| 57 shutil.rmtree(GetDownloadCache(), True) | |
| 58 shutil.rmtree(GetEditorTemp(), True) | |
| 59 shutil.rmtree(GetEclipseBuildRoot(), True) | |
| 60 else: | |
| 61 DeleteDirContents(OUTPUT) | |
|
danrubel
2013/01/07 23:07:54
shutil.rmtree(OUTPUT, True) instead of the above l
devoncarew
2013/01/07 23:21:22
Done.
ricow1
2013/01/08 07:08:26
Could we add a TODO here to say to remove when we
ricow1
2013/01/08 07:08:26
I would probably also print that I am deleting the
devoncarew
2013/01/09 21:08:09
I added a printout for when we clean the out direc
| |
| 62 | |
| 63 # macosx, cocoa, x86 & macosx, cocoa, x86_64 | |
|
ricow1
2013/01/08 07:08:26
I have a hard time reading these comments
devoncarew
2013/01/09 21:08:09
I'll add some explaination.
| |
| 64 # win32, win32, x86 & win32, win32, x86_64 | |
| 65 # linux, gtk, x86 & linux, gtk, x86_64 | |
| 66 | |
| 67 buildConfig = OS_CONFIG[osName] + ', ' + ARCH_CONFIG[arch] | |
| 68 | |
| 69 print "\ninvoking build_rcp.xml with buildConfig = [%s]\n" % buildConfig | |
| 70 | |
| 71 sys.stdout.flush() | |
| 72 sys.stderr.flush() | |
| 73 | |
| 74 buildScript = join('editor', 'tools', 'features', | |
| 75 'com.google.dart.tools.deploy.feature_releng', | |
| 76 'build_rcp.xml') | |
| 77 | |
| 78 buildRcpStatus = subprocess.call( | |
| 79 [AntPath(), | |
| 80 '-lib', | |
| 81 join('third_party', 'bzip2', 'bzip2.jar'), | |
| 82 '-Dbuild.out=' + OUTPUT, | |
| 83 '-Dbuild.configs=' + buildConfig, | |
| 84 '-Dbuild.revision=' + utils.GetSVNRevision(), | |
| 85 '-Ddart.version.full=' + utils.GetVersion(), | |
| 86 '-Dbuild.root=' + GetEclipseBuildRoot(), | |
| 87 '-Dbuild.downloads=' + GetDownloadCache(), | |
| 88 '-Dbuild.source=' + os.path.abspath('editor'), | |
| 89 '-Dbuild.dart.sdk=' + GetSdkPath(), | |
| 90 '-Dbuild.no.properties=true', | |
| 91 '-buildfile', | |
| 92 buildScript], | |
| 93 shell=utils.IsWindows()) | |
| 94 | |
| 95 if buildRcpStatus != 0: | |
| 96 sys.exit(buildRcpStatus) | |
| 97 | |
| 98 # build_rcp.xml will put the built editor archive in the OUTPUT directory | |
| 99 # (dart-editor-macosx.cocoa.x86.zip). It contains the editor application in a | |
| 100 # dart/ subdirectory. We unzip the contents of the archive into OUTPUT. It | |
| 101 # will use the ../dart-sdk directory as its SDK. | |
| 102 archives = glob.glob(join(OUTPUT, '*.zip')) | |
| 103 | |
| 104 if (archives): | |
| 105 ProcessEditorArchive(archives[0], OUTPUT) | |
| 106 | |
| 107 if os.path.exists(GetEditorTemp()): | |
| 108 shutil.rmtree(GetEditorTemp()) | |
| 109 | |
| 110 print('\nEditor build successful') | |
| 111 | |
| 112 | |
| 113 def AntPath(): | |
| 114 parent = join('third_party', 'apache_ant', 'v1_7_1', 'bin') | |
| 115 if utils.IsWindows(): | |
| 116 return join(parent, 'ant.bat') | |
| 117 else: | |
| 118 return join(parent, 'ant') | |
| 119 | |
| 120 | |
| 121 def ProcessEditorArchive(archive, outDir): | |
| 122 tempDir = join(GetEditorTemp(), 'editor.out') | |
| 123 os.makedirs(tempDir) | |
| 124 | |
| 125 if utils.IsWindows(): | |
| 126 f = zipfile.ZipFile(archive) | |
| 127 f.extractall(tempDir) | |
| 128 else: | |
| 129 subprocess.call(['unzip', '-q', archive, '-d', tempDir]) | |
| 130 | |
| 131 for src in glob.glob(join(tempDir, 'dart', '*')): | |
| 132 shutil.move(src, outDir) | |
| 133 | |
| 134 shutil.rmtree(tempDir) | |
| 135 os.unlink(archive) | |
| 136 | |
| 137 | |
| 138 def GetEditorTemp(): | |
| 139 return join(GetOutputParent(), 'editor.build.temp') | |
| 140 | |
| 141 | |
| 142 def GetDownloadCache(): | |
| 143 return join(os.path.expanduser('~'), '.editor.download.cache') | |
|
ricow1
2013/01/08 07:08:26
Any reason why not to put this into the output dir
devoncarew
2013/01/09 21:08:09
No, that sounds reasonable - done.
| |
| 144 | |
| 145 | |
| 146 def GetEclipseBuildRoot(): | |
| 147 return join(GetOutputParent(), 'editor.build.cache') | |
| 148 | |
| 149 | |
| 150 def GetSdkPath(): | |
| 151 return join(os.path.dirname(OUTPUT), 'dart-sdk') | |
| 152 | |
| 153 | |
| 154 def GetOutputParent(): | |
| 155 return os.path.dirname(os.path.dirname(OUTPUT)) | |
| 156 | |
| 157 | |
| 158 def DeleteDirContents(directory): | |
| 159 for root, dirs, files in os.walk(directory): | |
| 160 for f in files: | |
| 161 os.unlink(join(root, f)) | |
| 162 for d in dirs: | |
| 163 shutil.rmtree(join(root, d)) | |
| 164 | |
| 165 | |
| 166 def GetShouldClobber(): | |
| 167 return os.environ.get(BUILDER_CLOBBER) == "1" | |
| 168 | |
| 169 | |
| 170 if __name__ == '__main__': | |
| 171 sys.exit(Main(sys.argv)) | |
| OLD | NEW |