chromite/api: add the full depgraph to depgraph's response message directly
BUG=chromium:957707
TEST=run `./bin/build_api chromite.api.DependencyService/GetBuildDependencyGraph --input-json=input.json --output-json=output.json` and verifies output.json file contains the depgraph data directly.
Change-Id: I245e7481c6f47dd5be316661d7bca804628145ef
Reviewed-on: https://chromium-review.googlesource.com/1592843
Commit-Ready: Ned Nguyen <nednguyen@google.com>
Tested-by: Ned Nguyen <nednguyen@google.com>
Reviewed-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Sean Abraham <seanabraham@chromium.org>
diff --git a/api/controller/board_build_dependency.py b/api/controller/board_build_dependency.py
index ea2e123..3317d54 100644
--- a/api/controller/board_build_dependency.py
+++ b/api/controller/board_build_dependency.py
@@ -11,21 +11,21 @@
from __future__ import print_function
-from chromite.api.gen.chromite.api import depgraph_pb2
from chromite.lib import portage_util
from chromite.service import dependency
from google.protobuf import json_format
-def CreateDepGraphProtoFromJsonMap(json_map):
- """Return the depgraph proto message from package deps json map.
+def AugmentDepGraphProtoFromJsonMap(json_map, graph):
+ """Augment package deps from |json_map| to graph object.
Args:
json_map: the json object that stores the portage package. This is
generated from chromite.lib.service.dependency.GetBuildDependency()
+ graph: the proto object that represents the dependency graph (see DepGraph
+ message in chromite/api/depgraph.proto)
"""
- graph = depgraph_pb2.DepGraph()
graph.build_target.name = json_map['target_board']
for data in json_map['package_deps'].itervalues():
@@ -48,8 +48,6 @@
source_path = package_dep_info.dependency_source_paths.add()
source_path.path = path
- return graph
-
def GetBuildDependencyGraph(input_proto, output_proto):
"""Create the build dependency graph.
@@ -65,10 +63,11 @@
json_map = dependency.GetBuildDependency(board)
- graph = CreateDepGraphProtoFromJsonMap(json_map)
+ AugmentDepGraphProtoFromJsonMap(json_map, output_proto.dep_graph)
with open(output_path, 'w') as f:
f.write(
- json_format.MessageToJson(graph, including_default_value_fields=True))
+ json_format.MessageToJson(output_proto.dep_graph,
+ including_default_value_fields=True))
output_proto.build_dependency_graph_file = output_path