xref: /aosp_15_r20/external/federated-compute/Android.bp (revision 14675a029014e728ec732f129a32e299b2da0601)
1// Copyright (C) 2023 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: ["external_federated_compute_license"],
17}
18
19license {
20    name: "external_federated_compute_license",
21    visibility: [":__subpackages__"],
22    license_kinds: [
23        "SPDX-license-identifier-Apache-2.0",
24    ],
25    license_text: [
26        "LICENSE",
27    ],
28}
29
30cc_library_headers {
31    name: "libfederatedcompute_headers",
32    export_include_dirs: ["."],
33    sdk_version: "current",
34    min_sdk_version: "33",
35    apex_available: ["com.android.ondevicepersonalization"],
36}
37
38java_library_static {
39    name: "federated-compute-java-proto-lite",
40    proto: {
41        type: "lite",
42        canonical_path_from_root: false,
43        include_dirs: [
44            "external/protobuf/src",
45            "external/protobuf/java",
46            "external/tensorflow",
47        ],
48    },
49    srcs: [
50        "fcp/protos/ondevicepersonalization/task_assignments.proto",
51        "fcp/protos/ondevicepersonalization/eligibility_spec.proto",
52        "fcp/protos/ondevicepersonalization/exception_reporting.proto",
53        "fcp/protos/ondevicepersonalization/common.proto",
54        "fcp/protos/federatedcompute/common.proto",
55        "fcp/protos/plan.proto",
56        "fcp/client/**/*.proto",
57        ":libprotobuf-internal-protos",
58    ],
59    static_libs: [
60        "libprotobuf-java-lite",
61        "tensorflow_core_proto_java_lite",
62    ],
63    sdk_version: "current",
64    min_sdk_version: "33",
65    apex_available: ["com.android.ondevicepersonalization"],
66}
67
68cc_library {
69    name: "federated-compute-cc-proto-lite",
70    srcs: [
71        "fcp/secagg/shared/secagg_messages.proto",
72        "fcp/secagg/server/secagg_server_enums.proto",
73        "fcp/client/**/*.proto",
74        "fcp/protos/**/*.proto",
75        "fcp/dictionary/*.proto",
76        ":libprotobuf-internal-protos",
77    ],
78    proto: {
79        type: "lite",
80        export_proto_headers: true,
81        canonical_path_from_root: false,
82        include_dirs: [
83            "external/protobuf/src",
84            "external/tensorflow",
85        ],
86    },
87    static_libs: [
88        "tensorflow_core_proto_cpp_lite",
89    ],
90    shared_libs: [
91        "liblog",
92    ],
93    stl: "libc++_static",
94    apex_available: ["com.android.ondevicepersonalization"],
95    sdk_version: "current",
96    min_sdk_version: "33",
97}
98
99cc_library_static {
100    name: "libfederatedcompute",
101    srcs: [
102        "fcp/client/fcp_runner.cc",
103        "fcp/client/interruptible_runner.cc",
104        "fcp/client/simple_task_environment.cc",
105        "fcp/client/engine/*.cc",
106        "fcp/tensorflow/*.cc",
107        "fcp/dictionary/dictionary.cc",
108        "fcp/base/base_name.cc",
109        "fcp/base/monitoring.cc",
110        "fcp/base/platform.cc",
111        "fcp/base/clock.cc",
112        "fcp/base/random_token.cc",
113        "fcp/base/scheduler.cc",
114    ],
115    exclude_srcs: [
116        "fcp/**/*test*.cc",
117        "fcp/client/fake_*.cc",
118        // Exclude tfmobile engine dependencies.
119        "fcp/client/engine/tf_wrapper.cc",
120        "fcp/client/engine/simple_plan_engine.cc",
121        "fcp/tensorflow/tf_session.cc",
122    ],
123    static_libs: [
124        "federated-compute-cc-proto-lite",
125    ],
126    whole_static_libs: [
127        "libtflite_flex_delegate",
128    ],
129    export_include_dirs: ["."],
130    header_libs: [
131        "flatbuffer_headers",
132        "libeigen",
133        "libtextclassifier_hash_headers",
134    ],
135    shared_libs: [
136        "libcrypto",
137    ],
138    visibility: [
139        "//packages/modules/OnDevicePersonalization:__subpackages__",
140    ],
141    cflags: [
142        "-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash",
143        "-Wno-ignored-qualifiers",
144        "-Wno-unused-parameter",
145        "-Wno-missing-field-initializers",
146        "-Wno-defaulted-function-deleted",
147        "-Wno-deprecated-declarations",
148    ],
149    stl: "libc++_static",
150    sdk_version: "current",
151    apex_available: ["com.android.ondevicepersonalization"],
152    min_sdk_version: "33",
153}
154
155filegroup {
156    name: "fcp_native_wrapper",
157    srcs: ["fcp/java_src/main/java/com/google/fcp/client/CallFromNativeWrapper.java"],
158    visibility: [
159        "//packages/modules/OnDevicePersonalization:__subpackages__",
160    ],
161}
162
163filegroup {
164    name: "fcp_artifacts_testdata",
165    srcs: [
166        "fcp/testdata/federation_client_only_plan.pb",
167        "fcp/testdata/federation_proxy_train_examples.pb",
168        "fcp/testdata/federation_test_checkpoint.client.ckp",
169        "fcp/testdata/federation_test_select_checkpoints.pb",
170    ],
171    visibility: [
172        "//packages/modules/OnDevicePersonalization:__subpackages__",
173    ],
174}
175
176cc_test {
177    name: "fcp_plan_engine_test",
178    srcs: [
179        "fcp/client/engine/tflite_plan_engine_test.cc",
180        "fcp/client/engine/example_query_plan_engine_test.cc",
181        "fcp/tensorflow/file_descriptor_filesystem_test.cc",
182        "fcp/client/test_helpers.cc",
183    ],
184    test_suites: [
185        "general-tests",
186    ],
187    static_libs: [
188        "federated-compute-cc-proto-lite",
189        "libabsl",
190        "libbase_ndk",
191        "libc++fs", // used by filesystem
192        "libgmock",
193        "liblog",
194        "libprotobuf-cpp-lite-ndk",
195    ],
196    whole_static_libs: [
197        "libfederatedcompute",
198    ],
199    shared_libs: [
200        "libcurl",
201        "libcrypto",
202    ],
203    header_libs: [
204        "libeigen",
205    ],
206    stl: "libc++_static",
207    data: [
208        "fcp/testdata/federation_client_only_plan.pb",
209        "fcp/testdata/federation_proxy_train_examples.pb",
210        "fcp/testdata/federation_test_checkpoint.client.ckp",
211        "fcp/testdata/federation_test_select_checkpoints.pb",
212    ],
213    cflags: [
214        "-Wno-unused-parameter",
215        "-Wno-ignored-qualifiers",
216        "-Wno-missing-field-initializers",
217    ],
218}
219