Chromium Code Reviews| 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 Wheezy sysroots for building chromium. | 6 """Install Debian Wheezy 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. This script can be run manually but | 10 # the oldest supported linux distribution. This script can be run manually but |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 return 'mips' | 84 return 'mips' |
| 85 | 85 |
| 86 raise Error('Unrecognized host arch: %s' % detected_host_arch) | 86 raise Error('Unrecognized host arch: %s' % detected_host_arch) |
| 87 | 87 |
| 88 | 88 |
| 89 def DetectTargetArch(): | 89 def DetectTargetArch(): |
| 90 """Attempt for determine target architecture. | 90 """Attempt for determine target architecture. |
| 91 | 91 |
| 92 This works by looking for target_arch in GYP_DEFINES. | 92 This works by looking for target_arch in GYP_DEFINES. |
| 93 """ | 93 """ |
| 94 # TODO(agrieve): Make this script not depend on GYP_DEFINES so that it works | |
| 95 # with GN as well. | |
| 96 gyp_environment.SetEnvironment() | |
| 97 supplemental_includes = gyp_chromium.GetSupplementalFiles() | |
| 98 gyp_defines = gyp_chromium.GetGypVars(supplemental_includes) | |
| 99 target_arch = gyp_defines.get('target_arch') | 94 target_arch = gyp_defines.get('target_arch') |
| 100 if target_arch == 'x64': | 95 if target_arch == 'x64': |
| 101 return 'amd64' | 96 return 'amd64' |
| 102 elif target_arch == 'ia32': | 97 elif target_arch == 'ia32': |
| 103 return 'i386' | 98 return 'i386' |
| 104 elif target_arch == 'arm': | 99 elif target_arch == 'arm': |
| 105 return 'arm' | 100 return 'arm' |
| 106 elif target_arch == 'arm64': | 101 elif target_arch == 'arm64': |
| 107 return 'arm64' | 102 return 'arm64' |
| 108 elif target_arch == 'mipsel': | 103 elif target_arch == 'mipsel': |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 132 # architecture. | 127 # architecture. |
| 133 target_arch = DetectTargetArch() | 128 target_arch = DetectTargetArch() |
| 134 if target_arch and target_arch not in (host_arch, 'i386', 'arm64'): | 129 if target_arch and target_arch not in (host_arch, 'i386', 'arm64'): |
| 135 InstallSysroot(target_arch) | 130 InstallSysroot(target_arch) |
| 136 | 131 |
| 137 | 132 |
| 138 def main(): | 133 def main(): |
| 139 if options.running_as_hook and not sys.platform.startswith('linux'): | 134 if options.running_as_hook and not sys.platform.startswith('linux'): |
| 140 return 0 | 135 return 0 |
| 141 | 136 |
| 137 if gyp_defines.has_key('use_sysroot') \ | |
| 138 and int(gyp_defines['use_sysroot']) == 0: | |
|
Sam Clegg
2015/12/17 22:17:06
What about just `gyp_defines.get('use_sysroot') ==
| |
| 139 return 0 | |
| 140 | |
| 142 if options.running_as_hook: | 141 if options.running_as_hook: |
| 143 InstallDefaultSysroots() | 142 InstallDefaultSysroots() |
| 144 else: | 143 else: |
| 145 if not options.arch: | 144 if not options.arch: |
| 146 print 'You much specify either --arch or --running-as-hook' | 145 print 'You much specify either --arch or --running-as-hook' |
| 147 return 1 | 146 return 1 |
| 148 InstallSysroot(options.arch) | 147 InstallSysroot(options.arch) |
| 149 | 148 |
| 150 return 0 | 149 return 0 |
| 151 | 150 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 | 208 |
| 210 | 209 |
| 211 if __name__ == '__main__': | 210 if __name__ == '__main__': |
| 212 parser = optparse.OptionParser('usage: %prog [OPTIONS]', description=__doc__) | 211 parser = optparse.OptionParser('usage: %prog [OPTIONS]', description=__doc__) |
| 213 parser.add_option('--running-as-hook', action='store_true', | 212 parser.add_option('--running-as-hook', action='store_true', |
| 214 default=False, help='Used when running from gclient hooks.' | 213 default=False, help='Used when running from gclient hooks.' |
| 215 ' Installs default sysroot images.') | 214 ' Installs default sysroot images.') |
| 216 parser.add_option('--arch', type='choice', choices=valid_archs, | 215 parser.add_option('--arch', type='choice', choices=valid_archs, |
| 217 help='Sysroot architecture: %s' % ', '.join(valid_archs)) | 216 help='Sysroot architecture: %s' % ', '.join(valid_archs)) |
| 218 options, _ = parser.parse_args() | 217 options, _ = parser.parse_args() |
| 218 | |
| 219 # TODO(agrieve): Make this script not depend on GYP_DEFINES so that it works | |
| 220 # with GN as well. | |
| 221 gyp_environment.SetEnvironment() | |
| 222 supplemental_includes = gyp_chromium.GetSupplementalFiles() | |
| 223 gyp_defines = gyp_chromium.GetGypVars(supplemental_includes) | |
|
Sam Clegg
2015/12/17 22:15:45
Can you do this in main and pass gyp_defines to De
| |
| 224 | |
| 219 sys.exit(main()) | 225 sys.exit(main()) |
| OLD | NEW |