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

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

Issue 1430143002: Install both 32 and 64 bit x86 sysroots when arm is the target_cpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update a comment Created 5 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
« no previous file with comments | « no previous file | no next file » | 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
11 # platforms. 11 # platforms.
12 12
13 # The sysroot image could be constructed from scratch based on the current 13 # The sysroot image could be constructed from scratch based on the current
14 # state or Debian Wheezy but for consistency we currently use a pre-built root 14 # state or Debian Wheezy but for consistency we currently use a pre-built root
15 # image. The image will normally need to be rebuilt every time chrome's build 15 # image. The image will normally need to be rebuilt every time chrome's build
16 # dependancies are changed. 16 # dependancies are changed.
17 17
18 import hashlib 18 import hashlib
19 import platform 19 import platform
20 import optparse 20 import optparse
21 import os 21 import os
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 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
28 sys.path.append(os.path.dirname(os.path.dirname(os.path.join(SCRIPT_DIR))))
29 import detect_host_arch
30 import gyp_chromium
31 import gyp_environment
27 32
28 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 33
29 URL_PREFIX = 'http://storage.googleapis.com' 34 URL_PREFIX = 'http://storage.googleapis.com'
30 URL_PATH = 'chrome-linux-sysroot/toolchain' 35 URL_PATH = 'chrome-linux-sysroot/toolchain'
31 REVISION_AMD64 = 'a2d45701cb21244b9514e420950ba6ba687fb655' 36 REVISION_AMD64 = 'a2d45701cb21244b9514e420950ba6ba687fb655'
32 REVISION_ARM = 'a2d45701cb21244b9514e420950ba6ba687fb655' 37 REVISION_ARM = 'a2d45701cb21244b9514e420950ba6ba687fb655'
33 REVISION_I386 = 'a2d45701cb21244b9514e420950ba6ba687fb655' 38 REVISION_I386 = 'a2d45701cb21244b9514e420950ba6ba687fb655'
34 REVISION_MIPS = '7749d2957387abf225b6d45154c3ddad142148dc' 39 REVISION_MIPS = '7749d2957387abf225b6d45154c3ddad142148dc'
35 TARBALL_AMD64 = 'debian_wheezy_amd64_sysroot.tgz' 40 TARBALL_AMD64 = 'debian_wheezy_amd64_sysroot.tgz'
36 TARBALL_ARM = 'debian_wheezy_arm_sysroot.tgz' 41 TARBALL_ARM = 'debian_wheezy_arm_sysroot.tgz'
37 TARBALL_I386 = 'debian_wheezy_i386_sysroot.tgz' 42 TARBALL_I386 = 'debian_wheezy_i386_sysroot.tgz'
38 TARBALL_MIPS = 'debian_wheezy_mips_sysroot.tgz' 43 TARBALL_MIPS = 'debian_wheezy_mips_sysroot.tgz'
(...skipping 14 matching lines...) Expand all
53 with open(filename, 'rb') as f: 58 with open(filename, 'rb') as f:
54 while True: 59 while True:
55 # Read in 1mb chunks, so it doesn't all have to be loaded into memory. 60 # Read in 1mb chunks, so it doesn't all have to be loaded into memory.
56 chunk = f.read(1024*1024) 61 chunk = f.read(1024*1024)
57 if not chunk: 62 if not chunk:
58 break 63 break
59 sha1.update(chunk) 64 sha1.update(chunk)
60 return sha1.hexdigest() 65 return sha1.hexdigest()
61 66
62 67
63 def DetectArch(gyp_defines): 68 def DetectArch(gyp_defines, is_android):
64 # Check for optional target_arch and only install for that architecture. 69 # Check for optional target_arch and only install for that architecture.
65 # If target_arch is not specified, then only install for the host 70 # If target_arch is not specified, then only install for the host
66 # architecture. 71 # architecture.
67 if 'target_arch=x64' in gyp_defines: 72 target_arch = gyp_defines.get('target_arch')
73 if target_arch == 'x64':
68 return 'amd64' 74 return 'amd64'
69 elif 'target_arch=ia32' in gyp_defines: 75 elif target_arch == 'ia32':
70 return 'i386' 76 return 'i386'
71 elif 'target_arch=arm' in gyp_defines: 77 elif target_arch == 'arm':
72 return 'arm' 78 return 'arm'
73 elif 'target_arch=mipsel' in gyp_defines: 79 elif target_arch == 'arm64':
80 return 'arm64'
81 elif target_arch == 'mipsel':
74 return 'mips' 82 return 'mips'
83 elif target_arch:
84 raise Exception('Unrecognized target_arch: %s' % target_arch)
85
86 if is_android:
87 return 'arm'
75 88
76 # Figure out host arch using build/detect_host_arch.py and 89 # Figure out host arch using build/detect_host_arch.py and
77 # set target_arch to host arch 90 # set target_arch to host arch
78 build_dir = os.path.dirname(os.path.dirname(os.path.join(SCRIPT_DIR)))
79 sys.path.append(build_dir)
80 import detect_host_arch
81
82 detected_host_arch = detect_host_arch.HostArch() 91 detected_host_arch = detect_host_arch.HostArch()
83 if detected_host_arch == 'x64': 92 if detected_host_arch == 'x64':
84 return 'amd64' 93 return 'amd64'
85 elif detected_host_arch == 'ia32': 94 elif detected_host_arch == 'ia32':
86 return 'i386' 95 return 'i386'
87 elif detected_host_arch == 'arm': 96 elif detected_host_arch == 'arm':
88 return 'arm' 97 return 'arm'
89 elif detected_host_arch == 'mips': 98 elif detected_host_arch == 'mips':
90 return 'mips' 99 return 'mips'
91 else: 100 else:
92 print "Unknown host arch: %s" % detected_host_arch 101 print "Unknown host arch: %s" % detected_host_arch
93 102
94 return None 103 return None
95 104
96 105
97 def UsingSysroot(target_arch, gyp_defines): 106 def UsingSysroot(target_arch, is_android, gyp_defines):
98 # ChromeOS uses a chroot, so doesn't need a sysroot 107 # ChromeOS uses a chroot, so doesn't need a sysroot
99 if 'chromeos=1' in gyp_defines: 108 if gyp_defines.get('chromeos'):
100 return False 109 return False
101 110
102 # When cross-compiling we always use a sysroot 111 # When cross-compiling non-Android builds we always use a sysroot
103 if target_arch in ('arm', 'mips', 'i386'): 112 if not is_android and target_arch in ('arm', 'mips', 'i386'):
104 return True 113 return True
105 114
106 # Setting use_sysroot=1 GYP_DEFINES forces the use of the sysroot even 115 # Setting use_sysroot=1 GYP_DEFINES forces the use of the sysroot even
107 # when not cross compiling 116 # when not cross compiling
108 if 'use_sysroot=1' in gyp_defines: 117 if gyp_defines.get('use_sysroot'):
109 return True 118 return True
110 119
111 # Official builds always use the sysroot. 120 # Official builds always use the sysroot.
112 if 'branding=Chrome' in gyp_defines and 'buildtype=Official' in gyp_defines: 121 if (gyp_defines.get('branding') == 'Chrome' and
122 gyp_defines.get('buildtype') == 'Official'):
113 return True 123 return True
114 124
115 return False 125 return False
116 126
117 127
118 def main(): 128 def main():
119 if options.running_as_hook and not sys.platform.startswith('linux'): 129 if options.running_as_hook and not sys.platform.startswith('linux'):
120 return 0 130 return 0
121 131
122 gyp_defines = os.environ.get('GYP_DEFINES', '') 132 gyp_environment.SetEnvironment()
133 supplemental_includes = gyp_chromium.GetSupplementalFiles()
134 gyp_defines = gyp_chromium.GetGypVars(supplemental_includes)
135 is_android = gyp_defines.get('OS') == 'android'
123 136
124 if options.arch: 137 if options.arch:
125 target_arch = options.arch 138 target_arch = options.arch
126 else: 139 else:
127 target_arch = DetectArch(gyp_defines) 140 target_arch = DetectArch(gyp_defines, is_android)
128 if not target_arch: 141 if not target_arch:
129 print 'Unable to detect host architecture' 142 print 'Unable to detect target architecture'
130 return 1 143 return 1
131 144
132 if options.running_as_hook and not UsingSysroot(target_arch, gyp_defines): 145 if (options.running_as_hook and
146 not UsingSysroot(target_arch, is_android, gyp_defines)):
133 return 0 147 return 0
134 148
149 if is_android:
150 # 32-bit Android builds require a 32-bit host sysroot for the v8 snapshot.
151 if '64' not in target_arch:
152 ret = _InstallSysroot('i386')
153 if ret:
154 return ret
155 # Always need host sysroot (which we assume is x64).
156 target_arch = 'amd64'
157
158 return _InstallSysroot(target_arch)
159
160
161 def _InstallSysroot(target_arch):
135 # The sysroot directory should match the one specified in build/common.gypi. 162 # The sysroot directory should match the one specified in build/common.gypi.
136 # TODO(thestig) Consider putting this else where to avoid having to recreate 163 # TODO(thestig) Consider putting this else where to avoid having to recreate
137 # it on every build. 164 # it on every build.
138 linux_dir = os.path.dirname(SCRIPT_DIR) 165 linux_dir = os.path.dirname(SCRIPT_DIR)
139 if target_arch == 'amd64': 166 if target_arch == 'amd64':
140 sysroot = os.path.join(linux_dir, SYSROOT_DIR_AMD64) 167 sysroot = os.path.join(linux_dir, SYSROOT_DIR_AMD64)
141 tarball_filename = TARBALL_AMD64 168 tarball_filename = TARBALL_AMD64
142 tarball_sha1sum = TARBALL_AMD64_SHA1SUM 169 tarball_sha1sum = TARBALL_AMD64_SHA1SUM
143 revision = REVISION_AMD64 170 revision = REVISION_AMD64
144 elif target_arch == 'arm': 171 elif target_arch == 'arm':
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 parser = optparse.OptionParser('usage: %prog [OPTIONS]') 223 parser = optparse.OptionParser('usage: %prog [OPTIONS]')
197 parser.add_option('--running-as-hook', action='store_true', 224 parser.add_option('--running-as-hook', action='store_true',
198 default=False, help='Used when running from gclient hooks.' 225 default=False, help='Used when running from gclient hooks.'
199 ' In this mode the sysroot will only ' 226 ' In this mode the sysroot will only '
200 'be installed for official Linux ' 227 'be installed for official Linux '
201 'builds or ARM Linux builds') 228 'builds or ARM Linux builds')
202 parser.add_option('--arch', type='choice', choices=valid_archs, 229 parser.add_option('--arch', type='choice', choices=valid_archs,
203 help='Sysroot architecture: %s' % ', '.join(valid_archs)) 230 help='Sysroot architecture: %s' % ', '.join(valid_archs))
204 options, _ = parser.parse_args() 231 options, _ = parser.parse_args()
205 sys.exit(main()) 232 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698