OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright 2014 Google Inc. | 3 # Copyright 2014 Google Inc. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 """ | 8 """ |
9 Functions for parsing the gypd output from gyp. | 9 Functions for parsing the gypd output from gyp. |
10 """ | 10 """ |
11 | 11 |
12 import vars_dict_lib | |
13 | |
14 def parse_dictionary(var_dict, d, current_target_name): | 12 def parse_dictionary(var_dict, d, current_target_name): |
15 """ | 13 """ |
16 Helper function to get the meaningful entries in a dictionary. | 14 Helper function to get the meaningful entries in a dictionary. |
17 @param var_dict VarsDict object for storing the results of the parsing. | 15 @param var_dict VarsDict object for storing the results of the parsing. |
18 @param d Dictionary object to parse. | 16 @param d Dictionary object to parse. |
19 @param current_target_name The current target being parsed. If this | 17 @param current_target_name The current target being parsed. If this |
20 dictionary is a target, this will be its entry | 18 dictionary is a target, this will be its entry |
21 'target_name'. Otherwise, this will be the name of | 19 'target_name'. Otherwise, this will be the name of |
22 the target which contains this dictionary. | 20 the target which contains this dictionary. |
23 """ | 21 """ |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 include = include.replace('..', '$(LOCAL_PATH)', 1) | 80 include = include.replace('..', '$(LOCAL_PATH)', 1) |
83 # Remove a trailing slash, if present. | 81 # Remove a trailing slash, if present. |
84 if include.endswith('/'): | 82 if include.endswith('/'): |
85 include = include[:-1] | 83 include = include[:-1] |
86 var_dict.LOCAL_C_INCLUDES.add(include) | 84 var_dict.LOCAL_C_INCLUDES.add(include) |
87 # For the top level, libskia, include directories should be exported. | 85 # For the top level, libskia, include directories should be exported. |
88 if current_target_name == 'libskia': | 86 if current_target_name == 'libskia': |
89 var_dict.LOCAL_EXPORT_C_INCLUDE_DIRS.add(include) | 87 var_dict.LOCAL_EXPORT_C_INCLUDE_DIRS.add(include) |
90 | 88 |
91 for define in d.get('defines', []): | 89 for define in d.get('defines', []): |
92 var_dict.LOCAL_CFLAGS.add('-D' + define) | 90 var_dict.DEFINES.add(define) |
93 | 91 |
94 | 92 |
95 def parse_gypd(var_dict, path, desired_targets=None): | 93 def parse_gypd(var_dict, path, desired_targets=None): |
96 """ | 94 """ |
97 Parse a gypd file. | 95 Parse a gypd file. |
98 @param var_dict VarsDict object for storing the result of the parse. | 96 @param var_dict VarsDict object for storing the result of the parse. |
99 @param path Path to gypd file. | 97 @param path Path to gypd file. |
100 @param desired_targets List of targets to be parsed from this file. If empty, | 98 @param desired_targets List of targets to be parsed from this file. If empty, |
101 parse all targets. | 99 parse all targets. |
102 """ | 100 """ |
(...skipping 10 matching lines...) Expand all Loading... |
113 # Avoid circular dependencies | 111 # Avoid circular dependencies |
114 continue | 112 continue |
115 if desired_targets and target_name not in desired_targets: | 113 if desired_targets and target_name not in desired_targets: |
116 # Our caller does not depend on this one | 114 # Our caller does not depend on this one |
117 continue | 115 continue |
118 # Add it to our known targets so we don't parse it again | 116 # Add it to our known targets so we don't parse it again |
119 var_dict.KNOWN_TARGETS.add(target_name) | 117 var_dict.KNOWN_TARGETS.add(target_name) |
120 | 118 |
121 parse_dictionary(var_dict, target, target_name) | 119 parse_dictionary(var_dict, target, target_name) |
122 | 120 |
OLD | NEW |