blob: c127449fce3703a923ccee2e4f72213827de4e21 [file] [log] [blame]
Anton Hansson92b6c722021-04-12 18:05:56 +01001// 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 ":libtombstone_proto-src",
39 "core/proto/**/*.proto",
40 "libs/incident/**/*.proto",
41 ],
42 output_extension: "srcjar",
43}
44
45gensrcs {
46 name: "framework-cppstream-protos",
47 depfile: true,
48
49 tools: [
50 "aprotoc",
51 "protoc-gen-cppstream",
52 ],
53
54 cmd: "mkdir -p $(genDir) " +
55 "&& $(location aprotoc) " +
56 " --plugin=$(location protoc-gen-cppstream) " +
57 " --dependency_out=$(depfile) " +
58 " --cppstream_out=$(genDir) " +
59 " -Iexternal/protobuf/src " +
60 " -I . " +
61 " $(in)",
62
63 srcs: [
64 ":ipconnectivity-proto-src",
65 ":libstats_atom_enum_protos",
66 "core/proto/**/*.proto",
67 "libs/incident/**/*.proto",
68 ],
69
70 output_extension: "proto.h",
71}
72
73// ==== java proto host library ==============================
74java_library_host {
75 name: "platformprotos",
76 srcs: [
77 ":ipconnectivity-proto-src",
78 ":libstats_atom_enum_protos",
79 ":libstats_internal_protos",
80 ":statsd_internal_protos",
81 "cmds/am/proto/instrumentation_data.proto",
82 "cmds/statsd/src/**/*.proto",
83 "core/proto/**/*.proto",
84 "libs/incident/proto/**/*.proto",
85 ],
86 proto: {
87 include_dirs: [
88 "external/protobuf/src",
89 "frameworks/proto_logging/stats",
90 ],
91 type: "full",
92 },
93 errorprone: {
94 javacflags: ["-Xep:MissingOverride:OFF"], // b/72714520
95 },
96}
97
98// ==== java proto device library (for test only) ==============================
99java_library {
100 name: "platformprotosnano",
101 proto: {
102 type: "nano",
103 output_params: ["store_unknown_fields=true"],
104 include_dirs: ["external/protobuf/src"],
105 },
106 exclude_srcs: [
107 "core/proto/android/privacy.proto",
108 "core/proto/android/section.proto",
109 ],
110 sdk_version: "9",
111 srcs: [
112 ":ipconnectivity-proto-src",
113 ":libstats_atom_enum_protos",
114 "core/proto/**/*.proto",
115 "libs/incident/proto/android/os/**/*.proto",
116 ],
117}
118
119// ==== java proto device library (for test only) ==============================
120java_library {
121 name: "platformprotoslite",
122 proto: {
123 type: "lite",
124 include_dirs: ["external/protobuf/src"],
125 },
126
127 srcs: [
128 ":ipconnectivity-proto-src",
129 ":libstats_atom_enum_protos",
130 "core/proto/**/*.proto",
131 "libs/incident/proto/android/os/**/*.proto",
132 ],
133 exclude_srcs: [
134 "core/proto/android/privacy.proto",
135 "core/proto/android/section.proto",
136 ],
137 sdk_version: "core_current",
138 // Protos have lots of MissingOverride and similar.
139 errorprone: {
140 javacflags: ["-XepDisableAllChecks"],
141 },
142}
143
144// ==== c++ proto device library ==============================
145cc_defaults {
146 name: "libplatformprotos-defaults",
147
148 proto: {
149 export_proto_headers: true,
150 include_dirs: [
151 "external/protobuf/src",
152 ],
153 },
154
155 cflags: [
156 "-Wall",
157 "-Werror",
158 "-Wno-unused-parameter",
159 ],
160
161 srcs: [
162 ":ipconnectivity-proto-src",
163 ":libstats_atom_enum_protos",
164 "core/proto/**/*.proto",
165 ],
166}
167
168cc_library {
169 name: "libplatformprotos",
170 defaults: ["libplatformprotos-defaults"],
171 host_supported: true,
172
173 target: {
174 host: {
175 proto: {
176 type: "full",
177 },
178 },
179 android: {
180 proto: {
181 type: "lite",
182 },
183 shared_libs: [
184 "libprotobuf-cpp-lite",
185 ],
186 shared: {
187 enabled: false,
188 },
189 },
190 },
191}
192
193// This library is meant for vendor code that needs to output protobuf. It links
194// against the static version of libprotobuf-cpp-lite, for which we can not guarantee
195// binary compatibility.
196cc_library {
197 name: "libplatformprotos-static",
198 defaults: ["libplatformprotos-defaults"],
199 host_supported: false,
200
201 // This is okay because this library is only built as a static library. The C++
202 // API is not guaranteed. The proto API is guaranteed to be stable via Metrics Council,
203 // but is not authorized to be used outside of debugging.
204 vendor_available: true,
205
206 target: {
207 android: {
208 proto: {
209 type: "lite",
210 },
211 static_libs: [
212 "libprotobuf-cpp-lite",
213 ],
214 shared: {
215 enabled: false,
216 },
217 },
218 },
219}
220
221// This is the full proto version of libplatformprotos. It may only
222// be used by test code that is not shipped on the device.
223cc_library {
224 name: "libplatformprotos-test",
225 defaults: ["libplatformprotos-defaults"],
226 host_supported: false,
227
228 target: {
229 android: {
230 proto: {
231 type: "full",
232 },
233 shared: {
234 enabled: false,
235 },
236 },
237 },
238}