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    default_applicable_licenses: [
19        "packages_modules_NeuralNetworks_runtime_license",
20    ],
21}
22
23// Added automatically by a large-scale-change that took the approach of
24// 'apply every license found to every target'. While this makes sure we respect
25// every license restriction, it may not be entirely correct.
26//
27// e.g. GPL in an MIT project might only apply to the contrib/ directory.
28//
29// Please consider splitting the single license below into multiple licenses,
30// taking care not to lose any license_kind information, and overriding the
31// default license using the 'licenses: [...]' property on targets as needed.
32//
33// For unused files, consider creating a 'fileGroup' with "//visibility:private"
34// to attach the license to, and including a comment whether the files may be
35// used in the current project.
36// See: http://go/android-license-faq
37license {
38    name: "packages_modules_NeuralNetworks_runtime_license",
39    visibility: [":__subpackages__"],
40    license_kinds: [
41        "SPDX-license-identifier-Apache-2.0",
42        "SPDX-license-identifier-Artistic",
43        "SPDX-license-identifier-BSD",
44        "SPDX-license-identifier-MPL",
45        "SPDX-license-identifier-MPL-2.0",
46    ],
47    license_text: [
48        "NOTICE",
49    ],
50}
51
52cc_library_headers {
53    name: "libneuralnetworks_headers",
54    host_supported: false,
55    vendor_available: true,
56    export_include_dirs: ["include"],
57    apex_available: [
58        "com.android.neuralnetworks",
59        "test_com.android.neuralnetworks", // Due to the dependency from libneuralnetworks_common
60        // that is available to the platform
61
62        "//apex_available:platform",
63    ],
64}
65
66cc_library_headers {
67    name: "libneuralnetworks_headers_ndk",
68    export_include_dirs: ["include"],
69    sdk_version: "current",
70}
71
72cc_library_headers {
73    name: "libneuralnetworks_private_headers",
74    host_supported: false,
75    export_include_dirs: ["."],
76}
77
78cc_defaults {
79    name: "libneuralnetworks_defaults",
80    host_supported: false,
81    use_version_lib: true,
82    // b/109953668, disable OpenMP
83    // openmp: true,
84    srcs: [
85        "AppInfoFetcher.cpp",
86        "BurstBuilder.cpp",
87        "CompilationBuilder.cpp",
88        "ExecutionBuilder.cpp",
89        "ExecutionCallback.cpp",
90        "ExecutionPlan.cpp",
91        "Manager.cpp",
92        "Memory.cpp",
93        "ModelArgumentInfo.cpp",
94        "ModelBuilder.cpp",
95        "NeuralNetworks.cpp",
96        "TypeManager.cpp",
97    ],
98
99    target: {
100        android: {
101            version_script: "libneuralnetworks.map.txt",
102            shared_libs: [
103                "liblog",
104                "libnativewindow",
105                "libneuralnetworks_packageinfo",
106            ],
107        },
108        host: {
109            shared_libs: [
110            ],
111        },
112    },
113
114    // TODO(pszczepaniak, b/144488395): Use system libnativewindow,
115    // this would remove half of dependencies here.
116    static_libs: [
117        "android.hardware.common-V2-ndk_platform",
118        "android.hardware.graphics.common-V2-ndk_platform",
119        "android.hardware.neuralnetworks-V1-ndk_platform",
120        "android.hardware.neuralnetworks@1.0",
121        "android.hardware.neuralnetworks@1.1",
122        "android.hardware.neuralnetworks@1.2",
123        "android.hardware.neuralnetworks@1.3",
124        "android.hidl.allocator@1.0",
125        "android.hidl.memory@1.0",
126        "libaidlcommonsupport",
127        "libbase",
128        "libcrypto_static",
129        "libcutils",
130        "libfmq",
131        "libhidlbase",
132        "libhidlmemory",
133        "libjsoncpp",
134        "libmath",
135        "libneuralnetworks_common",
136        "libprocessgroup",
137        "libtextclassifier_hash_static",
138        "libutils",
139        "neuralnetworks_types",
140    ],
141
142    stl: "libc++_static",
143
144    whole_static_libs: [
145        "libprocpartition",
146    ],
147
148    shared_libs: [
149        "libbinder_ndk",
150        "libcgrouprc",
151        "libvndksupport",
152    ],
153
154    header_libs: [
155        "libneuralnetworks_headers",
156    ],
157
158    export_header_lib_headers: [
159        "libneuralnetworks_headers",
160    ],
161}
162
163cc_library_shared {
164    name: "libneuralnetworks",
165    llndk: {
166        symbol_file: "libneuralnetworks.map.txt",
167        override_export_include_dirs: ["include"],
168    },
169    defaults: [
170        "libneuralnetworks_defaults",
171        "neuralnetworks_defaults",
172    ],
173    apex_available: [
174        "com.android.neuralnetworks",
175        "test_com.android.neuralnetworks",
176    ],
177
178    stubs: {
179        versions: [
180            "30",
181            "31",
182        ],
183        symbol_file: "libneuralnetworks.map.txt",
184    },
185}
186
187// Required for tests (b/147158681)
188cc_library_static {
189    name: "libneuralnetworks_static",
190    defaults: [
191        "libneuralnetworks_defaults",
192        "neuralnetworks_defaults",
193    ],
194    apex_available: ["//apex_available:platform"],
195}
196
197cc_library_static {
198    name: "libneuralnetworks_cl",
199    defaults: [
200        "neuralnetworks_cl_defaults",
201        "neuralnetworks_defaults",
202    ],
203    apex_available: ["//apex_available:platform"],
204    // b/109953668, disable OpenMP
205    // openmp: true,
206    srcs: [
207        "BurstBuilder.cpp",
208        "CompilationBuilder.cpp",
209        "ExecutionBuilder.cpp",
210        "ExecutionCallback.cpp",
211        "ExecutionPlan.cpp",
212        "Manager.cpp",
213        "Memory.cpp",
214        "ModelArgumentInfo.cpp",
215        "ModelBuilder.cpp",
216        "NeuralNetworks.cpp",
217        "TypeManager.cpp",
218    ],
219    static_libs: [
220        "libbase_ndk",
221        "libcrypto_static",
222        "libneuralnetworks_common_cl",
223        "neuralnetworks_types_cl",
224    ],
225    shared_libs: [
226        "libnativewindow",
227    ],
228    header_libs: [
229        "libneuralnetworks_headers_ndk",
230        "neuralnetworks_supportlibrary_types_ndk",
231    ],
232    export_header_lib_headers: [
233        "libneuralnetworks_headers_ndk",
234    ],
235}
236
237ndk_headers {
238    name: "libneuralnetworks_ndk_headers",
239    from: "include",
240    to: "android",
241    srcs: [
242        "include/NeuralNetworks.h",
243        "include/NeuralNetworksTypes.h",
244    ],
245    license: "NOTICE",
246}
247
248ndk_library {
249    name: "libneuralnetworks",
250    symbol_file: "libneuralnetworks.map.txt",
251    // Android O-MR1
252    first_version: "27",
253}
254