Chromium Code Reviews| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 def _NormalizeTargetOSName(target_os): | 158 def _NormalizeTargetOSName(target_os): |
| 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 # TODO(wrengr): why not just pass the deps_loader to a method on | |
| 169 # root_dep which returns the deps_content? What's the point in threading | |
|
stgao
2016/09/21 23:03:25
We want root_dep class to be a plain object, and n
wrengr
2016/09/28 00:59:49
Why do we want root_dep to not do http stuff? Even
| |
| 170 # things through like this? | |
| 168 deps_content = deps_loader.Load( | 171 deps_content = deps_loader.Load( |
| 169 root_dep.deps_repo_url, root_dep.deps_repo_revision, root_dep.deps_file) | 172 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')) | 173 deps, deps_os = ParseDEPSContent(deps_content, keys=('deps', 'deps_os')) |
| 171 | 174 |
| 172 all_deps = MergeWithOsDeps(deps, deps_os, target_os_list) | 175 all_deps = MergeWithOsDeps(deps, deps_os, target_os_list) |
| 173 | 176 |
| 177 # TODO(wrengr): why close over root_dep to get at deps_file, but then | |
| 178 # force callsers to patch things up after the fact with SetParent? Why | |
| 179 # not just call SetParent ourselves? | |
|
stgao
2016/09/21 23:03:25
It's good to move that over here. Let's make the c
| |
| 174 def _CreateDependency(path, repo_info): | 180 def _CreateDependency(path, repo_info): |
| 175 if not path.endswith('/'): | 181 if not path.endswith('/'): |
| 176 path = path + '/' | 182 path = path + '/' |
| 177 | 183 |
| 178 repo_url = repo_info | 184 repo_url = repo_info |
| 179 revision = None | 185 revision = None |
| 180 if '@' in repo_info: | 186 if '@' in repo_info: |
| 181 # The dependency is pinned to some revision. | 187 # The dependency is pinned to some revision. |
| 182 repo_url, revision = repo_info.split('@') | 188 repo_url, revision = repo_info.split('@') |
| 183 | 189 |
| 184 return dependency.Dependency( | 190 return dependency.Dependency( |
| 185 path, repo_url, revision, root_dep.deps_file) | 191 path, repo_url, revision, root_dep.deps_file) |
| 186 | 192 |
| 187 for path, repo_info in all_deps.iteritems(): | 193 for path, repo_info in all_deps.iteritems(): |
| 188 if repo_info is None: | 194 if repo_info is None: |
| 189 # The dependency is not needed for all the target os. | 195 # The dependency is not needed for all the target os. |
| 190 continue | 196 continue |
| 191 | 197 |
| 198 # TODO(wrengr): why are we doing this? i.e., it looks like we're | |
| 199 # allocating a dependency.Dependency object and then just dropping it | |
| 200 # on the floor. To what end? | |
|
stgao
2016/09/21 23:03:24
You meant chromium_deps.py turns the result back t
| |
| 192 sub_dep = _CreateDependency(path, repo_info) | 201 sub_dep = _CreateDependency(path, repo_info) |
| 193 sub_dep.SetParent(root_dep) | 202 sub_dep.SetParent(root_dep) |
| 194 | 203 |
| 195 # TODO: go into the next level of dependency if needed. | 204 # TODO: go into the next level of dependency if needed. |
| OLD | NEW |