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

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/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 contentshell_scriptconfig = {
970 'windows' : {
971 'local_path' : os.path.join(scratch_dir, 'download_contentshell.bat'),
972 'zipfile_path' : 'dart/chromium/download_contentshell.bat',
973 'content_pattern' :
974 r"""
975 REM This script will download content shell to "content_shell.zip" in the
ricow1 2013/11/04 17:14:53 why don't we just put these scripts inside tools/d
kustermann 2013/11/05 12:45:19 We could, but remember that these are not executab
976 REM current working directory.
977
978 CHROMIUM_DIR="%~dp0"
979 SDK_BIN="%CHROMIUM_DIR%\..\dart-sdk\bin"
980
981 DART="%SDK_BIN%\dart.exe"
982 DOWNLOAD_SCRIPT="%CHROMIUM_DIR%\download_file.dart"
983
984 "$DART" "$DOWNLOAD_SCRIPT" "%(url)s" content_shell.zip
985 """
986 },
987 'posix' : {
988 'local_path' : os.path.join(scratch_dir, 'download_contentshell.sh'),
989 'zipfile_path' : 'dart/chromium/download_contentshell.sh',
990 'content_pattern' :
991 r"""#!/bin/bash
992
993 # This script will download content shell to "content_shell.zip" in the current
994 # working directory.
995
996 CHROMIUM_DIR="$(dirname $BASH_SOURCE)"
997 SDK_BIN="$CHROMIUM_DIR/../dart-sdk/bin"
998
999 DART="$SDK_BIN/dart"
1000 DOWNLOAD_SCRIPT="$CHROMIUM_DIR/download_file.dart"
1001
1002 "$DART" "$DOWNLOAD_SCRIPT" "%(url)s" content_shell.zip
1003 """
1004 },
1005 }
1006 contentshell_scriptconfig['linux'] = contentshell_scriptconfig['posix']
1007 contentshell_scriptconfig['macos'] = contentshell_scriptconfig['posix']
1008
1009 # Create a download_contentshell shell/bat script.
1010 def create_download_contentshell_script(arch):
1011 # The directory tree will look like this:
1012 # dart/dart-sdk/bin/dart(.exe)
1013 # /chromium/download_contentshell.(sh,bat)
1014 # /chromium/download_file.dart
1015 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RELEASE)
1016 contentshell_name = namer.dartium_variant_zipfilename(
1017 'content_shell', SYSTEM, arch, 'release')
1018 contentshell_url = (
1019 "http://dartlang.org/editor/update/channels/%s/latest/dartium/%s"
1020 % (CHANNEL, contentshell_name))
kustermann 2013/11/04 16:36:52 I'm not sure if we should use 'latest' here or the
ricow1 2013/11/04 17:14:53 We should use the exact version, otherwise there c
kustermann 2013/11/05 12:45:19 I'll change it.
1021
1022 with open(contentshell_scriptconfig[SYSTEM]['local_path'], 'w') as fd:
1023 fd.write(contentshell_scriptconfig[SYSTEM]['content_pattern']
1024 % {'url' : contentshell_url })
1025
1026 # Make it executable if we are not on windows
1027 if SYSTEM != 'windows':
1028 shell_script = contentshell_scriptconfig[SYSTEM]['local_path']
1029 os.chmod(shell_script, os.stat(shell_script).st_mode | stat.S_IEXEC)
1030
968 # Create a editor.properties 1031 # Create a editor.properties
969 editor_properties = os.path.join(scratch_dir, 'editor.properties') 1032 editor_properties = os.path.join(scratch_dir, 'editor.properties')
970 with open(editor_properties, 'w') as fd: 1033 with open(editor_properties, 'w') as fd:
971 fd.write("com.dart.tools.update.core.url=http://dartlang.org" 1034 fd.write("com.dart.tools.update.core.url=http://dartlang.org"
972 "/editor/update/channels/%s/\n" % CHANNEL) 1035 "/editor/update/channels/%s/\n" % CHANNEL)
973 1036
974 for zipFile in _FindRcpZipFiles(out_dir): 1037 for zipFile in _FindRcpZipFiles(out_dir):
975 basename = os.path.basename(zipFile) 1038 basename = os.path.basename(zipFile)
1039 is_64bit = basename.endswith('-64.zip')
976 1040
977 print(' processing %s' % basename) 1041 print(' processing %s' % basename)
978 1042
979 readme_file = join('dart', 'README') 1043 readme_file = join('dart', 'README')
980 if (basename.startswith('darteditor-win32-')): 1044 if (basename.startswith('darteditor-win32-')):
981 seven_zip = os.path.join(DART_DIR, 'third_party', '7zip', '7za.exe') 1045 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) 1046 bot_utils.run([seven_zip, 'd', zipFile, readme_file], env=os.environ)
983 else: 1047 else:
984 bot_utils.run(['zip', '-d', zipFile, readme_file], env=os.environ) 1048 bot_utils.run(['zip', '-d', zipFile, readme_file], env=os.environ)
985 1049
986 # If we're on -dev/-stable build: add an editor.properties file 1050 # 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 1051 # pointing to the correct update location of the editor for the channel
988 # we're building for. 1052 # we're building for.
989 if not TRUNK_BUILD and CHANNEL != 'be': 1053 if not TRUNK_BUILD and CHANNEL != 'be':
990 f = ziputils.ZipUtil(zipFile, buildos) 1054 f = ziputils.ZipUtil(zipFile, buildos)
991 f.AddFile(editor_properties, 'dart/editor.properties') 1055 f.AddFile(editor_properties, 'dart/editor.properties')
992 1056
1057 # Add a shell/bat script to download content shell (and the
1058 # tools/download_file.dart helper utility).
1059 create_download_contentshell_script('64' if is_64bit else '32')
1060 f = ziputils.ZipUtil(zipFile, buildos)
1061 f.AddFile(contentshell_scriptconfig[SYSTEM]['local_path'],
1062 contentshell_scriptconfig[SYSTEM]['zipfile_path'])
1063 f.AddFile(os.path.join(DART_DIR, 'tools', 'download_file.dart'),
1064 'dart/chromium/download_file.dart')
1065
993 # adjust memory params for 64 bit versions 1066 # adjust memory params for 64 bit versions
994 if (basename.endswith('-64.zip')): 1067 if is_64bit:
995 if (basename.startswith('darteditor-macos-')): 1068 if (basename.startswith('darteditor-macos-')):
996 inifile = join('dart', 'DartEditor.app', 'Contents', 'MacOS', 1069 inifile = join('dart', 'DartEditor.app', 'Contents', 'MacOS',
997 'DartEditor.ini') 1070 'DartEditor.ini')
998 else: 1071 else:
999 inifile = join('dart', 'DartEditor.ini') 1072 inifile = join('dart', 'DartEditor.ini')
1000 1073
1001 if (basename.startswith('darteditor-win32-')): 1074 if (basename.startswith('darteditor-win32-')):
1002 f = zipfile.ZipFile(zipFile) 1075 f = zipfile.ZipFile(zipFile)
1003 f.extract(inifile.replace('\\','/')) 1076 f.extract(inifile.replace('\\','/'))
1004 f.close() 1077 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""" 1456 """delete the given file - do not re-throw any exceptions that occur"""
1384 if os.path.exists(f): 1457 if os.path.exists(f):
1385 try: 1458 try:
1386 os.remove(f) 1459 os.remove(f)
1387 except OSError: 1460 except OSError:
1388 print 'error deleting %s' % f 1461 print 'error deleting %s' % f
1389 1462
1390 1463
1391 if __name__ == '__main__': 1464 if __name__ == '__main__':
1392 sys.exit(main()) 1465 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | dart/tools/download_file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698