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_environment | 11 import gyp_helper |
12 import os | 12 import os |
13 import re | 13 import re |
14 import shlex | 14 import shlex |
15 import subprocess | 15 import subprocess |
16 import string | 16 import string |
17 import sys | 17 import sys |
18 import vs_toolchain | 18 import vs_toolchain |
19 | 19 |
20 script_dir = os.path.dirname(os.path.realpath(__file__)) | 20 script_dir = os.path.dirname(os.path.realpath(__file__)) |
21 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) | 21 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 # TODO(sky): remove analyzer2 once updated recipes. | 192 # TODO(sky): remove analyzer2 once updated recipes. |
193 use_analyzer = len(args) and (args[0] == '--analyzer' or | 193 use_analyzer = len(args) and (args[0] == '--analyzer' or |
194 args[0] == '--analyzer2') | 194 args[0] == '--analyzer2') |
195 if use_analyzer: | 195 if use_analyzer: |
196 args.pop(0) | 196 args.pop(0) |
197 os.environ['GYP_GENERATORS'] = 'analyzer' | 197 os.environ['GYP_GENERATORS'] = 'analyzer' |
198 args.append('-Gconfig_path=' + args.pop(0)) | 198 args.append('-Gconfig_path=' + args.pop(0)) |
199 args.append('-Ganalyzer_output_path=' + args.pop(0)) | 199 args.append('-Ganalyzer_output_path=' + args.pop(0)) |
200 | 200 |
201 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): | 201 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): |
| 202 # Check for landmines (reasons to clobber the build) in any case. |
| 203 print 'Running build/landmines.py...' |
| 204 subprocess.check_call( |
| 205 [sys.executable, os.path.join(script_dir, 'landmines.py')]) |
202 print 'Skipping gyp_chromium due to GYP_CHROMIUM_NO_ACTION env var.' | 206 print 'Skipping gyp_chromium due to GYP_CHROMIUM_NO_ACTION env var.' |
203 sys.exit(0) | 207 sys.exit(0) |
204 | 208 |
205 # Use the Psyco JIT if available. | 209 # Use the Psyco JIT if available. |
206 if psyco: | 210 if psyco: |
207 psyco.profile() | 211 psyco.profile() |
208 print "Enabled Psyco JIT." | 212 print "Enabled Psyco JIT." |
209 | 213 |
210 # Fall back on hermetic python if we happen to get run under cygwin. | 214 # Fall back on hermetic python if we happen to get run under cygwin. |
211 # TODO(bradnelson): take this out once this issue is fixed: | 215 # TODO(bradnelson): take this out once this issue is fixed: |
212 # http://code.google.com/p/gyp/issues/detail?id=177 | 216 # http://code.google.com/p/gyp/issues/detail?id=177 |
213 if sys.platform == 'cygwin': | 217 if sys.platform == 'cygwin': |
214 import find_depot_tools | 218 import find_depot_tools |
215 depot_tools_path = find_depot_tools.add_depot_tools_to_path() | 219 depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
216 python_dir = sorted(glob.glob(os.path.join(depot_tools_path, | 220 python_dir = sorted(glob.glob(os.path.join(depot_tools_path, |
217 'python2*_bin')))[-1] | 221 'python2*_bin')))[-1] |
218 env = os.environ.copy() | 222 env = os.environ.copy() |
219 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') | 223 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') |
220 p = subprocess.Popen( | 224 p = subprocess.Popen( |
221 [os.path.join(python_dir, 'python.exe')] + sys.argv, | 225 [os.path.join(python_dir, 'python.exe')] + sys.argv, |
222 env=env, shell=False) | 226 env=env, shell=False) |
223 p.communicate() | 227 p.communicate() |
224 sys.exit(p.returncode) | 228 sys.exit(p.returncode) |
225 | 229 |
| 230 gyp_helper.apply_chromium_gyp_env() |
| 231 |
226 # This could give false positives since it doesn't actually do real option | 232 # This could give false positives since it doesn't actually do real option |
227 # parsing. Oh well. | 233 # parsing. Oh well. |
228 gyp_file_specified = False | 234 gyp_file_specified = False |
229 for arg in args: | 235 for arg in args: |
230 if arg.endswith('.gyp'): | 236 if arg.endswith('.gyp'): |
231 gyp_file_specified = True | 237 gyp_file_specified = True |
232 break | 238 break |
233 | 239 |
234 # If we didn't get a file, check an env var, and then fall back to | 240 # If we didn't get a file, check an env var, and then fall back to |
235 # assuming 'all.gyp' from the same directory as the script. | 241 # assuming 'all.gyp' from the same directory as the script. |
236 if not gyp_file_specified: | 242 if not gyp_file_specified: |
237 gyp_file = os.environ.get('CHROMIUM_GYP_FILE') | 243 gyp_file = os.environ.get('CHROMIUM_GYP_FILE') |
238 if gyp_file: | 244 if gyp_file: |
239 # Note that CHROMIUM_GYP_FILE values can't have backslashes as | 245 # Note that CHROMIUM_GYP_FILE values can't have backslashes as |
240 # path separators even on Windows due to the use of shlex.split(). | 246 # path separators even on Windows due to the use of shlex.split(). |
241 args.extend(shlex.split(gyp_file)) | 247 args.extend(shlex.split(gyp_file)) |
242 else: | 248 else: |
243 args.append(os.path.join(script_dir, 'all.gyp')) | 249 args.append(os.path.join(script_dir, 'all.gyp')) |
244 | 250 |
245 gyp_environment.SetEnvironment() | |
246 | |
247 # There shouldn't be a circular dependency relationship between .gyp files, | 251 # There shouldn't be a circular dependency relationship between .gyp files, |
248 # but in Chromium's .gyp files, on non-Mac platforms, circular relationships | 252 # but in Chromium's .gyp files, on non-Mac platforms, circular relationships |
249 # currently exist. The check for circular dependencies is currently | 253 # currently exist. The check for circular dependencies is currently |
250 # bypassed on other platforms, but is left enabled on the Mac, where a | 254 # bypassed on other platforms, but is left enabled on the Mac, where a |
251 # violation of the rule causes Xcode to misbehave badly. | 255 # violation of the rule causes Xcode to misbehave badly. |
252 # TODO(mark): Find and kill remaining circular dependencies, and remove this | 256 # TODO(mark): Find and kill remaining circular dependencies, and remove this |
253 # option. http://crbug.com/35878. | 257 # option. http://crbug.com/35878. |
254 # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the | 258 # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the |
255 # list. | 259 # list. |
256 if sys.platform not in ('darwin',): | 260 if sys.platform not in ('darwin',): |
257 args.append('--no-circular-check') | 261 args.append('--no-circular-check') |
258 | 262 |
259 # We explicitly don't support the make gyp generator (crbug.com/348686). Be | 263 # We explicitly don't support the make gyp generator (crbug.com/348686). Be |
260 # nice and fail here, rather than choking in gyp. | 264 # nice and fail here, rather than choking in gyp. |
261 if re.search(r'(^|,|\s)make($|,|\s)', os.environ.get('GYP_GENERATORS', '')): | 265 if re.search(r'(^|,|\s)make($|,|\s)', os.environ.get('GYP_GENERATORS', '')): |
262 print 'Error: make gyp generator not supported (check GYP_GENERATORS).' | 266 print 'Error: make gyp generator not supported (check GYP_GENERATORS).' |
263 sys.exit(1) | 267 sys.exit(1) |
264 | 268 |
| 269 # Default to ninja on linux and windows, but only if no generator has |
| 270 # explicitly been set. |
| 271 # Also default to ninja on mac, but only when not building chrome/ios. |
| 272 # . -f / --format has precedence over the env var, no need to check for it |
| 273 # . set the env var only if it hasn't been set yet |
| 274 # . chromium.gyp_env has been applied to os.environ at this point already |
| 275 if sys.platform.startswith(('linux', 'win', 'freebsd')) and \ |
| 276 not os.environ.get('GYP_GENERATORS'): |
| 277 os.environ['GYP_GENERATORS'] = 'ninja' |
| 278 elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \ |
| 279 not 'OS=ios' in os.environ.get('GYP_DEFINES', []): |
| 280 os.environ['GYP_GENERATORS'] = 'ninja' |
| 281 |
| 282 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() |
| 283 |
265 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check | 284 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check |
266 # to enfore syntax checking. | 285 # to enfore syntax checking. |
267 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') | 286 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') |
268 if syntax_check and int(syntax_check): | 287 if syntax_check and int(syntax_check): |
269 args.append('--check') | 288 args.append('--check') |
270 | 289 |
271 supplemental_includes = GetSupplementalFiles() | 290 supplemental_includes = GetSupplementalFiles() |
272 gyp_vars_dict = GetGypVars(supplemental_includes) | 291 gyp_vars_dict = GetGypVars(supplemental_includes) |
273 | 292 |
274 # TODO(dmikurube): Remove these checks and messages after a while. | 293 # TODO(dmikurube): Remove these checks and messages after a while. |
(...skipping 23 matching lines...) Expand all Loading... |
298 args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()]) | 317 args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()]) |
299 | 318 |
300 if not use_analyzer: | 319 if not use_analyzer: |
301 print 'Updating projects from gyp files...' | 320 print 'Updating projects from gyp files...' |
302 sys.stdout.flush() | 321 sys.stdout.flush() |
303 | 322 |
304 # Off we go... | 323 # Off we go... |
305 gyp_rc = gyp.main(args) | 324 gyp_rc = gyp.main(args) |
306 | 325 |
307 if not use_analyzer: | 326 if not use_analyzer: |
308 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() | 327 # Check for landmines (reasons to clobber the build). This must be run here, |
| 328 # rather than a separate runhooks step so that any environment modifications |
| 329 # from above are picked up. |
| 330 print 'Running build/landmines.py...' |
| 331 subprocess.check_call( |
| 332 [sys.executable, os.path.join(script_dir, 'landmines.py')]) |
| 333 |
309 if vs2013_runtime_dll_dirs: | 334 if vs2013_runtime_dll_dirs: |
310 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs | 335 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs |
311 vs_toolchain.CopyVsRuntimeDlls( | 336 vs_toolchain.CopyVsRuntimeDlls( |
312 os.path.join(chrome_src, GetOutputDirectory()), | 337 os.path.join(chrome_src, GetOutputDirectory()), |
313 (x86_runtime, x64_runtime)) | 338 (x86_runtime, x64_runtime)) |
314 | 339 |
315 sys.exit(gyp_rc) | 340 sys.exit(gyp_rc) |
OLD | NEW |