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

Side by Side Diff: dart/editor/build/build.py

Issue 57483005: Add tools/download_file.dart helper + download_contentshell shell/bat script included in the editor… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/tools/dartium/download_file.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import glob 7 import glob
8 import gsutil 8 import gsutil
9 import imp 9 import imp
10 import optparse 10 import optparse
11 import os 11 import os
12 import re 12 import re
13 import shutil 13 import shutil
14 import stat
14 import subprocess 15 import subprocess
15 import sys 16 import sys
16 import tempfile 17 import tempfile
17 import zipfile 18 import zipfile
18 import ziputils 19 import ziputils
19 20
20 from os.path import join 21 from os.path import join
21 22
22 BUILD_OS = None 23 BUILD_OS = None
23 DART_PATH = None 24 DART_PATH = None
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 959
959 for zipFile in _FindRcpZipFiles(out_dir): 960 for zipFile in _FindRcpZipFiles(out_dir):
960 basename = os.path.basename(zipFile) 961 basename = os.path.basename(zipFile)
961 if renameMap[basename] != None: 962 if renameMap[basename] != None:
962 os.rename(zipFile, join(os.path.dirname(zipFile), renameMap[basename])) 963 os.rename(zipFile, join(os.path.dirname(zipFile), renameMap[basename]))
963 964
964 965
965 def PostProcessEditorBuilds(out_dir, buildos): 966 def PostProcessEditorBuilds(out_dir, buildos):
966 """Post-process the created RCP builds""" 967 """Post-process the created RCP builds"""
967 with utils.TempDir('editor_scratch') as scratch_dir: 968 with utils.TempDir('editor_scratch') as scratch_dir:
969
970 def instantiate_download_script_template(destination, replacements):
971 """Helper function for replacing variables in the
972 tools/dartium/download_shellscript_templates.{sh,bat} scripts. It will
973 write the final download script to [destination] after doing all
974 replacements given in the [replacements] dictionary."""
975 template_location = {
976 'windows' : join(
977 DART_DIR, 'tools', 'dartium', 'download_shellscript_template.bat'),
978 'linux' : join(
979 DART_DIR, 'tools', 'dartium', 'download_shellscript_template.sh'),
980 'macos' : join(
981 DART_DIR, 'tools', 'dartium', 'download_shellscript_template.sh'),
982 }[SYSTEM]
983
984 with open(template_location) as fd:
985 content = fd.read()
986 for key in replacements:
987 content = content.replace(key, replacements[key])
988 with open(destination, 'w') as fd:
989 fd.write(content)
990
991 # Make it executable if we are not on windows
992 if SYSTEM != 'windows':
993 os.chmod(destination, os.stat(destination).st_mode | stat.S_IEXEC)
994
995 def add_download_scripts(zipFile, arch):
996 shell_ending = {
997 'windows' : '.bat',
998 'linux' : '.sh',
999 'macos' : '.sh',
1000 }[SYSTEM]
1001
1002 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RELEASE)
1003
1004 # We're adding download scripts to the chromium directory.
1005 # The directory tree will look like this after that:
1006 # dart/dart-sdk/bin/dart{,.exe}
1007 # /chromium/download_contentshell.{sh,bat}
1008 # /chromium/download_dartium_debug.{sh,bat}
1009 # /chromium/download_file.dart
1010
1011 # Add download_file.dart helper utility to the zip file.
1012 f = ziputils.ZipUtil(zipFile, buildos)
1013 f.AddFile(join(DART_DIR, 'tools', 'dartium', 'download_file.dart'),
1014 'dart/chromium/download_file.dart')
1015
1016 # Add content shell download script
1017 contentshell_name = namer.dartium_variant_zipfilename(
1018 'content_shell', SYSTEM, arch, 'release')
1019 contentshell_download_script = join(scratch_dir, 'download_contentshell')
1020 instantiate_download_script_template(contentshell_download_script, {
1021 'VAR_DESTINATION' : contentshell_name,
1022 'VAR_DOWNLOAD_URL' :
1023 ("http://dartlang.org/editor/update/channels/%s/%s/dartium/%s"
1024 % (CHANNEL, REVISION, contentshell_name)),
1025 })
1026 f.AddFile(contentshell_download_script,
1027 'dart/chromium/download_contentshell%s' % shell_ending)
1028
1029 # Add dartium debug download script
1030 dartium_debug_name = namer.dartium_variant_zipfilename(
1031 'dartium', SYSTEM, arch, 'debug')
1032 dartium_download_script = join(scratch_dir, 'download_dartium_debug')
1033 instantiate_download_script_template(dartium_download_script, {
1034 'VAR_DESTINATION' : dartium_debug_name,
1035 'VAR_DOWNLOAD_URL' :
1036 ("http://dartlang.org/editor/update/channels/%s/%s/dartium/%s"
1037 % (CHANNEL, REVISION, dartium_debug_name)),
1038 })
1039 f.AddFile(dartium_download_script,
1040 'dart/chromium/download_dartium_debug%s' % shell_ending)
1041
968 # Create a editor.properties 1042 # Create a editor.properties
969 editor_properties = os.path.join(scratch_dir, 'editor.properties') 1043 editor_properties = os.path.join(scratch_dir, 'editor.properties')
970 with open(editor_properties, 'w') as fd: 1044 with open(editor_properties, 'w') as fd:
971 fd.write("com.dart.tools.update.core.url=http://dartlang.org" 1045 fd.write("com.dart.tools.update.core.url=http://dartlang.org"
972 "/editor/update/channels/%s/\n" % CHANNEL) 1046 "/editor/update/channels/%s/\n" % CHANNEL)
973 1047
974 for zipFile in _FindRcpZipFiles(out_dir): 1048 for zipFile in _FindRcpZipFiles(out_dir):
975 basename = os.path.basename(zipFile) 1049 basename = os.path.basename(zipFile)
1050 is_64bit = basename.endswith('-64.zip')
976 1051
977 print(' processing %s' % basename) 1052 print(' processing %s' % basename)
978 1053
979 readme_file = join('dart', 'README') 1054 readme_file = join('dart', 'README')
980 if (basename.startswith('darteditor-win32-')): 1055 if (basename.startswith('darteditor-win32-')):
981 seven_zip = os.path.join(DART_DIR, 'third_party', '7zip', '7za.exe') 1056 seven_zip = os.path.join(DART_DIR, 'third_party', '7zip', '7za.exe')
982 bot_utils.run([seven_zip, 'd', zipFile, readme_file], env=os.environ) 1057 bot_utils.run([seven_zip, 'd', zipFile, readme_file], env=os.environ)
983 else: 1058 else:
984 bot_utils.run(['zip', '-d', zipFile, readme_file], env=os.environ) 1059 bot_utils.run(['zip', '-d', zipFile, readme_file], env=os.environ)
985 1060
986 # If we're on -dev/-stable build: add an editor.properties file 1061 # If we're on -dev/-stable build: add an editor.properties file
987 # pointing to the correct update location of the editor for the channel 1062 # pointing to the correct update location of the editor for the channel
988 # we're building for. 1063 # we're building for.
989 if not TRUNK_BUILD and CHANNEL != 'be': 1064 if not TRUNK_BUILD and CHANNEL != 'be':
990 f = ziputils.ZipUtil(zipFile, buildos) 1065 f = ziputils.ZipUtil(zipFile, buildos)
991 f.AddFile(editor_properties, 'dart/editor.properties') 1066 f.AddFile(editor_properties, 'dart/editor.properties')
992 1067
1068 # Add a shell/bat script to download contentshell and dartium debug.
1069 # (including the necessary tools/dartium/download_file.dart helper).
1070 add_download_scripts(zipFile, '64' if is_64bit else '32')
1071
993 # adjust memory params for 64 bit versions 1072 # adjust memory params for 64 bit versions
994 if (basename.endswith('-64.zip')): 1073 if is_64bit:
995 if (basename.startswith('darteditor-macos-')): 1074 if (basename.startswith('darteditor-macos-')):
996 inifile = join('dart', 'DartEditor.app', 'Contents', 'MacOS', 1075 inifile = join('dart', 'DartEditor.app', 'Contents', 'MacOS',
997 'DartEditor.ini') 1076 'DartEditor.ini')
998 else: 1077 else:
999 inifile = join('dart', 'DartEditor.ini') 1078 inifile = join('dart', 'DartEditor.ini')
1000 1079
1001 if (basename.startswith('darteditor-win32-')): 1080 if (basename.startswith('darteditor-win32-')):
1002 f = zipfile.ZipFile(zipFile) 1081 f = zipfile.ZipFile(zipFile)
1003 f.extract(inifile.replace('\\','/')) 1082 f.extract(inifile.replace('\\','/'))
1004 f.close() 1083 f.close()
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 """delete the given file - do not re-throw any exceptions that occur""" 1462 """delete the given file - do not re-throw any exceptions that occur"""
1384 if os.path.exists(f): 1463 if os.path.exists(f):
1385 try: 1464 try:
1386 os.remove(f) 1465 os.remove(f)
1387 except OSError: 1466 except OSError:
1388 print 'error deleting %s' % f 1467 print 'error deleting %s' % f
1389 1468
1390 1469
1391 if __name__ == '__main__': 1470 if __name__ == '__main__':
1392 sys.exit(main()) 1471 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | dart/tools/dartium/download_file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698