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

Side by Side Diff: pylib/gyp/__init__.py

Issue 1004803005: Export generator flavor to gyp scripts (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Address comments Created 5 years, 9 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 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 circular_check=True): 52 circular_check=True):
53 """ 53 """
54 Loads one or more specified build files. 54 Loads one or more specified build files.
55 default_variables and includes will be copied before use. 55 default_variables and includes will be copied before use.
56 Returns the generator for the specified format and the 56 Returns the generator for the specified format and the
57 data returned by loading the specified build files. 57 data returned by loading the specified build files.
58 """ 58 """
59 if params is None: 59 if params is None:
60 params = {} 60 params = {}
61 61
62 flavor = None
63 if '-' in format: 62 if '-' in format:
64 format, params['flavor'] = format.split('-', 1) 63 format, params['flavor'] = format.split('-', 1)
65 64
66 default_variables = copy.copy(default_variables) 65 default_variables = copy.copy(default_variables)
67 66
68 # Default variables provided by this program and its modules should be 67 # Default variables provided by this program and its modules should be
69 # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace, 68 # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace,
70 # avoiding collisions with user and automatic variables. 69 # avoiding collisions with user and automatic variables.
71 default_variables['GENERATOR'] = format 70 default_variables['GENERATOR'] = format
71 default_variables['GENERATOR_FLAVOR'] = params.get('flavor', '')
72 72
73 # Format can be a custom python file, or by default the name of a module 73 # Format can be a custom python file, or by default the name of a module
74 # within gyp.generator. 74 # within gyp.generator.
75 if format.endswith('.py'): 75 if format.endswith('.py'):
76 generator_name = os.path.splitext(format)[0] 76 generator_name = os.path.splitext(format)[0]
77 path, generator_name = os.path.split(generator_name) 77 path, generator_name = os.path.split(generator_name)
78 78
79 # Make sure the path to the custom generator is in sys.path 79 # 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 80 # 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 81 # to each generator that is used in sys.path is likely harmless and
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 except GypError, e: 527 except GypError, e:
528 sys.stderr.write("gyp: %s\n" % e) 528 sys.stderr.write("gyp: %s\n" % e)
529 return 1 529 return 1
530 530
531 # NOTE: setuptools generated console_scripts calls function with no arguments 531 # NOTE: setuptools generated console_scripts calls function with no arguments
532 def script_main(): 532 def script_main():
533 return main(sys.argv[1:]) 533 return main(sys.argv[1:])
534 534
535 if __name__ == '__main__': 535 if __name__ == '__main__':
536 sys.exit(script_main()) 536 sys.exit(script_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