OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # This script is wrapper for Chromium that adds some support for how GYP | 7 # This script is wrapper for Chromium that adds some support for how GYP |
8 # is invoked by Chromium beyond what can be done in the gclient hooks. | 8 # is invoked by Chromium beyond what can be done in the gclient hooks. |
9 | 9 |
10 import glob | 10 import glob |
11 import gyp_helper | 11 import gyp_helper |
12 import os | 12 import os |
| 13 import pipes |
13 import shlex | 14 import shlex |
14 import subprocess | 15 import subprocess |
15 import sys | 16 import sys |
16 | 17 |
17 script_dir = os.path.dirname(os.path.realpath(__file__)) | 18 script_dir = os.path.dirname(os.path.realpath(__file__)) |
18 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) | 19 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
19 | 20 |
20 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) | 21 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) |
21 import gyp | 22 import gyp |
22 | 23 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 # Also default to ninja on mac, but only when not building chrome/ios. | 145 # Also default to ninja on mac, but only when not building chrome/ios. |
145 # . -f / --format has precedence over the env var, no need to check for it | 146 # . -f / --format has precedence over the env var, no need to check for it |
146 # . set the env var only if it hasn't been set yet | 147 # . set the env var only if it hasn't been set yet |
147 # . chromium.gyp_env has been applied to os.environ at this point already | 148 # . chromium.gyp_env has been applied to os.environ at this point already |
148 if sys.platform.startswith('linux') and not os.environ.get('GYP_GENERATORS'): | 149 if sys.platform.startswith('linux') and not os.environ.get('GYP_GENERATORS'): |
149 os.environ['GYP_GENERATORS'] = 'ninja' | 150 os.environ['GYP_GENERATORS'] = 'ninja' |
150 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \ | 151 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \ |
151 not 'OS=ios' in os.environ.get('GYP_DEFINES', []): | 152 not 'OS=ios' in os.environ.get('GYP_DEFINES', []): |
152 os.environ['GYP_GENERATORS'] = 'ninja' | 153 os.environ['GYP_GENERATORS'] = 'ninja' |
153 | 154 |
| 155 # If using ninja on windows, and not opting out of the the automatic |
| 156 # toolchain, then set up variables for the automatic toolchain. Opt-out is |
| 157 # on by default, for now. |
| 158 if (sys.platform in ('win32', 'cygwin') and |
| 159 os.environ.get('GYP_GENERATORS') == 'ninja' and |
| 160 os.environ.get('GYP_MSVS_USE_SYSTEM_TOOLCHAIN', '1') != '1'): |
| 161 # For now, call the acquisition script here so that there's only one |
| 162 # opt-in step required. This will be moved to a separate DEPS step once |
| 163 # it's on by default. |
| 164 subprocess.check_call([ |
| 165 sys.executable, |
| 166 os.path.normpath(os.path.join(script_dir, '..', 'tools', 'win', |
| 167 'toolchain', |
| 168 'get_toolchain_if_necessary.py'))]) |
| 169 toolchain = os.path.normpath(os.path.join( |
| 170 script_dir, '..', 'third_party', 'win_toolchain', 'files')) |
| 171 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain |
| 172 os.environ['GYP_MSVS_VERSION'] = '2013' |
| 173 # We need to make sure windows_sdk_path is set to the automated toolchain |
| 174 # values in GYP_DEFINES, but don't want to override any other values there. |
| 175 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) |
| 176 win8sdk = os.path.join(toolchain, 'win8sdk') |
| 177 gyp_defines_dict['windows_sdk_path'] = win8sdk |
| 178 os.environ['WINDOWSSDKDIR'] = win8sdk |
| 179 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v))) |
| 180 for k, v in gyp_defines_dict.iteritems()) |
| 181 print('Using automatic toolchain in %s.' % toolchain) |
| 182 |
154 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check | 183 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check |
155 # to enfore syntax checking. | 184 # to enfore syntax checking. |
156 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') | 185 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') |
157 if syntax_check and int(syntax_check): | 186 if syntax_check and int(syntax_check): |
158 args.append('--check') | 187 args.append('--check') |
159 | 188 |
160 print 'Updating projects from gyp files...' | 189 print 'Updating projects from gyp files...' |
161 sys.stdout.flush() | 190 sys.stdout.flush() |
162 | 191 |
163 # Off we go... | 192 # Off we go... |
164 sys.exit(gyp.main(args)) | 193 sys.exit(gyp.main(args)) |
OLD | NEW |