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