xref: /aosp_15_r20/external/perfetto/tools/gen_bigtrace_grpc_protos.py (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1#!/usr/bin/env python3
2# Copyright (C) 2024 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import subprocess
17"""
18Compile the gRPC python code for Bigtrace
19and modify the include paths to point to the correct file paths
20
21"""
22
23
24def main():
25  subprocess.run([
26      "python",
27      "-m",
28      "grpc_tools.protoc",
29      "-I.",
30      "--python_out=python/perfetto/bigtrace",
31      "--pyi_out=python/perfetto/bigtrace",
32      "protos/perfetto/bigtrace/orchestrator.proto",
33      "protos/perfetto/trace_processor/trace_processor.proto",
34      "protos/perfetto/common/descriptor.proto",
35      "protos/perfetto/trace_processor/metatrace_categories.proto",
36  ])
37  subprocess.run([
38      "python",
39      "-m",
40      "grpc_tools.protoc",
41      "-I.",
42      "--python_out=python/perfetto/bigtrace",
43      "--pyi_out=python/perfetto/bigtrace",
44      "--grpc_python_out=python/perfetto/bigtrace",
45      "protos/perfetto/bigtrace/orchestrator.proto",
46  ])
47  subprocess.run([
48      "sed",
49      "-i",
50      "-e",
51      "s/protos\.perfetto/perfetto\.bigtrace\.protos\.perfetto/",
52      "python/perfetto/bigtrace/protos/perfetto/bigtrace/orchestrator_pb2_grpc.py",
53      "python/perfetto/bigtrace/protos/perfetto/bigtrace/orchestrator_pb2.py",
54      "python/perfetto/bigtrace/protos/perfetto/bigtrace/orchestrator_pb2.pyi",
55      "python/perfetto/bigtrace/protos/perfetto/trace_processor/trace_processor_pb2.py",
56      "python/perfetto/bigtrace/protos/perfetto/trace_processor/trace_processor_pb2.pyi",
57  ])
58  return 0
59
60
61if __name__ == "__main__":
62  main()
63