OLD | NEW |
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 elif detected_host_arch == 'arm': | 96 elif detected_host_arch == 'arm': |
97 return 'arm' | 97 return 'arm' |
98 elif detected_host_arch == 'mips': | 98 elif detected_host_arch == 'mips': |
99 return 'mips' | 99 return 'mips' |
100 else: | 100 else: |
101 print "Unknown host arch: %s" % detected_host_arch | 101 print "Unknown host arch: %s" % detected_host_arch |
102 | 102 |
103 return None | 103 return None |
104 | 104 |
105 | 105 |
| 106 def UsingSysroot(target_arch, is_android, gyp_defines): |
| 107 # ChromeOS uses a chroot, so doesn't need a sysroot |
| 108 if gyp_defines.get('chromeos'): |
| 109 return False |
| 110 |
| 111 # When cross-compiling non-Android builds we always use a sysroot |
| 112 if not is_android and target_arch in ('arm', 'mips', 'i386'): |
| 113 return True |
| 114 |
| 115 # Setting use_sysroot=1 GYP_DEFINES forces the use of the sysroot even |
| 116 # when not cross compiling |
| 117 if gyp_defines.get('use_sysroot'): |
| 118 return True |
| 119 |
| 120 # Official builds always use the sysroot. |
| 121 if (gyp_defines.get('branding') == 'Chrome' and |
| 122 gyp_defines.get('buildtype') == 'Official'): |
| 123 return True |
| 124 |
| 125 return False |
| 126 |
| 127 |
106 def main(): | 128 def main(): |
107 if options.running_as_hook and not sys.platform.startswith('linux'): | 129 if options.running_as_hook and not sys.platform.startswith('linux'): |
108 return 0 | 130 return 0 |
109 | 131 |
110 gyp_environment.SetEnvironment() | 132 gyp_environment.SetEnvironment() |
111 supplemental_includes = gyp_chromium.GetSupplementalFiles() | 133 supplemental_includes = gyp_chromium.GetSupplementalFiles() |
112 gyp_defines = gyp_chromium.GetGypVars(supplemental_includes) | 134 gyp_defines = gyp_chromium.GetGypVars(supplemental_includes) |
113 is_android = gyp_defines.get('OS') == 'android' | 135 is_android = gyp_defines.get('OS') == 'android' |
114 | 136 |
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 | |
118 | |
119 if options.arch: | 137 if options.arch: |
120 target_arch = options.arch | 138 target_arch = options.arch |
121 else: | 139 else: |
122 target_arch = DetectArch(gyp_defines, is_android) | 140 target_arch = DetectArch(gyp_defines, is_android) |
123 if not target_arch: | 141 if not target_arch: |
124 print 'Unable to detect target architecture' | 142 print 'Unable to detect target architecture' |
125 return 1 | 143 return 1 |
126 | 144 |
| 145 if (options.running_as_hook and |
| 146 not UsingSysroot(target_arch, is_android, gyp_defines)): |
| 147 return 0 |
| 148 |
127 if is_android: | 149 if is_android: |
128 # 32-bit Android builds require a 32-bit host sysroot for the v8 snapshot. | 150 # 32-bit Android builds require a 32-bit host sysroot for the v8 snapshot. |
129 if '64' not in target_arch: | 151 if '64' not in target_arch: |
130 ret = _InstallSysroot('i386') | 152 ret = _InstallSysroot('i386') |
131 if ret: | 153 if ret: |
132 return ret | 154 return ret |
133 # Always need host sysroot (which we assume is x64). | 155 # Always need host sysroot (which we assume is x64). |
134 target_arch = 'amd64' | 156 target_arch = 'amd64' |
135 | 157 |
136 return _InstallSysroot(target_arch) | 158 return _InstallSysroot(target_arch) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 parser = optparse.OptionParser('usage: %prog [OPTIONS]') | 223 parser = optparse.OptionParser('usage: %prog [OPTIONS]') |
202 parser.add_option('--running-as-hook', action='store_true', | 224 parser.add_option('--running-as-hook', action='store_true', |
203 default=False, help='Used when running from gclient hooks.' | 225 default=False, help='Used when running from gclient hooks.' |
204 ' In this mode the sysroot will only ' | 226 ' In this mode the sysroot will only ' |
205 'be installed for official Linux ' | 227 'be installed for official Linux ' |
206 'builds or ARM Linux builds') | 228 'builds or ARM Linux builds') |
207 parser.add_option('--arch', type='choice', choices=valid_archs, | 229 parser.add_option('--arch', type='choice', choices=valid_archs, |
208 help='Sysroot architecture: %s' % ', '.join(valid_archs)) | 230 help='Sysroot architecture: %s' % ', '.join(valid_archs)) |
209 options, _ = parser.parse_args() | 231 options, _ = parser.parse_args() |
210 sys.exit(main()) | 232 sys.exit(main()) |
OLD | NEW |