1// Copyright (C) 2021 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15gensrcs {
16    name: "framework-javastream-protos",
17    depfile: true,
18
19    tools: [
20        "aprotoc",
21        "protoc-gen-javastream",
22        "soong_zip",
23    ],
24
25    cmd: "mkdir -p $(genDir)/$(in) " +
26        "&& $(location aprotoc) " +
27        "  --plugin=$(location protoc-gen-javastream) " +
28        "  --dependency_out=$(depfile) " +
29        "  --javastream_out=$(genDir)/$(in) " +
30        "  -Iexternal/protobuf/src " +
31        "  -I . " +
32        "  $(in) " +
33        "&& $(location soong_zip) -jar -o $(out) -C $(genDir)/$(in) -D $(genDir)/$(in)",
34
35    srcs: [
36        ":ipconnectivity-proto-src",
37        ":libstats_atom_enum_protos",
38        ":libstats_atom_message_protos",
39        ":libtombstone_proto-src",
40        "core/proto/**/*.proto",
41        "libs/incident/**/*.proto",
42        ":service-permission-protos",
43    ],
44    output_extension: "srcjar",
45}
46
47gensrcs {
48    name: "framework-cppstream-protos",
49    depfile: true,
50
51    tools: [
52        "aprotoc",
53        "protoc-gen-cppstream",
54    ],
55
56    cmd: "mkdir -p $(genDir) " +
57        "&& $(location aprotoc) " +
58        "  --plugin=$(location protoc-gen-cppstream) " +
59        "  --dependency_out=$(depfile) " +
60        "  --cppstream_out=$(genDir) " +
61        "  -Iexternal/protobuf/src " +
62        "  -I . " +
63        "  $(in)",
64
65    srcs: [
66        ":ipconnectivity-proto-src",
67        ":libstats_atom_enum_protos",
68        ":libstats_atom_message_protos",
69        "core/proto/**/*.proto",
70        "libs/incident/**/*.proto",
71        ":service-permission-protos",
72    ],
73
74    output_extension: "proto.h",
75}
76
77// ====  java proto host library  ==============================
78java_library_host {
79    name: "platformprotos",
80    srcs: [
81        ":ipconnectivity-proto-src",
82        ":libstats_atom_enum_protos",
83        ":libstats_atom_message_protos",
84        ":libstats_internal_protos",
85        ":statsd_internal_protos",
86        "cmds/am/proto/instrumentation_data.proto",
87        "cmds/statsd/src/**/*.proto",
88        "core/proto/**/*.proto",
89        "libs/incident/proto/**/*.proto",
90        ":service-permission-protos",
91    ],
92    proto: {
93        include_dirs: [
94            "external/protobuf/src",
95            "frameworks/proto_logging/stats",
96        ],
97        type: "full",
98    },
99    // Protos have lots of MissingOverride and similar.
100    errorprone: {
101        javacflags: ["-XepDisableAllChecks"],
102    },
103}
104
105// ====  java proto device library (for test only)  ==============================
106java_library {
107    name: "platformprotosnano",
108    proto: {
109        type: "nano",
110        output_params: ["store_unknown_fields=true"],
111        include_dirs: ["external/protobuf/src"],
112    },
113    exclude_srcs: [
114        "core/proto/android/privacy.proto",
115        "core/proto/android/section.proto",
116        "core/proto/android/typedef.proto",
117    ],
118    sdk_version: "9",
119    srcs: [
120        ":ipconnectivity-proto-src",
121        ":libstats_atom_enum_protos",
122        ":libstats_atom_message_protos",
123        "core/proto/**/*.proto",
124        "libs/incident/proto/android/os/**/*.proto",
125        ":service-permission-protos",
126    ],
127}
128
129// ====  java proto device library (for test only)  ==============================
130java_library {
131    name: "platformprotoslite",
132    proto: {
133        type: "lite",
134        include_dirs: ["external/protobuf/src"],
135    },
136
137    srcs: [
138        ":ipconnectivity-proto-src",
139        ":libstats_atom_enum_protos",
140        ":libstats_atom_message_protos",
141        "core/proto/**/*.proto",
142        "libs/incident/proto/android/os/**/*.proto",
143        ":service-permission-protos",
144    ],
145    exclude_srcs: [
146        "core/proto/android/privacy.proto",
147        "core/proto/android/section.proto",
148        "core/proto/android/typedef.proto",
149    ],
150    sdk_version: "core_current",
151    // Protos have lots of MissingOverride and similar.
152    errorprone: {
153        javacflags: ["-XepDisableAllChecks"],
154    },
155}
156
157// ====  c++ proto device library  ==============================
158cc_defaults {
159    name: "libplatformprotos-defaults",
160
161    proto: {
162        export_proto_headers: true,
163        include_dirs: [
164            "external/protobuf/src",
165        ],
166    },
167
168    cflags: [
169        "-Wall",
170        "-Werror",
171        "-Wno-unused-parameter",
172    ],
173
174    srcs: [
175        ":ipconnectivity-proto-src",
176        ":libstats_atom_enum_protos",
177        ":libstats_atom_message_protos",
178        "core/proto/**/*.proto",
179        ":service-permission-protos",
180    ],
181}
182
183cc_library {
184    name: "libplatformprotos",
185    defaults: ["libplatformprotos-defaults"],
186    host_supported: true,
187
188    target: {
189        host: {
190            proto: {
191                type: "full",
192            },
193        },
194        android: {
195            proto: {
196                type: "lite",
197            },
198            shared_libs: [
199                "libprotobuf-cpp-lite",
200            ],
201            shared: {
202                enabled: false,
203            },
204        },
205    },
206}
207
208// This library is meant for vendor code that needs to output protobuf. It links
209// against the static version of libprotobuf-cpp-lite, for which we can not guarantee
210// binary compatibility.
211cc_library {
212    name: "libplatformprotos-static",
213    defaults: ["libplatformprotos-defaults"],
214    host_supported: false,
215
216    // This is okay because this library is only built as a static library.  The C++
217    // API is not guaranteed. The proto API is guaranteed to be stable via Metrics Council,
218    // but is not authorized to be used outside of debugging.
219    vendor_available: true,
220
221    target: {
222        android: {
223            proto: {
224                type: "lite",
225            },
226            static_libs: [
227                "libprotobuf-cpp-lite",
228            ],
229            shared: {
230                enabled: false,
231            },
232        },
233    },
234}
235
236// This is the full proto version of libplatformprotos. It may only
237// be used by test code that is not shipped on the device.
238cc_library {
239    name: "libplatformprotos-test",
240    defaults: ["libplatformprotos-defaults"],
241    host_supported: false,
242
243    target: {
244        android: {
245            proto: {
246                type: "full",
247            },
248            shared: {
249                enabled: false,
250            },
251        },
252    },
253}
254