| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 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. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 # | 6 # |
| 7 # A script which will be invoked from gyp to create a build of the editor. | 7 # A script which will be invoked from gyp to create a build of the editor. |
| 8 # | 8 # |
| 9 # Usage: ./tools/create_editor.py | 9 # Usage: ./tools/create_editor.py |
| 10 # [--mode <mode>] [--arch <arch>] [--out <output>] [--build <build>] | 10 # [--mode <mode>] [--arch <arch>] [--out <output>] [--build <build>] |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 | 39 |
| 40 def AntPath(): | 40 def AntPath(): |
| 41 parent = join('third_party', 'apache_ant', '1.8.4', 'bin') | 41 parent = join('third_party', 'apache_ant', '1.8.4', 'bin') |
| 42 if utils.IsWindows(): | 42 if utils.IsWindows(): |
| 43 return join(parent, 'ant.bat') | 43 return join(parent, 'ant.bat') |
| 44 else: | 44 else: |
| 45 return join(parent, 'ant') | 45 return join(parent, 'ant') |
| 46 | 46 |
| 47 | 47 |
| 48 def ProcessEditorArchive(archive, outDir): | 48 def ProcessEditorArchive(arch, archive, outDir): |
| 49 tempDir = join(GetEditorTemp(), 'editor.out') | 49 tempDir = join(GetEditorTemp(), 'editor.out') |
| 50 try: | 50 try: |
| 51 os.makedirs(tempDir) | 51 os.makedirs(tempDir) |
| 52 except OSError: | 52 except OSError: |
| 53 # Directory already exists. | 53 # Directory already exists. |
| 54 pass | 54 pass |
| 55 | 55 |
| 56 if utils.IsWindows(): | 56 if utils.IsWindows(): |
| 57 f = zipfile.ZipFile(archive) | 57 f = zipfile.ZipFile(archive) |
| 58 f.extractall(tempDir) | 58 f.extractall(tempDir) |
| 59 f.close() | 59 f.close() |
| 60 else: | 60 else: |
| 61 subprocess.call(['unzip', '-q', archive, '-d', tempDir]) | 61 subprocess.call(['unzip', '-q', archive, '-d', tempDir]) |
| 62 | 62 |
| 63 if arch == 'x64': |
| 64 if utils.GuessOS() == 'macos': |
| 65 inifile = join(tempDir, 'dart', 'DartEditor.app', 'Contents', 'MacOS', |
| 66 'DartEditor.ini') |
| 67 else: |
| 68 inifile = join(tempDir, 'dart', 'DartEditor.ini') |
| 69 Modify64BitDartEditorIni(inifile) |
| 70 |
| 63 for src in glob.glob(join(tempDir, 'dart', '*')): | 71 for src in glob.glob(join(tempDir, 'dart', '*')): |
| 64 shutil.move(src, outDir) | 72 shutil.move(src, outDir) |
| 65 | 73 |
| 66 shutil.rmtree(tempDir) | 74 shutil.rmtree(tempDir) |
| 67 os.unlink(archive) | 75 os.unlink(archive) |
| 68 | 76 |
| 69 | 77 |
| 78 def Modify64BitDartEditorIni(iniFilePath): |
| 79 f = open(iniFilePath, 'r') |
| 80 lines = f.readlines() |
| 81 f.close() |
| 82 lines[lines.index('-Xms40m\n')] = '-Xms256m\n' |
| 83 lines[lines.index('-Xmx1000m\n')] = '-Xmx2000m\n' |
| 84 f = open(iniFilePath, 'w') |
| 85 f.writelines(lines); |
| 86 f.close() |
| 87 |
| 88 |
| 70 def GetEditorTemp(): | 89 def GetEditorTemp(): |
| 71 return join(BUILD, 'editor.build.temp') | 90 return join(BUILD, 'editor.build.temp') |
| 72 | 91 |
| 73 | 92 |
| 74 def GetDownloadCache(): | 93 def GetDownloadCache(): |
| 75 return GetEclipseBuildRoot() | 94 return GetEclipseBuildRoot() |
| 76 | 95 |
| 77 | 96 |
| 78 def GetEclipseBuildRoot(): | 97 def GetEclipseBuildRoot(): |
| 79 return join(BUILD, 'editor.build.cache') | 98 return join(BUILD, 'editor.build.cache') |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 if buildRcpStatus != 0: | 200 if buildRcpStatus != 0: |
| 182 sys.exit(buildRcpStatus) | 201 sys.exit(buildRcpStatus) |
| 183 | 202 |
| 184 # build_rcp.xml will put the built editor archive in the OUTPUT directory | 203 # build_rcp.xml will put the built editor archive in the OUTPUT directory |
| 185 # (dart-editor-macosx.cocoa.x86.zip). It contains the editor application in a | 204 # (dart-editor-macosx.cocoa.x86.zip). It contains the editor application in a |
| 186 # dart/ subdirectory. We unzip the contents of the archive into OUTPUT. It | 205 # dart/ subdirectory. We unzip the contents of the archive into OUTPUT. It |
| 187 # will use the ../dart-sdk directory as its SDK. | 206 # will use the ../dart-sdk directory as its SDK. |
| 188 archives = glob.glob(join(OUTPUT, '*.zip')) | 207 archives = glob.glob(join(OUTPUT, '*.zip')) |
| 189 | 208 |
| 190 if archives: | 209 if archives: |
| 191 ProcessEditorArchive(archives[0], OUTPUT) | 210 ProcessEditorArchive(arch, archives[0], OUTPUT) |
| 192 | 211 |
| 193 if os.path.exists(GetEditorTemp()): | 212 if os.path.exists(GetEditorTemp()): |
| 194 shutil.rmtree(GetEditorTemp()) | 213 shutil.rmtree(GetEditorTemp()) |
| 195 | 214 |
| 196 print('\nEditor build successful') | 215 print('\nEditor build successful') |
| 197 | 216 |
| 198 | 217 |
| 199 if __name__ == '__main__': | 218 if __name__ == '__main__': |
| 200 sys.exit(Main()) | 219 sys.exit(Main()) |
| OLD | NEW |