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

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

Issue 1493913002: Always install default host sysroots from gclient runhooks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« 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
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 with open(filename, 'rb') as f: 58 with open(filename, 'rb') as f:
59 while True: 59 while True:
60 # 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.
61 chunk = f.read(1024*1024) 61 chunk = f.read(1024*1024)
62 if not chunk: 62 if not chunk:
63 break 63 break
64 sha1.update(chunk) 64 sha1.update(chunk)
65 return sha1.hexdigest() 65 return sha1.hexdigest()
66 66
67 67
68 def DetectArch(gyp_defines, is_android): 68 def DetectArch(gyp_defines):
69 # Check for optional target_arch and only install for that architecture. 69 # Check for optional target_arch and only install for that architecture.
70 # 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
71 # architecture. 71 # architecture.
72 target_arch = gyp_defines.get('target_arch') 72 target_arch = gyp_defines.get('target_arch')
73 if target_arch == 'x64': 73 if target_arch == 'x64':
74 return 'amd64' 74 return 'amd64'
75 elif target_arch == 'ia32': 75 elif target_arch == 'ia32':
76 return 'i386' 76 return 'i386'
77 elif target_arch == 'arm': 77 elif target_arch == 'arm':
78 return 'arm' 78 return 'arm'
79 elif target_arch == 'arm64': 79 elif target_arch == 'arm64':
80 return 'arm64' 80 return 'arm64'
81 elif target_arch == 'mipsel': 81 elif target_arch == 'mipsel':
82 return 'mips' 82 return 'mips'
83 elif target_arch: 83 elif target_arch:
84 raise Exception('Unrecognized target_arch: %s' % target_arch) 84 raise Exception('Unrecognized target_arch: %s' % target_arch)
85 85
86 if is_android:
87 return 'arm'
88
89 # Figure out host arch using build/detect_host_arch.py and 86 # Figure out host arch using build/detect_host_arch.py and
90 # set target_arch to host arch 87 # set target_arch to host arch
91 detected_host_arch = detect_host_arch.HostArch() 88 detected_host_arch = detect_host_arch.HostArch()
92 if detected_host_arch == 'x64': 89 if detected_host_arch == 'x64':
93 return 'amd64' 90 return 'amd64'
94 elif detected_host_arch == 'ia32': 91 elif detected_host_arch == 'ia32':
95 return 'i386' 92 return 'i386'
96 elif detected_host_arch == 'arm': 93 elif detected_host_arch == 'arm':
97 return 'arm' 94 return 'arm'
98 elif detected_host_arch == 'mips': 95 elif detected_host_arch == 'mips':
99 return 'mips' 96 return 'mips'
100 else: 97 else:
101 print "Unknown host arch: %s" % detected_host_arch 98 print "Unknown host arch: %s" % detected_host_arch
102 99
103 return None 100 return None
104 101
105 102
106 def main(): 103 def main():
107 if options.running_as_hook and not sys.platform.startswith('linux'): 104 if options.running_as_hook and not sys.platform.startswith('linux'):
108 return 0 105 return 0
109 106
107 # TODO(agrieve): Stop using GYP_DEFINES and ensure bots that cross-compile
108 # explicitly download sysroots.
Dirk Pranke 2015/12/02 23:09:22 I don't think we want a bot-only solution, so this
agrieve 2015/12/03 02:06:24 Done.
110 gyp_environment.SetEnvironment() 109 gyp_environment.SetEnvironment()
111 supplemental_includes = gyp_chromium.GetSupplementalFiles() 110 supplemental_includes = gyp_chromium.GetSupplementalFiles()
112 gyp_defines = gyp_chromium.GetGypVars(supplemental_includes) 111 gyp_defines = gyp_chromium.GetGypVars(supplemental_includes)
113 is_android = gyp_defines.get('OS') == 'android'
114
115 if (options.running_as_hook and (not is_android) and
116 (gyp_defines.get('chromeos') or gyp_defines.get('use_sysroot') == '0')):
117 return 0
Sam Clegg 2015/12/02 23:17:46 Why not keep this early out?
agrieve 2015/12/03 02:06:24 Because you might have built with both GYP and GN
118 112
119 if options.arch: 113 if options.arch:
120 target_arch = options.arch 114 target_arch = options.arch
121 else: 115 else:
122 target_arch = DetectArch(gyp_defines, is_android) 116 target_arch = DetectArch(gyp_defines)
123 if not target_arch: 117 if not target_arch:
124 print 'Unable to detect target architecture' 118 print 'Unable to detect target architecture'
125 return 1 119 return 1
126 120
127 if is_android: 121 if target_arch == 'amd64':
Sam Clegg 2015/12/02 23:17:46 Won't target_arch be 'arm' here for most android b
Dirk Pranke 2015/12/02 23:20:38 Not necessarily. The bots don't have to set target
agrieve 2015/12/03 02:06:24 Reworked this to look for the presence of //third_
128 # 32-bit Android builds require a 32-bit host sysroot for the v8 snapshot. 122 # 32-bit Android builds (the default) require a 32-bit host sysroot for
129 if '64' not in target_arch: 123 # the v8 snapshot, and a 64-bit sysroot for host tools. Assume 'amd64'
124 # means default setup.
Dirk Pranke 2015/12/02 23:09:22 I don't think it's really clear what "(the default
agrieve 2015/12/03 02:06:24 reworded.
130 ret = _InstallSysroot('i386') 125 ret = _InstallSysroot('i386')
131 if ret: 126 if ret:
132 return ret 127 return ret
133 # Always need host sysroot (which we assume is x64).
134 target_arch = 'amd64'
135 128
136 return _InstallSysroot(target_arch) 129 return _InstallSysroot(target_arch)
137 130
138 131
139 def _InstallSysroot(target_arch): 132 def _InstallSysroot(target_arch):
140 # The sysroot directory should match the one specified in build/common.gypi. 133 # The sysroot directory should match the one specified in build/common.gypi.
141 # TODO(thestig) Consider putting this else where to avoid having to recreate 134 # TODO(thestig) Consider putting this else where to avoid having to recreate
142 # it on every build. 135 # it on every build.
143 linux_dir = os.path.dirname(SCRIPT_DIR) 136 linux_dir = os.path.dirname(SCRIPT_DIR)
144 if target_arch == 'amd64': 137 if target_arch == 'amd64':
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 parser = optparse.OptionParser('usage: %prog [OPTIONS]') 194 parser = optparse.OptionParser('usage: %prog [OPTIONS]')
202 parser.add_option('--running-as-hook', action='store_true', 195 parser.add_option('--running-as-hook', action='store_true',
203 default=False, help='Used when running from gclient hooks.' 196 default=False, help='Used when running from gclient hooks.'
204 ' In this mode the sysroot will only ' 197 ' In this mode the sysroot will only '
205 'be installed for official Linux ' 198 'be installed for official Linux '
206 'builds or ARM Linux builds') 199 'builds or ARM Linux builds')
207 parser.add_option('--arch', type='choice', choices=valid_archs, 200 parser.add_option('--arch', type='choice', choices=valid_archs,
208 help='Sysroot architecture: %s' % ', '.join(valid_archs)) 201 help='Sysroot architecture: %s' % ', '.join(valid_archs))
209 options, _ = parser.parse_args() 202 options, _ = parser.parse_args()
210 sys.exit(main()) 203 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