| 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 """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 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if detected_host_arch == 'x64': | 101 if detected_host_arch == 'x64': |
| 102 return 'amd64' | 102 return 'amd64' |
| 103 elif detected_host_arch == 'ia32': | 103 elif detected_host_arch == 'ia32': |
| 104 return 'i386' | 104 return 'i386' |
| 105 elif detected_host_arch == 'arm': | 105 elif detected_host_arch == 'arm': |
| 106 return 'arm' | 106 return 'arm' |
| 107 elif detected_host_arch == 'arm64': | 107 elif detected_host_arch == 'arm64': |
| 108 return 'arm64' | 108 return 'arm64' |
| 109 elif detected_host_arch == 'mips': | 109 elif detected_host_arch == 'mips': |
| 110 return 'mips' | 110 return 'mips' |
| 111 elif detected_host_arch == 'ppc': |
| 112 return 'ppc' |
| 113 elif detected_host_arch == 's390': |
| 114 return 's390' |
| 111 | 115 |
| 112 raise Error('Unrecognized host arch: %s' % detected_host_arch) | 116 raise Error('Unrecognized host arch: %s' % detected_host_arch) |
| 113 | 117 |
| 114 | 118 |
| 115 def DetectTargetArch(): | 119 def DetectTargetArch(): |
| 116 """Attempt for determine target architecture. | 120 """Attempt for determine target architecture. |
| 117 | 121 |
| 118 This works by looking for target_arch in GYP_DEFINES. | 122 This works by looking for target_arch in GYP_DEFINES. |
| 119 """ | 123 """ |
| 120 # TODO(agrieve): Make this script not depend on GYP_DEFINES so that it works | 124 # TODO(agrieve): Make this script not depend on GYP_DEFINES so that it works |
| 121 # with GN as well. | 125 # with GN as well. |
| 122 gyp_environment.SetEnvironment() | 126 gyp_environment.SetEnvironment() |
| 123 supplemental_includes = gyp_chromium.GetSupplementalFiles() | 127 supplemental_includes = gyp_chromium.GetSupplementalFiles() |
| 124 gyp_defines = gyp_chromium.GetGypVars(supplemental_includes) | 128 gyp_defines = gyp_chromium.GetGypVars(supplemental_includes) |
| 125 target_arch = gyp_defines.get('target_arch') | 129 target_arch = gyp_defines.get('target_arch') |
| 126 if target_arch == 'x64': | 130 if target_arch == 'x64': |
| 127 return 'amd64' | 131 return 'amd64' |
| 128 elif target_arch == 'ia32': | 132 elif target_arch == 'ia32': |
| 129 return 'i386' | 133 return 'i386' |
| 130 elif target_arch == 'arm': | 134 elif target_arch == 'arm': |
| 131 return 'arm' | 135 return 'arm' |
| 132 elif target_arch == 'arm64': | 136 elif target_arch == 'arm64': |
| 133 return 'arm64' | 137 return 'arm64' |
| 134 elif target_arch == 'mipsel': | 138 elif target_arch == 'mipsel': |
| 135 return 'mips' | 139 return 'mips' |
| 136 | 140 |
| 137 return None | 141 return None |
| 138 | 142 |
| 139 | 143 |
| 140 def InstallDefaultSysroots(): | 144 def InstallDefaultSysroots(host_arch): |
| 141 """Install the default set of sysroot images. | 145 """Install the default set of sysroot images. |
| 142 | 146 |
| 143 This includes at least the sysroot for host architecture, and the 32-bit | 147 This includes at least the sysroot for host architecture, and the 32-bit |
| 144 sysroot for building the v8 snapshot image. It can also include the cross | 148 sysroot for building the v8 snapshot image. It can also include the cross |
| 145 compile sysroot for ARM/MIPS if cross compiling environment can be detected. | 149 compile sysroot for ARM/MIPS if cross compiling environment can be detected. |
| 146 | 150 |
| 147 Another reason we're installing this by default is so that developers can | 151 Another reason we're installing this by default is so that developers can |
| 148 compile and run on our supported platforms without having to worry about | 152 compile and run on our supported platforms without having to worry about |
| 149 flipping things back and forth and whether the sysroots have been downloaded | 153 flipping things back and forth and whether the sysroots have been downloaded |
| 150 or not. | 154 or not. |
| 151 """ | 155 """ |
| 152 host_arch = DetectHostArch() | |
| 153 InstallDefaultSysrootForArch(host_arch) | 156 InstallDefaultSysrootForArch(host_arch) |
| 154 | 157 |
| 155 if host_arch == 'amd64': | 158 if host_arch == 'amd64': |
| 156 InstallDefaultSysrootForArch('i386') | 159 InstallDefaultSysrootForArch('i386') |
| 157 | 160 |
| 158 # Desktop Chromium OS builds require the precise sysroot. | 161 # Desktop Chromium OS builds require the precise sysroot. |
| 159 # TODO(thomasanderson): only download this when the GN arg target_os | 162 # TODO(thomasanderson): only download this when the GN arg target_os |
| 160 # == 'chromeos', when the functionality to perform the check becomes | 163 # == 'chromeos', when the functionality to perform the check becomes |
| 161 # available. | 164 # available. |
| 162 InstallSysroot('Precise', 'amd64') | 165 InstallSysroot('Precise', 'amd64') |
| (...skipping 12 matching lines...) Expand all Loading... |
| 175 parser.add_option('--running-as-hook', action='store_true', | 178 parser.add_option('--running-as-hook', action='store_true', |
| 176 default=False, help='Used when running from gclient hooks.' | 179 default=False, help='Used when running from gclient hooks.' |
| 177 ' Installs default sysroot images.') | 180 ' Installs default sysroot images.') |
| 178 parser.add_option('--arch', type='choice', choices=valid_archs, | 181 parser.add_option('--arch', type='choice', choices=valid_archs, |
| 179 help='Sysroot architecture: %s' % ', '.join(valid_archs)) | 182 help='Sysroot architecture: %s' % ', '.join(valid_archs)) |
| 180 options, _ = parser.parse_args(args) | 183 options, _ = parser.parse_args(args) |
| 181 if options.running_as_hook and not sys.platform.startswith('linux'): | 184 if options.running_as_hook and not sys.platform.startswith('linux'): |
| 182 return 0 | 185 return 0 |
| 183 | 186 |
| 184 if options.running_as_hook: | 187 if options.running_as_hook: |
| 185 InstallDefaultSysroots() | 188 host_arch = DetectHostArch() |
| 189 # PPC/s390 don't use sysroot, see http://crbug.com/646169 |
| 190 if host_arch in ['ppc','s390']: |
| 191 return 0 |
| 192 InstallDefaultSysroots(host_arch) |
| 186 else: | 193 else: |
| 187 if not options.arch: | 194 if not options.arch: |
| 188 print 'You much specify either --arch or --running-as-hook' | 195 print 'You much specify either --arch or --running-as-hook' |
| 189 return 1 | 196 return 1 |
| 190 InstallDefaultSysrootForArch(options.arch) | 197 InstallDefaultSysrootForArch(options.arch) |
| 191 | 198 |
| 192 return 0 | 199 return 0 |
| 193 | 200 |
| 194 def InstallDefaultSysrootForArch(target_arch): | 201 def InstallDefaultSysrootForArch(target_arch): |
| 195 if target_arch == 'amd64': | 202 if target_arch == 'amd64': |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 with open(stamp, 'w') as s: | 257 with open(stamp, 'w') as s: |
| 251 s.write(url) | 258 s.write(url) |
| 252 | 259 |
| 253 | 260 |
| 254 if __name__ == '__main__': | 261 if __name__ == '__main__': |
| 255 try: | 262 try: |
| 256 sys.exit(main(sys.argv[1:])) | 263 sys.exit(main(sys.argv[1:])) |
| 257 except Error as e: | 264 except Error as e: |
| 258 sys.stderr.write(str(e) + '\n') | 265 sys.stderr.write(str(e) + '\n') |
| 259 sys.exit(1) | 266 sys.exit(1) |
| OLD | NEW |