blob: 8358dfe7e599908b2e5a25567ef0b46fc243ac2f [file] [log] [blame]
Ned Nguyen9a7a9052019-02-05 11:04:03 -07001# -*- 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
8This service handles the creation of the portage build dependency graphs and the
9graphs mapping from portage packages to the dependency source.
10"""
11
12from __future__ import print_function
13
14import json
15
16from chromite.lib.api import dependency
17
18
19def 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