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

Side by Side Diff: chrome/installer/linux/sysroot_scripts/install-debian.wheezy.sysroot.py

Issue 1164073004: Add mips support to install-debian.wheezy.sysroot.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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
« no previous file with comments | « no previous file | chrome/installer/linux/sysroot_scripts/sysroot-creator.sh » ('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 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Script to install a Debian Wheezy sysroot for making official Google Chrome 6 # Script to install a Debian Wheezy sysroot for making official Google Chrome
7 # Linux builds. 7 # Linux builds.
8 # The sysroot is needed to make Chrome work for Debian Wheezy. 8 # The sysroot is needed to make Chrome work for Debian Wheezy.
9 # This script can be run manually but is more often run as part of gclient 9 # This script can be run manually but is more often run as part of gclient
10 # hooks. When run from hooks this script should be a no-op on non-linux 10 # hooks. When run from hooks this script should be a no-op on non-linux
(...skipping 11 matching lines...) Expand all
22 import re 22 import re
23 import shutil 23 import shutil
24 import subprocess 24 import subprocess
25 import sys 25 import sys
26 26
27 27
28 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 28 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
29 URL_PREFIX = 'http://storage.googleapis.com' 29 URL_PREFIX = 'http://storage.googleapis.com'
30 URL_PATH = 'chrome-linux-sysroot/toolchain' 30 URL_PATH = 'chrome-linux-sysroot/toolchain'
31 REVISION_AMD64 = 'a2d45701cb21244b9514e420950ba6ba687fb655' 31 REVISION_AMD64 = 'a2d45701cb21244b9514e420950ba6ba687fb655'
32 REVISION_ARM = 'a2d45701cb21244b9514e420950ba6ba687fb655'
32 REVISION_I386 = 'a2d45701cb21244b9514e420950ba6ba687fb655' 33 REVISION_I386 = 'a2d45701cb21244b9514e420950ba6ba687fb655'
33 REVISION_ARM = 'a2d45701cb21244b9514e420950ba6ba687fb655' 34 REVISION_MIPS = '7749d2957387abf225b6d45154c3ddad142148dc'
34 TARBALL_AMD64 = 'debian_wheezy_amd64_sysroot.tgz' 35 TARBALL_AMD64 = 'debian_wheezy_amd64_sysroot.tgz'
36 TARBALL_ARM = 'debian_wheezy_arm_sysroot.tgz'
35 TARBALL_I386 = 'debian_wheezy_i386_sysroot.tgz' 37 TARBALL_I386 = 'debian_wheezy_i386_sysroot.tgz'
36 TARBALL_ARM = 'debian_wheezy_arm_sysroot.tgz' 38 TARBALL_MIPS = 'debian_wheezy_mips_sysroot.tgz'
37 TARBALL_AMD64_SHA1SUM = '601216c0f980e798e7131635f3dd8171b3dcbcde' 39 TARBALL_AMD64_SHA1SUM = '601216c0f980e798e7131635f3dd8171b3dcbcde'
40 TARBALL_ARM_SHA1SUM = '6289593b36616526562a4d85ae9c92b694b8ce7e'
38 TARBALL_I386_SHA1SUM = '0090e5a4b56ab9ffb5d557da6a520195ab59b446' 41 TARBALL_I386_SHA1SUM = '0090e5a4b56ab9ffb5d557da6a520195ab59b446'
39 TARBALL_ARM_SHA1SUM = '6289593b36616526562a4d85ae9c92b694b8ce7e' 42 TARBALL_MIPS_SHA1SUM = '3b4d782a237db4aac185a638572a7747c1a21825'
40 SYSROOT_DIR_AMD64 = 'debian_wheezy_amd64-sysroot' 43 SYSROOT_DIR_AMD64 = 'debian_wheezy_amd64-sysroot'
44 SYSROOT_DIR_ARM = 'debian_wheezy_arm-sysroot'
41 SYSROOT_DIR_I386 = 'debian_wheezy_i386-sysroot' 45 SYSROOT_DIR_I386 = 'debian_wheezy_i386-sysroot'
42 SYSROOT_DIR_ARM = 'debian_wheezy_arm-sysroot' 46 SYSROOT_DIR_MIPS = 'debian_wheezy_mips-sysroot'
43 47
44 valid_archs = ('arm', 'i386', 'amd64') 48 valid_archs = ('arm', 'i386', 'amd64', 'mips')
45 49
46 50
47 def GetSha1(filename): 51 def GetSha1(filename):
48 sha1 = hashlib.sha1() 52 sha1 = hashlib.sha1()
49 with open(filename, 'rb') as f: 53 with open(filename, 'rb') as f:
50 while True: 54 while True:
51 # Read in 1mb chunks, so it doesn't all have to be loaded into memory. 55 # Read in 1mb chunks, so it doesn't all have to be loaded into memory.
52 chunk = f.read(1024*1024) 56 chunk = f.read(1024*1024)
53 if not chunk: 57 if not chunk:
54 break 58 break
55 sha1.update(chunk) 59 sha1.update(chunk)
56 return sha1.hexdigest() 60 return sha1.hexdigest()
57 61
58 62
59 def DetectArch(gyp_defines): 63 def DetectArch(gyp_defines):
60 # Check for optional target_arch and only install for that architecture. 64 # Check for optional target_arch and only install for that architecture.
61 # If target_arch is not specified, then only install for the host 65 # If target_arch is not specified, then only install for the host
62 # architecture. 66 # architecture.
63 if 'target_arch=x64' in gyp_defines: 67 if 'target_arch=x64' in gyp_defines:
64 return 'amd64' 68 return 'amd64'
65 elif 'target_arch=ia32' in gyp_defines: 69 elif 'target_arch=ia32' in gyp_defines:
66 return 'i386' 70 return 'i386'
67 elif 'target_arch=arm' in gyp_defines: 71 elif 'target_arch=arm' in gyp_defines:
68 return 'arm' 72 return 'arm'
73 elif 'target_arch=mipsel' in gyp_defines:
74 return 'mips'
69 75
70 # Figure out host arch using build/detect_host_arch.py and 76 # Figure out host arch using build/detect_host_arch.py and
71 # set target_arch to host arch 77 # set target_arch to host arch
72 SRC_DIR = os.path.abspath( 78 SRC_DIR = os.path.abspath(
73 os.path.join(SCRIPT_DIR, '..', '..', '..', '..')) 79 os.path.join(SCRIPT_DIR, '..', '..', '..', '..'))
74 sys.path.append(os.path.join(SRC_DIR, 'build')) 80 sys.path.append(os.path.join(SRC_DIR, 'build'))
75 import detect_host_arch 81 import detect_host_arch
76 82
77 detected_host_arch = detect_host_arch.HostArch() 83 detected_host_arch = detect_host_arch.HostArch()
78 if detected_host_arch == 'x64': 84 if detected_host_arch == 'x64':
79 return 'amd64' 85 return 'amd64'
80 elif detected_host_arch == 'ia32': 86 elif detected_host_arch == 'ia32':
81 return 'i386' 87 return 'i386'
82 elif detected_host_arch == 'arm': 88 elif detected_host_arch == 'arm':
83 return 'arm' 89 return 'arm'
90 elif detected_host_arch == 'mips':
91 return 'mips'
84 else: 92 else:
85 print "Unknown host arch: %s" % detected_host_arch 93 print "Unknown host arch: %s" % detected_host_arch
86 94
87 return None 95 return None
88 96
89 97
90 def main(): 98 def main():
91 if options.running_as_hook and not sys.platform.startswith('linux'): 99 if options.running_as_hook and not sys.platform.startswith('linux'):
92 return 0 100 return 0
93 101
94 gyp_defines = os.environ.get('GYP_DEFINES', '') 102 gyp_defines = os.environ.get('GYP_DEFINES', '')
95 103
96 if options.arch: 104 if options.arch:
97 target_arch = options.arch 105 target_arch = options.arch
98 else: 106 else:
99 target_arch = DetectArch(gyp_defines) 107 target_arch = DetectArch(gyp_defines)
100 if not target_arch: 108 if not target_arch:
101 print 'Unable to detect host architecture' 109 print 'Unable to detect host architecture'
102 return 1 110 return 1
103 111
104 if options.running_as_hook and target_arch != 'arm': 112 if options.running_as_hook and target_arch != 'arm' and target_arch != 'mips':
105 # When run from runhooks, only install the sysroot for an Official Chrome 113 # When run from runhooks, only install the sysroot for an Official Chrome
106 # Linux build, except on ARM where we always use a sysroot. 114 # Linux build, except on ARM where we always use a sysroot.
107 skip_if_defined = ['branding=Chrome', 'buildtype=Official'] 115 skip_if_defined = ['branding=Chrome', 'buildtype=Official']
108 skip_if_undefined = ['chromeos=1'] 116 skip_if_undefined = ['chromeos=1']
109 for option in skip_if_defined: 117 for option in skip_if_defined:
110 if option not in gyp_defines: 118 if option not in gyp_defines:
111 return 0 119 return 0
112 for option in skip_if_undefined: 120 for option in skip_if_undefined:
113 if option in gyp_defines: 121 if option in gyp_defines:
114 return 0 122 return 0
(...skipping 10 matching lines...) Expand all
125 elif target_arch == 'arm': 133 elif target_arch == 'arm':
126 sysroot = os.path.join(linux_dir, SYSROOT_DIR_ARM) 134 sysroot = os.path.join(linux_dir, SYSROOT_DIR_ARM)
127 tarball_filename = TARBALL_ARM 135 tarball_filename = TARBALL_ARM
128 tarball_sha1sum = TARBALL_ARM_SHA1SUM 136 tarball_sha1sum = TARBALL_ARM_SHA1SUM
129 revision = REVISION_ARM 137 revision = REVISION_ARM
130 elif target_arch == 'i386': 138 elif target_arch == 'i386':
131 sysroot = os.path.join(linux_dir, SYSROOT_DIR_I386) 139 sysroot = os.path.join(linux_dir, SYSROOT_DIR_I386)
132 tarball_filename = TARBALL_I386 140 tarball_filename = TARBALL_I386
133 tarball_sha1sum = TARBALL_I386_SHA1SUM 141 tarball_sha1sum = TARBALL_I386_SHA1SUM
134 revision = REVISION_I386 142 revision = REVISION_I386
143 elif target_arch == 'mips':
144 sysroot = os.path.join(linux_dir, SYSROOT_DIR_MIPS)
145 tarball_filename = TARBALL_MIPS
146 tarball_sha1sum = TARBALL_MIPS_SHA1SUM
147 revision = REVISION_MIPS
135 else: 148 else:
136 print 'Unknown architecture: %s' % target_arch 149 print 'Unknown architecture: %s' % target_arch
137 assert(False) 150 assert(False)
138 151
139 url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, revision, tarball_filename) 152 url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, revision, tarball_filename)
140 153
141 stamp = os.path.join(sysroot, '.stamp') 154 stamp = os.path.join(sysroot, '.stamp')
142 if os.path.exists(stamp): 155 if os.path.exists(stamp):
143 with open(stamp) as s: 156 with open(stamp) as s:
144 if s.read() == url: 157 if s.read() == url:
(...skipping 27 matching lines...) Expand all
172 parser = optparse.OptionParser('usage: %prog [OPTIONS]') 185 parser = optparse.OptionParser('usage: %prog [OPTIONS]')
173 parser.add_option('--running-as-hook', action='store_true', 186 parser.add_option('--running-as-hook', action='store_true',
174 default=False, help='Used when running from gclient hooks.' 187 default=False, help='Used when running from gclient hooks.'
175 ' In this mode the sysroot will only ' 188 ' In this mode the sysroot will only '
176 'be installed for official Linux ' 189 'be installed for official Linux '
177 'builds or ARM Linux builds') 190 'builds or ARM Linux builds')
178 parser.add_option('--arch', type='choice', choices=valid_archs, 191 parser.add_option('--arch', type='choice', choices=valid_archs,
179 help='Sysroot architecture: %s' % ', '.join(valid_archs)) 192 help='Sysroot architecture: %s' % ', '.join(valid_archs))
180 options, _ = parser.parse_args() 193 options, _ = parser.parse_args()
181 sys.exit(main()) 194 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/linux/sysroot_scripts/sysroot-creator.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698