1package {
2    // See: http://go/android-license-faq
3    // A large-scale-change added 'default_applicable_licenses' to import
4    // all of the 'license_kinds' from "tools_netsim_license"
5    // to get the below license kinds:
6    //   SPDX-license-identifier-Apache-2.0
7    default_applicable_licenses: ["tools_netsim_license"],
8}
9
10filegroup {
11    name: "netsim-protos",
12    srcs: [
13        "netsim/common.proto",
14        "netsim/frontend.proto",
15        "netsim/hci_packet.proto",
16        "netsim/model.proto",
17        "netsim/packet_streamer.proto",
18        "netsim/startup.proto",
19        "netsim/stats.proto",
20    ],
21}
22
23genrule_defaults {
24    name: "netsim-grpc-gen-defaults",
25    tools: [
26        "aprotoc",
27        "protoc-gen-grpc-cpp-plugin",
28    ],
29    cmd: "$(location aprotoc)" +
30        "    -Itools/netsim/proto" +
31        "    -Iexternal/protobuf/src" +
32        "    -Ipackages/modules/Bluetooth/tools/rootcanal/proto" +
33        "    --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin)" +
34        "    --grpc_out=$(genDir)" +
35        "    --cpp_out=$(genDir)" +
36        "    $(locations :netsim-protos)",
37    srcs: [
38        ":libprotobuf-internal-protos",
39        ":netsim-protos",
40        ":rootcanal-protos",
41    ],
42}
43
44genrule {
45    name: "FrontendStub_h",
46    defaults: ["netsim-grpc-gen-defaults"],
47    out: ["netsim/frontend.grpc.pb.h"],
48}
49
50genrule {
51    name: "FrontendStub_cc",
52    defaults: ["netsim-grpc-gen-defaults"],
53    out: ["netsim/frontend.grpc.pb.cc"],
54}
55
56genrule {
57    name: "PacketStreamerStub_h",
58    defaults: ["netsim-grpc-gen-defaults"],
59    out: ["netsim/packet_streamer.grpc.pb.h"],
60}
61
62genrule {
63    name: "PacketStreamerStub_cc",
64    defaults: ["netsim-grpc-gen-defaults"],
65    out: ["netsim/packet_streamer.grpc.pb.cc"],
66}
67
68cc_library {
69    name: "lib-netsim-frontend-proto",
70    host_supported: true,
71    proto: {
72        export_proto_headers: true,
73        type: "full",
74        canonical_path_from_root: false,
75        include_dirs: [
76            "external/protobuf/src",
77            "tools/netsim/proto",
78            "packages/modules/Bluetooth/tools/rootcanal/proto",
79        ],
80    },
81    shared_libs: [
82        "libprotobuf-cpp-full",
83    ],
84    srcs: [
85        "netsim/common.proto",
86        "netsim/config.proto",
87        "netsim/frontend.proto",
88        "netsim/hci_packet.proto",
89        "netsim/model.proto",
90        "netsim/startup.proto",
91        ":rootcanal-protos",
92    ],
93}
94
95cc_library {
96    name: "lib-netsimd-proto",
97    host_supported: true,
98    proto: {
99        export_proto_headers: true,
100        type: "full",
101        canonical_path_from_root: false,
102        include_dirs: [
103            "external/protobuf/src",
104            "tools/netsim/proto",
105            "packages/modules/Bluetooth/tools/rootcanal/proto",
106        ],
107    },
108    srcs: [
109        "netsim/common.proto",
110        "netsim/config.proto",
111        "netsim/frontend.proto",
112        "netsim/hci_packet.proto",
113        "netsim/model.proto",
114        "netsim/packet_streamer.proto",
115        "netsim/startup.proto",
116        "netsim/stats.proto",
117        ":rootcanal-protos",
118    ],
119}
120
121genrule {
122    name: "netsim-python-src",
123    tools: [
124        "aprotoc",
125        "protoc-gen-grpc-python-plugin",
126    ],
127    cmd: "$(location aprotoc)" +
128        "    -Itools/netsim/proto" +
129        "    -Ipackages/modules/Bluetooth/tools/rootcanal/proto" +
130        "    -Iexternal/protobuf/src" +
131        "    --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin)" +
132        "    --python_out=$(genDir)" +
133        "    --grpc_out=$(genDir)" +
134        "    $(locations :netsim-protos)" +
135        "    $(locations :rootcanal-protos) &&" +
136        "touch $(genDir)/netsim/__init__.py",
137    srcs: [
138        ":libprotobuf-internal-protos",
139        ":netsim-protos",
140        ":rootcanal-protos",
141    ],
142    out: [
143        "netsim/__init__.py",
144        "netsim/common_pb2.py",
145        "netsim/common_pb2_grpc.py",
146        "netsim/frontend_pb2.py",
147        "netsim/frontend_pb2_grpc.py",
148        "netsim/hci_packet_pb2.py",
149        "netsim/hci_packet_pb2_grpc.py",
150        "netsim/model_pb2.py",
151        "netsim/model_pb2_grpc.py",
152        "netsim/startup_pb2.py",
153        "netsim/startup_pb2_grpc.py",
154        "rootcanal/configuration_pb2.py",
155    ],
156    visibility: [
157        "//packages/modules/Bluetooth/android/pandora/mmi2grpc",
158    ],
159}
160