1//
2// Copyright (C) 2021 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    // See: http://go/android-license-faq
19    // A large-scale-change added 'default_applicable_licenses' to import
20    // all of the 'license_kinds' from "hardware_interfaces_license"
21    // to get the below license kinds:
22    //   SPDX-license-identifier-Apache-2.0
23    default_applicable_licenses: ["hardware_interfaces_license"],
24}
25
26cc_defaults {
27    name: "neuralnetworks_utils_hal_aidl_defaults",
28    defaults: [
29        "android.hardware.graphics.common-ndk_static",
30        "neuralnetworks_utils_defaults",
31    ],
32    srcs: [
33        // AIDL utils that a driver may depend on.
34        "src/BufferTracker.cpp",
35        "src/Conversions.cpp",
36        "src/HalUtils.cpp",
37        "src/Utils.cpp",
38        "src/ValidateHal.cpp",
39    ],
40    local_include_dirs: ["include/nnapi/hal/aidl/"],
41    export_include_dirs: ["include"],
42    cflags: ["-Wthread-safety"],
43    static_libs: [
44        "libaidlcommonsupport",
45        "libarect",
46        "neuralnetworks_types",
47        "neuralnetworks_utils_hal_common",
48    ],
49    shared_libs: [
50        "libbinder_ndk",
51    ],
52    target: {
53        android: {
54            shared_libs: ["libnativewindow"],
55        },
56    },
57}
58
59// Deprecated. Remove once all modules depending on this are migrated away.
60cc_library_static {
61    name: "neuralnetworks_utils_hal_aidl_v1",
62    defaults: ["neuralnetworks_utils_hal_aidl_defaults"],
63    shared_libs: [
64        "android.hardware.neuralnetworks-V1-ndk",
65    ],
66}
67
68cc_library_static {
69    name: "neuralnetworks_utils_hal_aidl",
70    defaults: ["neuralnetworks_utils_hal_aidl_defaults"],
71    srcs: [
72        // Additional AIDL utils for the runtime.
73        "src/Assertions.cpp",
74        "src/Buffer.cpp",
75        "src/Burst.cpp",
76        "src/Callbacks.cpp",
77        "src/Device.cpp",
78        "src/Execution.cpp",
79        "src/InvalidDevice.cpp",
80        "src/PreparedModel.cpp",
81        "src/ProtectCallback.cpp",
82        "src/Service.cpp",
83    ],
84    shared_libs: [
85        "android.hardware.neuralnetworks-V4-ndk",
86    ],
87    cflags: ["-DNN_AIDL_V4_OR_ABOVE"],
88}
89
90// A cc_defaults that includes the latest non-experimental AIDL utilities and other AIDL libraries
91// that are commonly used together. Modules that always depend on the latest non-experimental
92// AIDL features can include this cc_defaults to avoid managing dependency versions explicitly.
93cc_defaults {
94    name: "neuralnetworks_use_latest_utils_hal_aidl",
95    defaults: ["android.hardware.graphics.common-ndk_static"],
96    static_libs: [
97        "android.hardware.common-V2-ndk",
98        "android.hardware.neuralnetworks-V4-ndk",
99        "neuralnetworks_utils_hal_aidl",
100    ],
101    cflags: ["-DNN_AIDL_V4_OR_ABOVE"],
102}
103
104cc_test {
105    name: "neuralnetworks_utils_hal_aidl_test",
106    defaults: [
107        "neuralnetworks_use_latest_utils_hal_aidl",
108        "neuralnetworks_utils_defaults",
109    ],
110    tidy_timeout_srcs: [
111        "test/DeviceTest.cpp",
112        "test/PreparedModelTest.cpp",
113    ],
114    srcs: [
115        "test/*.cpp",
116    ],
117    static_libs: [
118        "libaidlcommonsupport",
119        "libgmock",
120        "neuralnetworks_types",
121        "neuralnetworks_utils_hal_common",
122    ],
123    shared_libs: [
124        "libbase",
125        "libbinder_ndk",
126        "libcutils",
127    ],
128    target: {
129        android: {
130            shared_libs: ["libnativewindow"],
131        },
132    },
133    cflags: [
134        /* GMOCK defines functions for printing all MOCK_DEVICE arguments and
135         * MockDevice contains a string pointer which triggers a warning in the
136         * base logging library. */
137        "-Wno-user-defined-warnings",
138    ],
139    test_suites: ["general-tests"],
140}
141