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

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

Issue 10383073: Remove duplicate function definitions I accidentally added in r1357. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« 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 # Copyright (c) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from compiler.ast import Const 5 from compiler.ast import Const
6 from compiler.ast import Dict 6 from compiler.ast import Dict
7 from compiler.ast import Discard 7 from compiler.ast import Discard
8 from compiler.ast import List 8 from compiler.ast import List
9 from compiler.ast import Module 9 from compiler.ast import Module
10 from compiler.ast import Node 10 from compiler.ast import Node
(...skipping 2155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 if len(files) > 1: 2166 if len(files) > 1:
2167 error += ' %s: %s\n' % (basename, ' '.join(files)) 2167 error += ' %s: %s\n' % (basename, ' '.join(files))
2168 2168
2169 if error: 2169 if error:
2170 print ('static library %s has several files with the same basename:\n' % 2170 print ('static library %s has several files with the same basename:\n' %
2171 target + error + 'Some build systems, e.g. MSVC08, ' 2171 target + error + 'Some build systems, e.g. MSVC08, '
2172 'cannot handle that.') 2172 'cannot handle that.')
2173 raise KeyError, 'Duplicate basenames in sources section, see list above' 2173 raise KeyError, 'Duplicate basenames in sources section, see list above'
2174 2174
2175 2175
2176 def ValidateSourcesInTarget(target, target_dict, build_file):
2177 # TODO: Check if MSVC allows this for non-static_library targets.
2178 if target_dict.get('type', None) != 'static_library':
2179 return
2180 sources = target_dict.get('sources', [])
2181 basenames = {}
2182 for source in sources:
2183 name, ext = os.path.splitext(source)
2184 is_compiled_file = ext in [
2185 '.c', '.cc', '.cpp', '.cxx', '.m', '.mm', '.s', '.S']
2186 if not is_compiled_file:
2187 continue
2188 basename = os.path.basename(name) # Don't include extension.
2189 basenames.setdefault(basename, []).append(source)
2190
2191 error = ''
2192 for basename, files in basenames.iteritems():
2193 if len(files) > 1:
2194 error += ' %s: %s\n' % (basename, ' '.join(files))
2195
2196 if error:
2197 print ('static library %s has several files with the same basename:\n' %
2198 target + error + 'Some build systems, e.g. MSVC08, '
2199 'cannot handle that.')
2200 raise KeyError, 'Duplicate basenames in sources section, see list above'
2201
2202
2203 def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules): 2176 def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules):
2204 """Ensures that the rules sections in target_dict are valid and consistent, 2177 """Ensures that the rules sections in target_dict are valid and consistent,
2205 and determines which sources they apply to. 2178 and determines which sources they apply to.
2206 2179
2207 Arguments: 2180 Arguments:
2208 target: string, name of target. 2181 target: string, name of target.
2209 target_dict: dict, target spec containing "rules" and "sources" lists. 2182 target_dict: dict, target spec containing "rules" and "sources" lists.
2210 extra_sources_for_rules: a list of keys to scan for rule matches in 2183 extra_sources_for_rules: a list of keys to scan for rule matches in
2211 addition to 'sources'. 2184 addition to 'sources'.
2212 """ 2185 """
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 if not action_name: 2269 if not action_name:
2297 raise Exception("Anonymous action in target %s. " 2270 raise Exception("Anonymous action in target %s. "
2298 "An action must have an 'action_name' field." % 2271 "An action must have an 'action_name' field." %
2299 target_name) 2272 target_name)
2300 inputs = action.get('inputs', []) 2273 inputs = action.get('inputs', [])
2301 action_command = action.get('action') 2274 action_command = action.get('action')
2302 if action_command and not action_command[0]: 2275 if action_command and not action_command[0]:
2303 raise Exception("Empty action as command in target %s." % target_name) 2276 raise Exception("Empty action as command in target %s." % target_name)
2304 2277
2305 2278
2306 def ValidateActionsInTarget(target, target_dict, build_file):
2307 '''Validates the inputs to the actions in a target.'''
2308 target_name = target_dict.get('target_name')
2309 actions = target_dict.get('actions', [])
2310 for action in actions:
2311 action_name = action.get('action_name')
2312 if not action_name:
2313 raise Exception("Anonymous action in target %s. "
2314 "An action must have an 'action_name' field." %
2315 target_name)
2316 inputs = action.get('inputs', [])
2317 action_command = action.get('action')
2318 if action_command and not action_command[0]:
2319 raise Exception("Empty action as command in target %s." % target_name)
2320
2321
2322 def TurnIntIntoStrInDict(the_dict): 2279 def TurnIntIntoStrInDict(the_dict):
2323 """Given dict the_dict, recursively converts all integers into strings. 2280 """Given dict the_dict, recursively converts all integers into strings.
2324 """ 2281 """
2325 # Use items instead of iteritems because there's no need to try to look at 2282 # Use items instead of iteritems because there's no need to try to look at
2326 # reinserted keys and their associated values. 2283 # reinserted keys and their associated values.
2327 for k, v in the_dict.items(): 2284 for k, v in the_dict.items():
2328 if isinstance(v, int): 2285 if isinstance(v, int):
2329 v = str(v) 2286 v = str(v)
2330 the_dict[k] = v 2287 the_dict[k] = v
2331 elif isinstance(v, dict): 2288 elif isinstance(v, dict):
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 ValidateRunAsInTarget(target, target_dict, build_file) 2479 ValidateRunAsInTarget(target, target_dict, build_file)
2523 ValidateActionsInTarget(target, target_dict, build_file) 2480 ValidateActionsInTarget(target, target_dict, build_file)
2524 2481
2525 # Generators might not expect ints. Turn them into strs. 2482 # Generators might not expect ints. Turn them into strs.
2526 TurnIntIntoStrInDict(data) 2483 TurnIntIntoStrInDict(data)
2527 2484
2528 # TODO(mark): Return |data| for now because the generator needs a list of 2485 # TODO(mark): Return |data| for now because the generator needs a list of
2529 # build files that came in. In the future, maybe it should just accept 2486 # build files that came in. In the future, maybe it should just accept
2530 # a list, and not the whole data dict. 2487 # a list, and not the whole data dict.
2531 return [flat_list, targets, data] 2488 return [flat_list, targets, data]
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