1// Copyright (C) 2022 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 15package { 16 default_applicable_licenses: ["Android-Apache-2.0"], 17} 18 19filegroup { 20 name: "adservices-proto", 21 srcs: [ 22 "*.proto", 23 ], 24} 25 26// Generate the Proto POJO builders, etc. 27java_library { 28 name: "adservices-proto-lite", 29 sdk_version: "core_current", 30 proto: { 31 type: "lite", 32 include_dirs: [ 33 "external/protobuf/src", 34 "external/protobuf/java", 35 ], 36 }, 37 srcs: [ 38 ":adservices-proto", 39 ":libprotobuf-internal-protos", 40 ], 41 static_libs: ["libprotobuf-java-lite"], 42 apex_available: ["com.android.adservices", "com.android.extservices"], 43} 44 45// Generate gRPC client code 46PROTO_TOOLS = [ 47 "aprotoc", 48 "protoc-gen-grpc-java-plugin", 49 "soong_zip", 50] 51LITE_PROTO_CMD = "mkdir -p $(genDir)/gen && " + 52 "$(location aprotoc) --java_opt=annotate_code=false -Ipackages/modules/AdServices/adservices/service-core -Iexternal/protobuf/src " + 53 "--plugin=protoc-gen-grpc-java=$(location protoc-gen-grpc-java-plugin) --grpc-java_out=lite:$(genDir)/gen $(in) && " + 54 "$(location soong_zip) -o $(out) -C $(genDir)/gen -D $(genDir)/gen" 55genrule { 56 name: "seller-frontend-service-stub-lite", 57 tools: PROTO_TOOLS, 58 cmd: LITE_PROTO_CMD, 59 srcs: [ 60 ":adservices-proto", 61 ], 62 out: [ 63 "protos.srcjar", 64 ], 65} 66 67// Package into java_library to reference in "static_libs" in "adservices-service-core" 68java_library { 69 name: "adservices-grpclib-lite", 70 min_sdk_version: "30", 71 apex_available: ["com.android.adservices", "com.android.extservices"], 72 srcs: [ 73 ":seller-frontend-service-stub-lite", 74 ":adservices-proto", 75 ":libprotobuf-internal-protos", 76 ], 77 libs: [ 78 "javax_annotation-api_1.3.2", 79 ], 80 static_libs: [ 81 "libprotobuf-java-lite", 82 "guava", 83 "grpc-java-core-android", 84 "grpc-java-okhttp-client-lite", 85 ], 86 proto: { 87 type: "lite", 88 include_dirs: [ 89 "external/protobuf/src", 90 "external/protobuf/java", 91 ], 92 }, 93} 94