| 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 that get built will run on |
| 10 # the oldest supported linux distribution. For ARM64 linux, we have Debian | 10 # the oldest stable version of Debian that we currently support. |
| 11 # Jessie sysroot as Jessie is the first version with ARM64 support. This script | 11 # This script can be run manually but is more often run as part of gclient |
| 12 # can be run manually but is more often run as part of gclient hooks. When run | 12 # hooks. When run from hooks this script is a no-op on non-linux platforms. |
| 13 # from hooks this script is a no-op on non-linux platforms. | |
| 14 | 13 |
| 15 # The sysroot image could be constructed from scratch based on the current | 14 # The sysroot image could be constructed from scratch based on the current |
| 16 # state or Debian Wheezy/Jessie but for consistency we currently use a | 15 # state of the Debian archived but for consistency we currently use a |
| 17 # pre-built root image. The image will normally need to be rebuilt every time | 16 # pre-built root image (we don't want upstream changes to Debian to effect |
| 18 # chrome's build dependencies are changed. | 17 # the chromium build until we choose to pull them in). The images will normally |
| 18 # need to be rebuilt every time chrome's build dependencies are changed but |
| 19 # should also be updated periodically to include upstream security fixed from |
| 20 # Debian. |
| 19 | 21 |
| 20 import hashlib | 22 import hashlib |
| 21 import json | 23 import json |
| 22 import platform | 24 import platform |
| 23 import optparse | 25 import optparse |
| 24 import os | 26 import os |
| 25 import re | 27 import re |
| 26 import shutil | 28 import shutil |
| 27 import subprocess | 29 import subprocess |
| 28 import sys | 30 import sys |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 InstallDefaultSysrootForArch(target_arch) | 138 InstallDefaultSysrootForArch(target_arch) |
| 137 | 139 |
| 138 | 140 |
| 139 def main(args): | 141 def main(args): |
| 140 parser = optparse.OptionParser('usage: %prog [OPTIONS]', description=__doc__) | 142 parser = optparse.OptionParser('usage: %prog [OPTIONS]', description=__doc__) |
| 141 parser.add_option('--running-as-hook', action='store_true', | 143 parser.add_option('--running-as-hook', action='store_true', |
| 142 default=False, help='Used when running from gclient hooks.' | 144 default=False, help='Used when running from gclient hooks.' |
| 143 ' Installs default sysroot images.') | 145 ' Installs default sysroot images.') |
| 144 parser.add_option('--arch', type='choice', choices=VALID_ARCHS, | 146 parser.add_option('--arch', type='choice', choices=VALID_ARCHS, |
| 145 help='Sysroot architecture: %s' % ', '.join(VALID_ARCHS)) | 147 help='Sysroot architecture: %s' % ', '.join(VALID_ARCHS)) |
| 148 parser.add_option('--all', action='store_true', |
| 149 help='Install all sysroot images (useful when updating the' |
| 150 ' images)') |
| 146 options, _ = parser.parse_args(args) | 151 options, _ = parser.parse_args(args) |
| 147 if options.running_as_hook and not sys.platform.startswith('linux'): | 152 if options.running_as_hook and not sys.platform.startswith('linux'): |
| 148 return 0 | 153 return 0 |
| 149 | 154 |
| 150 if options.running_as_hook: | 155 if options.running_as_hook: |
| 151 host_arch = DetectHostArch() | 156 host_arch = DetectHostArch() |
| 152 # PPC/s390 don't use sysroot, see http://crbug.com/646169 | 157 # PPC/s390 don't use sysroot, see http://crbug.com/646169 |
| 153 if host_arch in ['ppc','s390']: | 158 if host_arch in ['ppc','s390']: |
| 154 return 0 | 159 return 0 |
| 155 InstallDefaultSysroots(host_arch) | 160 InstallDefaultSysroots(host_arch) |
| 156 else: | 161 else: |
| 157 if not options.arch: | 162 if options.arch: |
| 163 InstallDefaultSysrootForArch(options.arch) |
| 164 elif options.all: |
| 165 for arch in VALID_ARCHS: |
| 166 InstallDefaultSysrootForArch(arch) |
| 167 else: |
| 158 print 'You much specify either --arch or --running-as-hook' | 168 print 'You much specify either --arch or --running-as-hook' |
| 159 return 1 | 169 return 1 |
| 160 InstallDefaultSysrootForArch(options.arch) | |
| 161 | 170 |
| 162 return 0 | 171 return 0 |
| 163 | 172 |
| 164 def InstallDefaultSysrootForArch(target_arch): | 173 def InstallDefaultSysrootForArch(target_arch): |
| 165 if target_arch == 'amd64': | 174 if target_arch == 'amd64': |
| 166 InstallSysroot('Wheezy', 'amd64') | 175 InstallSysroot('Jessie', 'amd64') |
| 167 elif target_arch == 'arm': | 176 elif target_arch == 'arm': |
| 168 InstallSysroot('Wheezy', 'arm') | 177 InstallSysroot('Jessie', 'arm') |
| 169 elif target_arch == 'arm64': | 178 elif target_arch == 'arm64': |
| 170 InstallSysroot('Jessie', 'arm64') | 179 InstallSysroot('Jessie', 'arm64') |
| 171 elif target_arch == 'i386': | 180 elif target_arch == 'i386': |
| 172 InstallSysroot('Wheezy', 'i386') | 181 InstallSysroot('Jessie', 'i386') |
| 173 elif target_arch == 'mips': | 182 elif target_arch == 'mips': |
| 174 InstallSysroot('Wheezy', 'mips') | 183 InstallSysroot('Jessie', 'mips') |
| 175 else: | 184 else: |
| 176 raise Error('Unknown architecture: %s' % target_arch) | 185 raise Error('Unknown architecture: %s' % target_arch) |
| 177 | 186 |
| 178 def InstallSysroot(target_platform, target_arch): | 187 def InstallSysroot(target_platform, target_arch): |
| 179 # The sysroot directory should match the one specified in build/common.gypi. | 188 # The sysroot directory should match the one specified in build/common.gypi. |
| 180 # TODO(thestig) Consider putting this elsewhere to avoid having to recreate | 189 # TODO(thestig) Consider putting this elsewhere to avoid having to recreate |
| 181 # it on every build. | 190 # it on every build. |
| 182 linux_dir = os.path.dirname(SCRIPT_DIR) | 191 linux_dir = os.path.dirname(SCRIPT_DIR) |
| 183 | 192 |
| 184 sysroots_file = os.path.join(SCRIPT_DIR, 'sysroots.json') | 193 sysroots_file = os.path.join(SCRIPT_DIR, 'sysroots.json') |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 with open(stamp, 'w') as s: | 240 with open(stamp, 'w') as s: |
| 232 s.write(url) | 241 s.write(url) |
| 233 | 242 |
| 234 | 243 |
| 235 if __name__ == '__main__': | 244 if __name__ == '__main__': |
| 236 try: | 245 try: |
| 237 sys.exit(main(sys.argv[1:])) | 246 sys.exit(main(sys.argv[1:])) |
| 238 except Error as e: | 247 except Error as e: |
| 239 sys.stderr.write(str(e) + '\n') | 248 sys.stderr.write(str(e) + '\n') |
| 240 sys.exit(1) | 249 sys.exit(1) |
| OLD | NEW |