1# Copyright 2020 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5
6# Set root for generated files.
7lucicfg.config(
8    config_dir = "metadata/generated",
9)
10
11# Load and register protos.
12load("@stdlib//internal/descpb.star", "wellknown_descpb")
13protos = proto.new_descriptor_set(
14    name = "chromiumos",
15    blob = io.read_file("//metadata/proto/descpb.bin"),
16    deps = [wellknown_descpb],
17)
18protos.register()
19
20
21load('@proto//chromiumos/config/api/test/metadata/v1/metadata.proto',
22    metadata_pb = 'chromiumos.config.api.test.metadata.v1'
23)
24load('//metadata/tests.star', 'define_tests')
25
26
27def _specification():
28    return metadata_pb.Specification(
29        remote_test_drivers = [metadata_pb.RemoteTestDriver(
30            name = 'remoteTestDrivers/tauto',
31            tests = define_tests(),
32        )]
33    )
34
35
36# Generate metadata proto output.
37def _generate(config):
38    """
39    Serializes a proto message to files.
40
41    A text proto and binary proto are written.
42    """
43    def _generate_impl(ctx):
44        ctx.output["config.cfg"] = proto.to_jsonpb(config)
45        ctx.output["config.binaryproto"] = proto.to_wirepb(config)
46    lucicfg.generator(impl = _generate_impl)
47
48
49def generate():
50    _generate(_specification())
51