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

Side by Side Diff: build/linux/sysroot_scripts/install-sysroot.py

Issue 2567123002: Sysroot: Add build_and_upload.py (Closed)
Patch Set: Address sbc@'s comments Created 4 years 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
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 """Install Debian sysroots for building chromium. 6 """Install Debian sysroots for building chromium.
7 """ 7 """
8 8
9 # The sysroot is needed to ensure that binaries will run on Debian Wheezy, 9 # The sysroot is needed to ensure that binaries will run on Debian Wheezy,
10 # the oldest supported linux distribution. For ARM64 linux, we have Debian 10 # the oldest supported linux distribution. For ARM64 linux, we have Debian
11 # Jessie sysroot as Jessie is the first version with ARM64 support. This script 11 # Jessie sysroot as Jessie is the first version with ARM64 support. This script
12 # can be run manually but is more often run as part of gclient hooks. When run 12 # can be run manually but is more often run as part of gclient hooks. When run
13 # from hooks this script is a no-op on non-linux platforms. 13 # from hooks this script is a no-op on non-linux platforms.
14 14
15 # The sysroot image could be constructed from scratch based on the current 15 # The sysroot image could be constructed from scratch based on the current
16 # state or Debian Wheezy/Jessie but for consistency we currently use a 16 # state or Debian Wheezy/Jessie but for consistency we currently use a
17 # pre-built root image. The image will normally need to be rebuilt every time 17 # pre-built root image. The image will normally need to be rebuilt every time
18 # chrome's build dependencies are changed. 18 # chrome's build dependencies are changed.
19 19
20 import hashlib 20 import hashlib
21 import json
21 import platform 22 import platform
22 import optparse 23 import optparse
23 import os 24 import os
24 import re 25 import re
25 import shutil 26 import shutil
26 import subprocess 27 import subprocess
27 import sys 28 import sys
28 import urllib 29 import urllib
29 30
30 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 31 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
31 sys.path.append(os.path.dirname(os.path.dirname(SCRIPT_DIR))) 32 sys.path.append(os.path.dirname(os.path.dirname(SCRIPT_DIR)))
32 import detect_host_arch 33 import detect_host_arch
33 import gyp_chromium 34 import gyp_chromium
34 import gyp_environment 35 import gyp_environment
35 36
36 37
37 URL_PREFIX = 'https://commondatastorage.googleapis.com' 38 URL_PREFIX = 'https://commondatastorage.googleapis.com'
38 URL_PATH = 'chrome-linux-sysroot/toolchain' 39 URL_PATH = 'chrome-linux-sysroot/toolchain'
39 40
40 SYSROOTS = { 41 VALID_ARCHS = ('arm', 'arm64', 'i386', 'amd64', 'mips')
41 ('Wheezy', 'amd64'): {
42 'Revision' : '7d200a1ddfeb50dbf9f7e2c1c4ff1080679edf02',
43 'Tarball' : 'debian_wheezy_amd64_sysroot.tgz',
44 'Sha1Sum' : 'cc43f16c817fbb8c525405363ece863347210a30',
45 'SysrootDir' : 'debian_wheezy_amd64-sysroot'
46 },
47 ('Wheezy', 'arm'): {
48 'Revision' : '7d200a1ddfeb50dbf9f7e2c1c4ff1080679edf02',
49 'Tarball' : 'debian_wheezy_arm_sysroot.tgz',
50 'Sha1Sum' : 'c09ac9576642d81209f25cde19a64f427b5fbaf8',
51 'SysrootDir' : 'debian_wheezy_arm-sysroot'
52 },
53 ('Wheezy', 'i386'): {
54 'Revision' : '7d200a1ddfeb50dbf9f7e2c1c4ff1080679edf02',
55 'Tarball' : 'debian_wheezy_i386_sysroot.tgz',
56 'Sha1Sum' : '1b28326d17094b9d3616579b988eb5554c3dc9f8',
57 'SysrootDir' : 'debian_wheezy_i386-sysroot'
58 },
59 ('Wheezy', 'mips'): {
60 'Revision' : '7d200a1ddfeb50dbf9f7e2c1c4ff1080679edf02',
61 'Tarball' : 'debian_wheezy_mips_sysroot.tgz',
62 'Sha1Sum' : 'c0948a2c955588079dc31d688e8105730744ef45',
63 'SysrootDir' : 'debian_wheezy_mips-sysroot'
64 },
65 ('Jessie', 'arm64'): {
66 'Revision' : '5735a5e9605d549acb6495e1fb65384a54fe0a48',
67 'Tarball' : 'debian_jessie_arm64_sysroot.tgz',
68 'Sha1Sum' : '82ebae900d0aadd52cf76a8e7cdb6a782df6ef28',
69 'SysrootDir' : 'debian_jessie_arm64-sysroot'
70 },
71 ('Precise', 'amd64'): {
72 'Revision' : '7d200a1ddfeb50dbf9f7e2c1c4ff1080679edf02',
73 'Tarball' : 'ubuntu_precise_amd64_sysroot.tgz',
74 'Sha1Sum' : 'fdf81c55a0c6decd44f07781ebf163f97deb26cc',
75 'SysrootDir' : 'ubuntu_precise_amd64-sysroot'
76 }
77 }
78
79 valid_archs = ('arm', 'arm64', 'i386', 'amd64', 'mips')
80 42
81 43
82 class Error(Exception): 44 class Error(Exception):
83 pass 45 pass
84 46
85 47
86 def GetSha1(filename): 48 def GetSha1(filename):
87 sha1 = hashlib.sha1() 49 sha1 = hashlib.sha1()
88 with open(filename, 'rb') as f: 50 with open(filename, 'rb') as f:
89 while True: 51 while True:
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 target_arch = DetectTargetArch() 134 target_arch = DetectTargetArch()
173 if target_arch and target_arch not in (host_arch, 'i386'): 135 if target_arch and target_arch not in (host_arch, 'i386'):
174 InstallDefaultSysrootForArch(target_arch) 136 InstallDefaultSysrootForArch(target_arch)
175 137
176 138
177 def main(args): 139 def main(args):
178 parser = optparse.OptionParser('usage: %prog [OPTIONS]', description=__doc__) 140 parser = optparse.OptionParser('usage: %prog [OPTIONS]', description=__doc__)
179 parser.add_option('--running-as-hook', action='store_true', 141 parser.add_option('--running-as-hook', action='store_true',
180 default=False, help='Used when running from gclient hooks.' 142 default=False, help='Used when running from gclient hooks.'
181 ' Installs default sysroot images.') 143 ' Installs default sysroot images.')
182 parser.add_option('--arch', type='choice', choices=valid_archs, 144 parser.add_option('--arch', type='choice', choices=VALID_ARCHS,
183 help='Sysroot architecture: %s' % ', '.join(valid_archs)) 145 help='Sysroot architecture: %s' % ', '.join(VALID_ARCHS))
184 options, _ = parser.parse_args(args) 146 options, _ = parser.parse_args(args)
185 if options.running_as_hook and not sys.platform.startswith('linux'): 147 if options.running_as_hook and not sys.platform.startswith('linux'):
186 return 0 148 return 0
187 149
188 if options.running_as_hook: 150 if options.running_as_hook:
189 host_arch = DetectHostArch() 151 host_arch = DetectHostArch()
190 # PPC/s390 don't use sysroot, see http://crbug.com/646169 152 # PPC/s390 don't use sysroot, see http://crbug.com/646169
191 if host_arch in ['ppc','s390']: 153 if host_arch in ['ppc','s390']:
192 return 0 154 return 0
193 InstallDefaultSysroots(host_arch) 155 InstallDefaultSysroots(host_arch)
(...skipping 14 matching lines...) Expand all
208 InstallSysroot('Jessie', 'arm64') 170 InstallSysroot('Jessie', 'arm64')
209 elif target_arch == 'i386': 171 elif target_arch == 'i386':
210 InstallSysroot('Wheezy', 'i386') 172 InstallSysroot('Wheezy', 'i386')
211 elif target_arch == 'mips': 173 elif target_arch == 'mips':
212 InstallSysroot('Wheezy', 'mips') 174 InstallSysroot('Wheezy', 'mips')
213 else: 175 else:
214 raise Error('Unknown architecture: %s' % target_arch) 176 raise Error('Unknown architecture: %s' % target_arch)
215 177
216 def InstallSysroot(target_platform, target_arch): 178 def InstallSysroot(target_platform, target_arch):
217 # The sysroot directory should match the one specified in build/common.gypi. 179 # The sysroot directory should match the one specified in build/common.gypi.
218 # TODO(thestig) Consider putting this else where to avoid having to recreate 180 # TODO(thestig) Consider putting this elsewhere to avoid having to recreate
219 # it on every build. 181 # it on every build.
220 linux_dir = os.path.dirname(SCRIPT_DIR) 182 linux_dir = os.path.dirname(SCRIPT_DIR)
221 183
222 if (target_platform, target_arch) not in SYSROOTS: 184 sysroots_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
Sam Clegg 2016/12/12 22:11:52 Use SCRIPT_DIR here?
Tom (Use chromium acct) 2016/12/13 00:06:19 Done.
223 raise Error('No sysroot for: %s %s' % (target_platform, target_arch)) 185 'sysroots.json')
224 sysroot_dict = SYSROOTS[(target_platform, target_arch)] 186 sysroots = json.load(open(sysroots_file))
187 sysroot_dict = sysroots['%s_%s' % (target_platform.lower(), target_arch)]
Sam Clegg 2016/12/12 22:11:52 Should see keep the error for the case when the ke
Tom (Use chromium acct) 2016/12/13 00:06:19 Oops, forgot about that. Done
225 revision = sysroot_dict['Revision'] 188 revision = sysroot_dict['Revision']
226 tarball_filename = sysroot_dict['Tarball'] 189 tarball_filename = sysroot_dict['Tarball']
227 tarball_sha1sum = sysroot_dict['Sha1Sum'] 190 tarball_sha1sum = sysroot_dict['Sha1Sum']
228 sysroot = os.path.join(linux_dir, sysroot_dict['SysrootDir']) 191 sysroot = os.path.join(linux_dir, sysroot_dict['SysrootDir'])
229 192
230 url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, revision, tarball_filename) 193 url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, revision, tarball_filename)
231 194
232 stamp = os.path.join(sysroot, '.stamp') 195 stamp = os.path.join(sysroot, '.stamp')
233 if os.path.exists(stamp): 196 if os.path.exists(stamp):
234 with open(stamp) as s: 197 with open(stamp) as s:
(...skipping 29 matching lines...) Expand all
264 with open(stamp, 'w') as s: 227 with open(stamp, 'w') as s:
265 s.write(url) 228 s.write(url)
266 229
267 230
268 if __name__ == '__main__': 231 if __name__ == '__main__':
269 try: 232 try:
270 sys.exit(main(sys.argv[1:])) 233 sys.exit(main(sys.argv[1:]))
271 except Error as e: 234 except Error as e:
272 sys.stderr.write(str(e) + '\n') 235 sys.stderr.write(str(e) + '\n')
273 sys.exit(1) 236 sys.exit(1)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698