Ivan Chong | a1d2361 | 2024-08-15 18:32:57 +0000 | [diff] [blame] | 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 | |
| 16 | import subprocess |
| 17 | import os |
| 18 | """ |
| 19 | Compile the gRPC python code for Clickhouse for Bigtrace |
| 20 | and modify the include paths to point to the correct file paths |
| 21 | |
| 22 | """ |
| 23 | |
| 24 | |
| 25 | def main(): |
| 26 | subprocess.run([ |
Ivan Chong | 4dd52d5 | 2024-09-10 09:41:54 +0000 | [diff] [blame] | 27 | "python3", |
Ivan Chong | a1d2361 | 2024-08-15 18:32:57 +0000 | [diff] [blame] | 28 | "-m", |
| 29 | "grpc_tools.protoc", |
| 30 | "-I.", |
| 31 | "--python_out=python/perfetto/bigtrace_clickhouse", |
| 32 | "--pyi_out=python/perfetto/bigtrace_clickhouse", |
| 33 | "protos/perfetto/bigtrace/orchestrator.proto", |
| 34 | "protos/perfetto/trace_processor/trace_processor.proto", |
| 35 | "protos/perfetto/common/descriptor.proto", |
| 36 | "protos/perfetto/trace_processor/metatrace_categories.proto", |
| 37 | ]) |
| 38 | subprocess.run([ |
Ivan Chong | 4dd52d5 | 2024-09-10 09:41:54 +0000 | [diff] [blame] | 39 | "python3", |
Ivan Chong | a1d2361 | 2024-08-15 18:32:57 +0000 | [diff] [blame] | 40 | "-m", |
| 41 | "grpc_tools.protoc", |
| 42 | "-I.", |
| 43 | "--python_out=python/perfetto/bigtrace_clickhouse", |
| 44 | "--pyi_out=python/perfetto/bigtrace_clickhouse", |
| 45 | "--grpc_python_out=python/perfetto/bigtrace_clickhouse", |
| 46 | "protos/perfetto/bigtrace/orchestrator.proto", |
| 47 | ]) |
| 48 | subprocess.run([ |
| 49 | "sed", |
| 50 | "-i", |
| 51 | "-e", |
| 52 | "s/protos\.perfetto/\./", |
| 53 | "python/perfetto/bigtrace_clickhouse/protos/perfetto/bigtrace/orchestrator_pb2_grpc.py", |
| 54 | "python/perfetto/bigtrace_clickhouse/protos/perfetto/bigtrace/orchestrator_pb2.py", |
| 55 | "python/perfetto/bigtrace_clickhouse/protos/perfetto/bigtrace/orchestrator_pb2.pyi", |
| 56 | "python/perfetto/bigtrace_clickhouse/protos/perfetto/trace_processor/trace_processor_pb2.py", |
| 57 | "python/perfetto/bigtrace_clickhouse/protos/perfetto/trace_processor/trace_processor_pb2.pyi", |
| 58 | ]) |
| 59 | return 0 |
| 60 | |
| 61 | |
| 62 | if __name__ == "__main__": |
| 63 | main() |