summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@78cadc50-ecff-11dd-a971-7dbc132099af>2014-08-06 20:47:13 +0000
committersky@chromium.org <sky@chromium.org@78cadc50-ecff-11dd-a971-7dbc132099af>2014-08-06 20:47:13 +0000
commit474e6f6c6772675e4aa0a076af5206021756d7d2 (patch)
tree127d655b3bb893e65520378731becc77d52eee04
parent93303ec2a58c910b7b2f26230002e8c736115844 (diff)
downloadgyp-474e6f6c6772675e4aa0a076af5206021756d7d2.tar.gz
Style changes for analyzer
__ -> _ and lots of single newlines to double newlines. BUG=none R=scottmg@chromium.org Review URL: https://codereview.chromium.org/445113002 git-svn-id: http://gyp.googlecode.com/svn/trunk@1963 78cadc50-ecff-11dd-a971-7dbc132099af
-rw-r--r--pylib/gyp/generator/analyzer.py60
1 files changed, 34 insertions, 26 deletions
diff --git a/pylib/gyp/generator/analyzer.py b/pylib/gyp/generator/analyzer.py
index 2648e7d5..8a8ac70c 100644
--- a/pylib/gyp/generator/analyzer.py
+++ b/pylib/gyp/generator/analyzer.py
@@ -64,22 +64,17 @@ for unused in ['RULE_INPUT_PATH', 'RULE_INPUT_ROOT', 'RULE_INPUT_NAME',
'CONFIGURATION_NAME']:
generator_default_variables[unused] = ''
+
def _ToGypPath(path):
"""Converts a path to the format used by gyp."""
if os.sep == '\\' and os.altsep == '/':
return path.replace('\\', '/')
return path
-def __ExtractBasePath(target):
- """Extracts the path components of the specified gyp target path."""
- last_index = target.rfind('/')
- if last_index == -1:
- return ''
- return target[0:(last_index + 1)]
-def __ResolveParent(path, base_path_components):
+def _ResolveParent(path, base_path_components):
"""Resolves |path|, which starts with at least one '../'. Returns an empty
- string if the path shouldn't be considered. See __AddSources() for a
+ string if the path shouldn't be considered. See _AddSources() for a
description of |base_path_components|."""
depth = 0
while path.startswith('../'):
@@ -94,7 +89,8 @@ def __ResolveParent(path, base_path_components):
return '/'.join(base_path_components[0:len(base_path_components) - depth]) + \
'/' + path
-def __AddSources(sources, base_path, base_path_components, result):
+
+def _AddSources(sources, base_path, base_path_components, result):
"""Extracts valid sources from |sources| and adds them to |result|. Each
source file is relative to |base_path|, but may contain '..'. To make
resolving '..' easier |base_path_components| contains each of the
@@ -109,7 +105,7 @@ def __AddSources(sources, base_path, base_path_components, result):
org_source = source
source = source[0] + source[1:].replace('//', '/')
if source.startswith('../'):
- source = __ResolveParent(source, base_path_components)
+ source = _ResolveParent(source, base_path_components)
if len(source):
result.append(source)
continue
@@ -117,12 +113,14 @@ def __AddSources(sources, base_path, base_path_components, result):
if debug:
print 'AddSource', org_source, result[len(result) - 1]
-def __ExtractSourcesFromAction(action, base_path, base_path_components,
- results):
+
+def _ExtractSourcesFromAction(action, base_path, base_path_components,
+ results):
if 'inputs' in action:
- __AddSources(action['inputs'], base_path, base_path_components, results)
+ _AddSources(action['inputs'], base_path, base_path_components, results)
-def __ExtractSources(target, target_dict, toplevel_dir):
+
+def _ExtractSources(target, target_dict, toplevel_dir):
# |target| is either absolute or relative and in the format of the OS. Gyp
# source paths are always posix. Convert |target| to a posix path relative to
# |toplevel_dir_|. This is done to make it easy to build source paths.
@@ -134,7 +132,7 @@ def __ExtractSources(target, target_dict, toplevel_dir):
base_path = posixpath.dirname(base_path)
base_path_components = base_path.split('/')
- # Add a trailing '/' so that __AddSources() can easily build paths.
+ # Add a trailing '/' so that _AddSources() can easily build paths.
if len(base_path):
base_path += '/'
@@ -143,20 +141,21 @@ def __ExtractSources(target, target_dict, toplevel_dir):
results = []
if 'sources' in target_dict:
- __AddSources(target_dict['sources'], base_path, base_path_components,
- results)
+ _AddSources(target_dict['sources'], base_path, base_path_components,
+ results)
# Include the inputs from any actions. Any changes to these effect the
# resulting output.
if 'actions' in target_dict:
for action in target_dict['actions']:
- __ExtractSourcesFromAction(action, base_path, base_path_components,
- results)
+ _ExtractSourcesFromAction(action, base_path, base_path_components,
+ results)
if 'rules' in target_dict:
for rule in target_dict['rules']:
- __ExtractSourcesFromAction(rule, base_path, base_path_components, results)
+ _ExtractSourcesFromAction(rule, base_path, base_path_components, results)
return results
+
class Target(object):
"""Holds information about a particular target:
deps: set of the names of direct dependent targets.
@@ -165,6 +164,7 @@ class Target(object):
self.deps = set()
self.match_status = MATCH_STATUS_TBD
+
class Config(object):
"""Details what we're looking for
look_for_dependency_only: if true only search for a target listing any of
@@ -219,6 +219,7 @@ class Config(object):
except IOError:
raise Exception('Unable to open file', file_path)
+
def _WasBuildFileModified(build_file, data, files):
"""Returns true if the build file |build_file| is either in |files| or
one of the files included by |build_file| is in |files|."""
@@ -242,7 +243,8 @@ def _WasBuildFileModified(build_file, data, files):
return True
return False
-def __GenerateTargets(data, target_list, target_dicts, toplevel_dir, files):
+
+def _GenerateTargets(data, target_list, target_dicts, toplevel_dir, files):
"""Generates a dictionary with the key the name of a target and the value a
Target. |toplevel_dir| is the root of the source tree. If the sources of
a target match that of |files|, then |target.matched| is set to True.
@@ -278,8 +280,8 @@ def __GenerateTargets(data, target_list, target_dicts, toplevel_dir, files):
target.match_status = MATCH_STATUS_MATCHES
matched = True
else:
- sources = __ExtractSources(target_name, target_dicts[target_name],
- toplevel_dir)
+ sources = _ExtractSources(target_name, target_dicts[target_name],
+ toplevel_dir)
for source in sources:
if source in files:
target.match_status = MATCH_STATUS_MATCHES
@@ -292,6 +294,7 @@ def __GenerateTargets(data, target_list, target_dicts, toplevel_dir, files):
return targets, matched
+
def _GetUnqualifiedToQualifiedMapping(all_targets, to_find):
"""Returns a mapping (dictionary) from unqualified name to qualified name for
all the targets in |to_find|."""
@@ -308,6 +311,7 @@ def _GetUnqualifiedToQualifiedMapping(all_targets, to_find):
return result
return result
+
def _DoesTargetDependOn(target, all_targets):
"""Returns true if |target| or any of its dependencies matches the supplied
set of paths. This updates |matches| of the Targets as it recurses.
@@ -327,6 +331,7 @@ def _DoesTargetDependOn(target, all_targets):
dep_target.match_status = MATCH_STATUS_DOESNT_MATCH
return False
+
def _GetTargetsDependingOn(all_targets, possible_targets):
"""Returns the list of targets in |possible_targets| that depend (either
directly on indirectly) on the matched files.
@@ -339,6 +344,7 @@ def _GetTargetsDependingOn(all_targets, possible_targets):
found.append(gyp.common.ParseQualifiedTarget(target)[1])
return found
+
def _WriteOutput(params, **values):
"""Writes the output, either to stdout or a file is specified."""
output_path = params.get('generator_flags', {}).get(
@@ -353,6 +359,7 @@ def _WriteOutput(params, **values):
except IOError as e:
print 'Error writing to output file', output_path, str(e)
+
def CalculateVariables(default_variables, params):
"""Calculate additional variables for use in the build (called by gyp)."""
flavor = gyp.common.GetFlavor(params)
@@ -375,6 +382,7 @@ def CalculateVariables(default_variables, params):
operating_system = 'linux' # Keep this legacy behavior for now.
default_variables.setdefault('OS', operating_system)
+
def GenerateOutput(target_list, target_dicts, data, params):
"""Called by gyp as the final stage. Outputs results."""
config = Config()
@@ -406,9 +414,9 @@ def GenerateOutput(target_list, target_dicts, data, params):
break
if not matched:
- all_targets, matched = __GenerateTargets(data, target_list, target_dicts,
- toplevel_dir,
- frozenset(config.files))
+ all_targets, matched = _GenerateTargets(data, target_list, target_dicts,
+ toplevel_dir,
+ frozenset(config.files))
# Set of targets that refer to one of the files.
if config.look_for_dependency_only: