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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 return 'i386' | 81 return 'i386' |
82 elif detected_host_arch == 'arm': | 82 elif detected_host_arch == 'arm': |
83 return 'arm' | 83 return 'arm' |
84 else: | 84 else: |
85 print "Unknown host arch: %s" % detected_host_arch | 85 print "Unknown host arch: %s" % detected_host_arch |
86 | 86 |
87 return None | 87 return None |
88 | 88 |
89 | 89 |
90 def main(): | 90 def main(): |
91 if options.linux_only: | 91 if options.running_as_hook and not sys.platform.startswith('linux'): |
92 # This argument is passed when run from the gclient hooks. | 92 return 0 |
93 # In this case we return early on non-linux platforms. | |
94 if not sys.platform.startswith('linux'): | |
95 return 0 | |
96 | 93 |
97 gyp_defines = os.environ.get('GYP_DEFINES', '') | 94 gyp_defines = os.environ.get('GYP_DEFINES', '') |
98 | 95 |
99 if options.arch: | 96 if options.arch: |
100 target_arch = options.arch | 97 target_arch = options.arch |
101 else: | 98 else: |
102 target_arch = DetectArch(gyp_defines) | 99 target_arch = DetectArch(gyp_defines) |
103 if not target_arch: | 100 if not target_arch: |
104 print 'Unable to detect host architecture' | 101 print 'Unable to detect host architecture' |
105 return 1 | 102 return 1 |
106 | 103 |
107 if options.linux_only and target_arch != 'arm': | 104 if options.running_as_hook and target_arch != 'arm' : |
Lei Zhang
2015/05/13 01:04:48
nit: extra space?
Sam Clegg
2015/05/13 01:13:23
Done.
| |
108 # When run from runhooks, only install the sysroot for an Official Chrome | 105 # When run from runhooks, only install the sysroot for an Official Chrome |
109 # Linux build, except on ARM where we always use a sysroot. | 106 # Linux build, except on ARM where we always use a sysroot. |
110 defined = ['branding=Chrome', 'buildtype=Official'] | 107 skip_if_defined = ['branding=Chrome', 'buildtype=Official'] |
111 undefined = ['chromeos=1'] | 108 skip_if_undefined = ['chromeos=1'] |
112 for option in defined: | 109 for option in skip_if_defined: |
113 if option not in gyp_defines: | 110 if option not in gyp_defines: |
114 return 0 | 111 return 0 |
115 for option in undefined: | 112 for option in skip_if_undefined: |
116 if option in gyp_defines: | 113 if option in gyp_defines: |
117 return 0 | 114 return 0 |
118 | 115 |
119 # The sysroot directory should match the one specified in build/common.gypi. | 116 # The sysroot directory should match the one specified in build/common.gypi. |
120 # TODO(thestig) Consider putting this else where to avoid having to recreate | 117 # TODO(thestig) Consider putting this else where to avoid having to recreate |
121 # it on every build. | 118 # it on every build. |
122 linux_dir = os.path.dirname(SCRIPT_DIR) | 119 linux_dir = os.path.dirname(SCRIPT_DIR) |
123 if target_arch == 'amd64': | 120 if target_arch == 'amd64': |
124 sysroot = os.path.join(linux_dir, SYSROOT_DIR_AMD64) | 121 sysroot = os.path.join(linux_dir, SYSROOT_DIR_AMD64) |
125 tarball_filename = TARBALL_AMD64 | 122 tarball_filename = TARBALL_AMD64 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) | 163 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) |
167 os.remove(tarball) | 164 os.remove(tarball) |
168 | 165 |
169 with open(stamp, 'w') as s: | 166 with open(stamp, 'w') as s: |
170 s.write(url) | 167 s.write(url) |
171 return 0 | 168 return 0 |
172 | 169 |
173 | 170 |
174 if __name__ == '__main__': | 171 if __name__ == '__main__': |
175 parser = optparse.OptionParser('usage: %prog [OPTIONS]') | 172 parser = optparse.OptionParser('usage: %prog [OPTIONS]') |
176 parser.add_option('--linux-only', action='store_true', | 173 parser.add_option('--running-as-hook', action='store_true', |
177 default=False, help='Only install sysroot for official ' | 174 default=False, help='Only install sysroot for official ' |
Lei Zhang
2015/05/13 01:04:48
Update the help msg?
Sam Clegg
2015/05/13 01:13:23
Done.
| |
178 'Linux builds') | 175 'Linux builds') |
179 parser.add_option('--arch', type='choice', choices=valid_archs, | 176 parser.add_option('--arch', type='choice', choices=valid_archs, |
180 help='Sysroot architecture: %s' % ', '.join(valid_archs)) | 177 help='Sysroot architecture: %s' % ', '.join(valid_archs)) |
181 options, _ = parser.parse_args() | 178 options, _ = parser.parse_args() |
182 sys.exit(main()) | 179 sys.exit(main()) |
OLD | NEW |