Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: build/linux/sysroot_scripts/install-sysroot.py

Issue 1240123004: Cleanup logic for deciding when to install linux sysroot (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 elif detected_host_arch == 'arm': 87 elif detected_host_arch == 'arm':
88 return 'arm' 88 return 'arm'
89 elif detected_host_arch == 'mips': 89 elif detected_host_arch == 'mips':
90 return 'mips' 90 return 'mips'
91 else: 91 else:
92 print "Unknown host arch: %s" % detected_host_arch 92 print "Unknown host arch: %s" % detected_host_arch
93 93
94 return None 94 return None
95 95
96 96
97 def UsingSysroot(target_arch, gyp_defines):
98 # ChromeOS uses a chroot, so doesn't need a sysroot
99 if 'chromeos=1' in gyp_defines:
100 return False
101
102 # When cross-compiling we always use a sysroot
103 if target_arch in ('arm', 'mips', 'ia32'):
104 return True
105
106 # Setting use_sysroot=1 GYP_DEFINES forces the use of the sysroot even
107 # when not cross compiling
108 if 'use_sysroot=1' in gyp_defines:
109 return True
110
111 # Official builds always use the sysroot.
112 if 'branding=Chrome' in gyp_defines and 'buildtype=Official' in gyp_defines:
113 return True
114
115 return False
116
117
97 def main(): 118 def main():
98 if options.running_as_hook and not sys.platform.startswith('linux'): 119 if options.running_as_hook and not sys.platform.startswith('linux'):
99 return 0 120 return 0
100 121
101 gyp_defines = os.environ.get('GYP_DEFINES', '') 122 gyp_defines = os.environ.get('GYP_DEFINES', '')
102 123
103 if options.arch: 124 if options.arch:
104 target_arch = options.arch 125 target_arch = options.arch
105 else: 126 else:
106 target_arch = DetectArch(gyp_defines) 127 target_arch = DetectArch(gyp_defines)
107 if not target_arch: 128 if not target_arch:
108 print 'Unable to detect host architecture' 129 print 'Unable to detect host architecture'
109 return 1 130 return 1
110 131
111 if options.running_as_hook and target_arch != 'arm' and target_arch != 'mips': 132 if options.running_as_hook and not UsingSysroot(target_arch, gyp_defines):
112 # When run from runhooks, only install the sysroot for an Official Chrome 133 return 0
113 # Linux build, except on ARM where we always use a sysroot.
114 skip_if_defined = ['branding=Chrome', 'buildtype=Official']
115 skip_if_undefined = ['chromeos=1']
116 for option in skip_if_defined:
117 if option not in gyp_defines:
118 return 0
119 for option in skip_if_undefined:
120 if option in gyp_defines:
121 return 0
122 134
123 # The sysroot directory should match the one specified in build/common.gypi. 135 # The sysroot directory should match the one specified in build/common.gypi.
124 # TODO(thestig) Consider putting this else where to avoid having to recreate 136 # TODO(thestig) Consider putting this else where to avoid having to recreate
125 # it on every build. 137 # it on every build.
126 linux_dir = os.path.dirname(SCRIPT_DIR) 138 linux_dir = os.path.dirname(SCRIPT_DIR)
127 if target_arch == 'amd64': 139 if target_arch == 'amd64':
128 sysroot = os.path.join(linux_dir, SYSROOT_DIR_AMD64) 140 sysroot = os.path.join(linux_dir, SYSROOT_DIR_AMD64)
129 tarball_filename = TARBALL_AMD64 141 tarball_filename = TARBALL_AMD64
130 tarball_sha1sum = TARBALL_AMD64_SHA1SUM 142 tarball_sha1sum = TARBALL_AMD64_SHA1SUM
131 revision = REVISION_AMD64 143 revision = REVISION_AMD64
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 parser = optparse.OptionParser('usage: %prog [OPTIONS]') 196 parser = optparse.OptionParser('usage: %prog [OPTIONS]')
185 parser.add_option('--running-as-hook', action='store_true', 197 parser.add_option('--running-as-hook', action='store_true',
186 default=False, help='Used when running from gclient hooks.' 198 default=False, help='Used when running from gclient hooks.'
187 ' In this mode the sysroot will only ' 199 ' In this mode the sysroot will only '
188 'be installed for official Linux ' 200 'be installed for official Linux '
189 'builds or ARM Linux builds') 201 'builds or ARM Linux builds')
190 parser.add_option('--arch', type='choice', choices=valid_archs, 202 parser.add_option('--arch', type='choice', choices=valid_archs,
191 help='Sysroot architecture: %s' % ', '.join(valid_archs)) 203 help='Sysroot architecture: %s' % ', '.join(valid_archs))
192 options, _ = parser.parse_args() 204 options, _ = parser.parse_args()
193 sys.exit(main()) 205 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698