| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. 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 """ This is an incomplete implementation of a DEPS file parser. | 5 """ This is an incomplete implementation of a DEPS file parser. |
| 6 | 6 |
| 7 Now only keys 'vars', 'deps', and 'deps_os' are taken care of. | 7 Now only keys 'vars', 'deps', and 'deps_os' are taken care of. |
| 8 | 8 |
| 9 TODO: support strict mode, 'target_os', 'target_os_only', 'use_relative_paths', | 9 TODO: support strict mode, 'target_os', 'target_os_only', 'use_relative_paths', |
| 10 both forms of recursion, both forms of hooks, 'allowed_hosts', etc. | 10 both forms of recursion, both forms of hooks, 'allowed_hosts', etc. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 os_name = target_os.lower() | 159 os_name = target_os.lower() |
| 160 assert os_name in DEPS_OS_CHOICES, 'Target OS "%s" is invalid' % os_name | 160 assert os_name in DEPS_OS_CHOICES, 'Target OS "%s" is invalid' % os_name |
| 161 return os_name | 161 return os_name |
| 162 | 162 |
| 163 if 'all' in target_os_list: | 163 if 'all' in target_os_list: |
| 164 target_os_list = DEPS_OS_CHOICES | 164 target_os_list = DEPS_OS_CHOICES |
| 165 else: | 165 else: |
| 166 target_os_list = [_NormalizeTargetOSName(name) for name in target_os_list] | 166 target_os_list = [_NormalizeTargetOSName(name) for name in target_os_list] |
| 167 | 167 |
| 168 deps_content = deps_loader.Load( | 168 deps_content = deps_loader.Load( |
| 169 root_dep.repo_url, root_dep.revision, root_dep.deps_file) | 169 root_dep.deps_repo_url, root_dep.deps_repo_revision, root_dep.deps_file) |
| 170 deps, deps_os = ParseDEPSContent(deps_content, keys=('deps', 'deps_os')) | 170 deps, deps_os = ParseDEPSContent(deps_content, keys=('deps', 'deps_os')) |
| 171 | 171 |
| 172 all_deps = MergeWithOsDeps(deps, deps_os, target_os_list) | 172 all_deps = MergeWithOsDeps(deps, deps_os, target_os_list) |
| 173 | 173 |
| 174 def _CreateDependency(path, repo_info): | 174 def _CreateDependency(path, repo_info): |
| 175 if not path.endswith('/'): | 175 if not path.endswith('/'): |
| 176 path = path + '/' | 176 path = path + '/' |
| 177 | 177 |
| 178 repo_url = repo_info | 178 repo_url = repo_info |
| 179 revision = None | 179 revision = None |
| 180 if '@' in repo_info: | 180 if '@' in repo_info: |
| 181 # The dependency is pinned to some revision. | 181 # The dependency is pinned to some revision. |
| 182 repo_url, revision = repo_info.split('@') | 182 repo_url, revision = repo_info.split('@') |
| 183 | 183 |
| 184 return dependency.Dependency( | 184 return dependency.Dependency( |
| 185 path, repo_url, revision, root_dep.deps_file) | 185 path, repo_url, revision, root_dep.deps_file) |
| 186 | 186 |
| 187 for path, repo_info in all_deps.iteritems(): | 187 for path, repo_info in all_deps.iteritems(): |
| 188 if repo_info is None: | 188 if repo_info is None: |
| 189 # The dependency is not needed for all the target os. | 189 # The dependency is not needed for all the target os. |
| 190 continue | 190 continue |
| 191 | 191 |
| 192 sub_dep = _CreateDependency(path, repo_info) | 192 sub_dep = _CreateDependency(path, repo_info) |
| 193 sub_dep.SetParent(root_dep) | 193 sub_dep.SetParent(root_dep) |
| 194 | 194 |
| 195 # TODO: go into the next level of dependency if needed. | 195 # TODO: go into the next level of dependency if needed. |
| OLD | NEW |