1/*
2 * Copyright 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package {
18    // Inherits all licenses from parent to get Apache 2.0 and package name
19    default_applicable_licenses: [
20        "packages_modules_NeuralNetworks_license",
21    ],
22}
23
24cc_library_static {
25    name: "neuralnetworks_canonical_sample_driver",
26    defaults: ["neuralnetworks_defaults"],
27    host_supported: true,
28    vendor_available: true,
29    // b/109953668, disable OpenMP
30    // openmp: true,
31    srcs: [
32        "Canonical*.cpp",
33        "LimitedSupportDevice.cpp",
34    ],
35    header_libs: ["libneuralnetworks_headers"],
36    export_include_dirs: ["."],
37    static_libs: ["libneuralnetworks_common"],
38    shared_libs: [
39        "libbase",
40    ],
41    target: {
42        android: {
43            shared_libs: [
44                "libnativewindow",
45            ],
46        },
47        host: {
48            cflags: [
49                "-D__INTRODUCED_IN(n)=",
50            ],
51        },
52    },
53}
54
55cc_library_static {
56    name: "neuralnetworks_canonical_sample_driver_cl",
57    defaults: ["neuralnetworks_cl_defaults"],
58    // b/109953668, disable OpenMP
59    // openmp: true,
60    srcs: [
61        "Canonical*.cpp",
62        "LimitedSupportDevice.cpp",
63    ],
64    header_libs: ["libneuralnetworks_headers_ndk"],
65    export_include_dirs: ["."],
66    static_libs: [
67        "libbase_ndk",
68        "libneuralnetworks_common_cl",
69        "neuralnetworks_types_cl",
70    ],
71    shared_libs: [
72        "libnativewindow",
73    ],
74}
75
76// neuralnetworks_sample_sl_driver is an example NNAPI Support Library object.
77// In general, the SL should be built against the _cl variants, including:
78// * neuralnetworks_types_cl
79// * libneuralnetworks_common_cl
80// * libneuralnetworks_cl
81//
82// neuralnetworks_sample_sl_driver is not vendor_available, so it is not able
83// to be used directly by the build system for a vendor service. This SL object
84// is used as a prebuilt in packages/modules/NeuralNetworks/driver/sample_shim/.
85//
86// To see an example where the driver code is available as a vendor service
87// directly in the build system, refer to how the sAIDL adapter is used in
88// android.hardware.neuralnetworks-service-sample-limited in the file
89// packages/modules/NeuralNetworks/driver/sample_aidl/Android.bp.
90cc_library_shared {
91    name: "neuralnetworks_sample_sl_driver",
92    defaults: ["neuralnetworks_cl_defaults"],
93    srcs: ["SampleDriverSL.cpp"],
94    shared_libs: [
95        "liblog",
96        "libnativewindow",
97    ],
98    // Change the soname, this library will be added as cc_prebuilt_library_shared
99    // with different name to android.hardware.neuralnetworks-shim-service-sample
100    ldflags: [
101        "-Wl,-soname,neuralnetworks_sample_sl_driver_prebuilt.so",
102    ],
103    static_libs: [
104        "libbase_ndk",
105        "libcrypto_static",
106        "libneuralnetworks_common_cl_cpu",
107        "libtflite_static",
108        "neuralnetworks_canonical_sample_driver_cl",
109        "neuralnetworks_types_cl",
110    ],
111    whole_static_libs: [
112        "libneuralnetworks_cl",
113    ],
114}
115
116cc_fuzz {
117    name: "android.hardware.neuralnetworks-service.example_fuzzer",
118    host_supported: true,
119    defaults: [
120        "neuralnetworks_defaults",
121        "neuralnetworks_use_latest_utils_hal_aidl",
122        "service_fuzzer_defaults",
123    ],
124    header_libs: [
125        "libneuralnetworks_headers",
126    ],
127    shared_libs: [
128        "liblog",
129        "libtextclassifier_hash",
130    ],
131    static_libs: [
132        "libaidlcommonsupport",
133        "libneuralnetworks_common",
134        "neuralnetworks_canonical_sample_driver",
135        "neuralnetworks_utils_hal_adapter_aidl",
136    ],
137    target: {
138        android: {
139            shared_libs: [
140                "libnativewindow",
141            ],
142        },
143    },
144    srcs: ["Fuzzer.cpp"],
145    fuzz_config: {
146        cc: [
147            "[email protected]",
148        ],
149        triage_assignee: "[email protected]",
150        componentid: 195575,
151        description: "The fuzzer targets the APIs of libneuralnetworks_common",
152        vector: "host_access",
153        service_privilege: "nsi",
154        users: "single_user",
155        fuzzed_code_usage: "experimental",
156    },
157}
158