Ned Nguyen | 9a7a905 | 2019-02-05 11:04:03 -0700 | [diff] [blame^] | 1 | # -*- coding: utf-8 -*- |
| 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | """Build graph dependency creation service. |
| 7 | |
| 8 | This service handles the creation of the portage build dependency graphs and the |
| 9 | graphs mapping from portage packages to the dependency source. |
| 10 | """ |
| 11 | |
| 12 | from __future__ import print_function |
| 13 | |
| 14 | import json |
| 15 | |
| 16 | from chromite.lib.api import dependency |
| 17 | |
| 18 | |
| 19 | def GetBuildDependencyGraph(input_proto, output_proto): |
| 20 | """Create the build dependency graph. |
| 21 | |
| 22 | Args: |
| 23 | input_proto (GetBuildDependencyGraphRequest): The input arguments message. |
| 24 | output_proto (GetBuildDependencyGraphResponse): The empty output message. |
| 25 | """ |
| 26 | board = input_proto.build_target.name |
| 27 | output_path = input_proto.output_path |
| 28 | |
| 29 | assert board, 'Missing build target name' |
| 30 | assert output_path, 'Missing output file' |
| 31 | |
| 32 | json_map = dependency.GetBuildDependency(board) |
| 33 | with open(output_path, 'w') as f: |
| 34 | json.dump(json_map, f, indent=2, sort_keys=True) |
| 35 | |
| 36 | output_proto.build_dependency_graph_file = output_path |