Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2012 Google Inc. All rights reserved. | 3 # Copyright (c) 2012 Google Inc. 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 import copy | 7 import copy |
| 8 import gyp.input | 8 import gyp.input |
| 9 import optparse | 9 import optparse |
| 10 import os.path | 10 import os.path |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 flavor = None | 62 flavor = None |
| 63 if '-' in format: | 63 if '-' in format: |
| 64 format, params['flavor'] = format.split('-', 1) | 64 format, params['flavor'] = format.split('-', 1) |
| 65 | 65 |
| 66 default_variables = copy.copy(default_variables) | 66 default_variables = copy.copy(default_variables) |
| 67 | 67 |
| 68 # Default variables provided by this program and its modules should be | 68 # Default variables provided by this program and its modules should be |
| 69 # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace, | 69 # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace, |
| 70 # avoiding collisions with user and automatic variables. | 70 # avoiding collisions with user and automatic variables. |
| 71 default_variables['GENERATOR'] = format | 71 default_variables['GENERATOR'] = format |
| 72 default_variables['HOST_OS'] = options.host_os | |
| 73 default_variables['TARGET_OS'] = options.target_os | |
|
Torne
2013/03/11 16:16:50
Currently there is a variable OS that's set by som
| |
| 74 default_variables['HOST_ARCH'] = options.host_arch | |
| 75 default_variables['TARGET_ARCH'] = options.target_arch | |
|
Nico
2013/07/05 21:50:50
On Mac (and iOS), targets can have multiple target
| |
| 72 | 76 |
| 73 # Format can be a custom python file, or by default the name of a module | 77 # Format can be a custom python file, or by default the name of a module |
| 74 # within gyp.generator. | 78 # within gyp.generator. |
| 75 if format.endswith('.py'): | 79 if format.endswith('.py'): |
| 76 generator_name = os.path.splitext(format)[0] | 80 generator_name = os.path.splitext(format)[0] |
| 77 path, generator_name = os.path.split(generator_name) | 81 path, generator_name = os.path.split(generator_name) |
| 78 | 82 |
| 79 # Make sure the path to the custom generator is in sys.path | 83 # Make sure the path to the custom generator is in sys.path |
| 80 # Don't worry about removing it once we are done. Keeping the path | 84 # Don't worry about removing it once we are done. Keeping the path |
| 81 # to each generator that is used in sys.path is likely harmless and | 85 # to each generator that is used in sys.path is likely harmless and |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 # --no-circular-check disables the check for circular relationships between | 330 # --no-circular-check disables the check for circular relationships between |
| 327 # .gyp files. These relationships should not exist, but they've only been | 331 # .gyp files. These relationships should not exist, but they've only been |
| 328 # observed to be harmful with the Xcode generator. Chromium's .gyp files | 332 # observed to be harmful with the Xcode generator. Chromium's .gyp files |
| 329 # currently have some circular relationships on non-Mac platforms, so this | 333 # currently have some circular relationships on non-Mac platforms, so this |
| 330 # option allows the strict behavior to be used on Macs and the lenient | 334 # option allows the strict behavior to be used on Macs and the lenient |
| 331 # behavior to be used elsewhere. | 335 # behavior to be used elsewhere. |
| 332 # TODO(mark): Remove this option when http://crbug.com/35878 is fixed. | 336 # TODO(mark): Remove this option when http://crbug.com/35878 is fixed. |
| 333 parser.add_option('--no-circular-check', dest='circular_check', | 337 parser.add_option('--no-circular-check', dest='circular_check', |
| 334 action='store_false', default=True, regenerate=False, | 338 action='store_false', default=True, regenerate=False, |
| 335 help="don't check for circular relationships between files") | 339 help="don't check for circular relationships between files") |
| 340 parser.add_option('--host-os', dest='host_os', action='store', default=None, | |
| 341 metavar='OS', env_name='GYP_HOST_OS', | |
| 342 help='override detected host OS') | |
| 343 parser.add_option('--target-os', dest='target_os', action='store', | |
| 344 default=None, metavar='OS', env_name='GYP_TARGET_OS', | |
| 345 help='crosscompile for a different target OS') | |
| 346 parser.add_option('--host-arch', dest='host_arch', action='store', | |
| 347 default=None, metavar='ARCH', env_name='GYP_HOST_ARCH', | |
| 348 help='override detected host architecture') | |
| 349 parser.add_option('--target-arch', dest='target_arch', action='store', | |
| 350 default=None, metavar='ARCH', env_name='GYP_TARGET_ARCH', | |
| 351 help='crosscompile for a different target architecture') | |
| 336 | 352 |
| 337 # We read a few things from ~/.gyp, so set up a var for that. | 353 # We read a few things from ~/.gyp, so set up a var for that. |
| 338 home_vars = ['HOME'] | 354 home_vars = ['HOME'] |
| 339 if sys.platform in ('cygwin', 'win32'): | 355 if sys.platform in ('cygwin', 'win32'): |
| 340 home_vars.append('USERPROFILE') | 356 home_vars.append('USERPROFILE') |
| 341 home = None | 357 home = None |
| 342 home_dot_gyp = None | 358 home_dot_gyp = None |
| 343 for home_var in home_vars: | 359 for home_var in home_vars: |
| 344 home = os.getenv(home_var) | 360 home = os.getenv(home_var) |
| 345 if home != None: | 361 if home != None: |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 374 | 390 |
| 375 if not options.generator_output and options.use_environment: | 391 if not options.generator_output and options.use_environment: |
| 376 g_o = os.environ.get('GYP_GENERATOR_OUTPUT') | 392 g_o = os.environ.get('GYP_GENERATOR_OUTPUT') |
| 377 if g_o: | 393 if g_o: |
| 378 options.generator_output = g_o | 394 options.generator_output = g_o |
| 379 | 395 |
| 380 if not options.parallel and options.use_environment: | 396 if not options.parallel and options.use_environment: |
| 381 p = os.environ.get('GYP_PARALLEL') | 397 p = os.environ.get('GYP_PARALLEL') |
| 382 options.parallel = bool(p and p != '0') | 398 options.parallel = bool(p and p != '0') |
| 383 | 399 |
| 400 if not options.host_os: | |
| 401 if options.use_environment: | |
| 402 options.host_os = os.environ.get('GYP_HOST_OS') | |
| 403 if not options.host_os: | |
| 404 options.host_os = gyp.common.GetFlavor({}) | |
| 405 | |
| 406 if not options.target_os: | |
| 407 if options.use_environment: | |
| 408 options.target_os = os.environ.get('GYP_TARGET_OS') | |
| 409 if not options.target_os: | |
| 410 options.target_os = options.host_os | |
| 411 | |
| 412 if not options.host_arch: | |
| 413 if options.use_environment: | |
| 414 options.host_arch = os.environ.get('GYP_HOST_ARCH') | |
| 415 if not options.host_arch: | |
| 416 options.host_arch = gyp.common.DetectHostArchitecture() | |
| 417 | |
| 418 if not options.target_arch: | |
| 419 if options.use_environment: | |
| 420 options.target_arch = arch.environ.get('GYP_TARGET_ARCH') | |
| 421 if not options.target_arch: | |
| 422 options.target_arch = options.host_arch | |
| 423 | |
| 384 for mode in options.debug: | 424 for mode in options.debug: |
| 385 gyp.debug[mode] = 1 | 425 gyp.debug[mode] = 1 |
| 386 | 426 |
| 387 # Do an extra check to avoid work when we're not debugging. | 427 # Do an extra check to avoid work when we're not debugging. |
| 388 if DEBUG_GENERAL in gyp.debug: | 428 if DEBUG_GENERAL in gyp.debug: |
| 389 DebugOutput(DEBUG_GENERAL, 'running with these options:') | 429 DebugOutput(DEBUG_GENERAL, 'running with these options:') |
| 390 for option, value in sorted(options.__dict__.items()): | 430 for option, value in sorted(options.__dict__.items()): |
| 391 if option[0] == '_': | 431 if option[0] == '_': |
| 392 continue | 432 continue |
| 393 if isinstance(value, basestring): | 433 if isinstance(value, basestring): |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 | 563 |
| 524 def main(args): | 564 def main(args): |
| 525 try: | 565 try: |
| 526 return gyp_main(args) | 566 return gyp_main(args) |
| 527 except GypError, e: | 567 except GypError, e: |
| 528 sys.stderr.write("gyp: %s\n" % e) | 568 sys.stderr.write("gyp: %s\n" % e) |
| 529 return 1 | 569 return 1 |
| 530 | 570 |
| 531 if __name__ == '__main__': | 571 if __name__ == '__main__': |
| 532 sys.exit(main(sys.argv[1:])) | 572 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |