Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 import copy | 5 import copy |
| 6 import ntpath | 6 import ntpath |
| 7 import os | 7 import os |
| 8 import posixpath | 8 import posixpath |
| 9 import re | 9 import re |
| 10 import subprocess | 10 import subprocess |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 domain_match = domain_re.search(config) | 127 domain_match = domain_re.search(config) |
| 128 if domain_match: | 128 if domain_match: |
| 129 domain = domain_match.group(1) | 129 domain = domain_match.group(1) |
| 130 cached_domain = domain | 130 cached_domain = domain |
| 131 cached_username = username | 131 cached_username = username |
| 132 return (cached_domain, cached_username) | 132 return (cached_domain, cached_username) |
| 133 | 133 |
| 134 fixpath_prefix = None | 134 fixpath_prefix = None |
| 135 | 135 |
| 136 | 136 |
| 137 def _NormalizedSource(source): | 137 def _NormalizedSource(source, curdir = None): |
|
scottmg
2015/06/15 18:46:52
here too
| |
| 138 """Normalize the path. | 138 """Normalize the path. |
| 139 | 139 |
| 140 But not if that gets rid of a variable, as this may expand to something | 140 But not if that gets rid of a variable, as this may expand to something |
| 141 larger than one directory. | 141 larger than one directory. |
| 142 | 142 |
| 143 Arguments: | 143 Arguments: |
| 144 source: The path to be normalize.d | 144 source: The path to be normalized |
| 145 curdir: Current direcory to normalize against (optional) | |
| 145 | 146 |
| 146 Returns: | 147 Returns: |
| 147 The normalized path. | 148 The normalized path. |
| 148 """ | 149 """ |
| 149 normalized = os.path.normpath(source) | 150 normalized = os.path.normpath(source) |
| 151 if curdir: | |
| 152 normalized = os.path.normpath(os.path.join(curdir, normalized)) | |
| 153 normalized = os.path.relpath(normalized, curdir) | |
| 150 if source.count('$') == normalized.count('$'): | 154 if source.count('$') == normalized.count('$'): |
| 151 source = normalized | 155 source = normalized |
| 152 return source | 156 return source |
| 153 | 157 |
| 154 | 158 |
| 155 def _FixPath(path): | 159 def _FixPath(path, curdir = None): |
| 156 """Convert paths to a form that will make sense in a vcproj file. | 160 """Convert paths to a form that will make sense in a vcproj file. |
| 157 | 161 |
| 158 Arguments: | 162 Arguments: |
| 159 path: The path to convert, may contain / etc. | 163 path: The path to convert, may contain / etc. |
| 164 curdir: Current directory of path (optional) | |
| 160 Returns: | 165 Returns: |
| 161 The path with all slashes made into backslashes. | 166 The path with all slashes made into backslashes. |
| 162 """ | 167 """ |
| 163 if fixpath_prefix and path and not os.path.isabs(path) and not path[0] == '$': | 168 if fixpath_prefix and path and not os.path.isabs(path) and not path[0] == '$': |
| 164 path = os.path.join(fixpath_prefix, path) | 169 path = os.path.join(fixpath_prefix, path) |
| 165 path = path.replace('/', '\\') | 170 path = path.replace('/', '\\') |
| 166 path = _NormalizedSource(path) | 171 path = _NormalizedSource(path, curdir) |
| 167 if path and path[-1] == '\\': | 172 if path and path[-1] == '\\': |
| 168 path = path[:-1] | 173 path = path[:-1] |
| 169 return path | 174 return path |
| 170 | 175 |
| 171 | 176 |
| 172 def _FixPaths(paths): | 177 def _FixPaths(paths, curdir = None): |
|
scottmg
2015/06/15 18:46:52
nit; No spaces around = for default args.
| |
| 173 """Fix each of the paths of the list.""" | 178 """Fix each of the paths of the list.""" |
| 174 return [_FixPath(i) for i in paths] | 179 return [_FixPath(i, curdir) for i in paths] |
| 175 | 180 |
| 176 | 181 |
| 177 def _ConvertSourcesToFilterHierarchy(sources, prefix=None, excluded=None, | 182 def _ConvertSourcesToFilterHierarchy(sources, prefix=None, excluded=None, |
| 178 list_excluded=True, msvs_version=None): | 183 list_excluded=True, msvs_version=None): |
| 179 """Converts a list split source file paths into a vcproj folder hierarchy. | 184 """Converts a list split source file paths into a vcproj folder hierarchy. |
| 180 | 185 |
| 181 Arguments: | 186 Arguments: |
| 182 sources: A list of source file paths split. | 187 sources: A list of source file paths split. |
| 183 prefix: A list of source file path layers meant to apply to each of sources. | 188 prefix: A list of source file path layers meant to apply to each of sources. |
| 184 excluded: A set of excluded files. | 189 excluded: A set of excluded files. |
| (...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1472 A trio of (list of sources, list of excluded sources, | 1477 A trio of (list of sources, list of excluded sources, |
| 1473 path of excluded IDL file) | 1478 path of excluded IDL file) |
| 1474 """ | 1479 """ |
| 1475 # Exclude excluded sources coming into the generator. | 1480 # Exclude excluded sources coming into the generator. |
| 1476 excluded_sources.update(OrderedSet(spec.get('sources_excluded', []))) | 1481 excluded_sources.update(OrderedSet(spec.get('sources_excluded', []))) |
| 1477 # Add excluded sources into sources for good measure. | 1482 # Add excluded sources into sources for good measure. |
| 1478 sources.update(excluded_sources) | 1483 sources.update(excluded_sources) |
| 1479 # Convert to proper windows form. | 1484 # Convert to proper windows form. |
| 1480 # NOTE: sources goes from being a set to a list here. | 1485 # NOTE: sources goes from being a set to a list here. |
| 1481 # NOTE: excluded_sources goes from being a set to a list here. | 1486 # NOTE: excluded_sources goes from being a set to a list here. |
| 1482 sources = _FixPaths(sources) | 1487 sources = _FixPaths(sources, _FixPath(gyp_dir)) |
| 1483 # Convert to proper windows form. | 1488 # Convert to proper windows form. |
| 1484 excluded_sources = _FixPaths(excluded_sources) | 1489 excluded_sources = _FixPaths(excluded_sources) |
| 1485 | 1490 |
| 1486 excluded_idl = _IdlFilesHandledNonNatively(spec, sources) | 1491 excluded_idl = _IdlFilesHandledNonNatively(spec, sources) |
| 1487 | 1492 |
| 1488 precompiled_related = _GetPrecompileRelatedFiles(spec) | 1493 precompiled_related = _GetPrecompileRelatedFiles(spec) |
| 1489 # Find the excluded ones, minus the precompiled header related ones. | 1494 # Find the excluded ones, minus the precompiled header related ones. |
| 1490 fully_excluded = [i for i in excluded_sources if i not in precompiled_related] | 1495 fully_excluded = [i for i in excluded_sources if i not in precompiled_related] |
| 1491 | 1496 |
| 1492 # Convert to folders and the right slashes. | 1497 # Convert to folders and the right slashes. |
| (...skipping 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3428 action_spec.extend( | 3433 action_spec.extend( |
| 3429 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3434 # TODO(jeanluc) 'Document' for all or just if as_sources? |
| 3430 [['FileType', 'Document'], | 3435 [['FileType', 'Document'], |
| 3431 ['Command', command], | 3436 ['Command', command], |
| 3432 ['Message', description], | 3437 ['Message', description], |
| 3433 ['Outputs', outputs] | 3438 ['Outputs', outputs] |
| 3434 ]) | 3439 ]) |
| 3435 if additional_inputs: | 3440 if additional_inputs: |
| 3436 action_spec.append(['AdditionalInputs', additional_inputs]) | 3441 action_spec.append(['AdditionalInputs', additional_inputs]) |
| 3437 actions_spec.append(action_spec) | 3442 actions_spec.append(action_spec) |
| OLD | NEW |