• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    package_name: "Android Neural Networks API Runtime",
40    visibility: [":__subpackages__"],
41    license_kinds: [
42        "SPDX-license-identifier-Apache-2.0",
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: true,
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    host_supported: true,
69    export_include_dirs: ["include"],
70    sdk_version: "current",
71}
72
73cc_library_headers {
74    name: "libneuralnetworks_private_headers",
75    host_supported: true,
76    export_include_dirs: ["."],
77}
78
79cc_defaults {
80    name: "libneuralnetworks_defaults",
81    defaults: ["neuralnetworks_use_latest_utils_hal_aidl"],
82    host_supported: true,
83    use_version_lib: true,
84    // b/109953668, disable OpenMP
85    // openmp: true,
86    srcs: [
87        "AppInfoFetcher.cpp",
88        "BurstBuilder.cpp",
89        "CompilationBuilder.cpp",
90        "ExecutionBuilder.cpp",
91        "ExecutionCallback.cpp",
92        "ExecutionPlan.cpp",
93        "Manager.cpp",
94        "Memory.cpp",
95        "ModelArchHasher.cpp",
96        "ModelArgumentInfo.cpp",
97        "ModelBuilder.cpp",
98        "NeuralNetworks.cpp",
99        "ServerFlag.cpp",
100        "Telemetry.cpp",
101        "TypeManager.cpp",
102    ],
103    target: {
104        android: {
105            version_script: "libneuralnetworks.map.txt",
106            generated_sources: ["statslog_neuralnetworks.cpp"],
107            generated_headers: ["statslog_neuralnetworks.h"],
108            export_generated_headers: ["statslog_neuralnetworks.h"],
109            srcs: [
110                "TelemetryStatsd.cpp",
111            ],
112            shared_libs: [
113                "libnativewindow",
114                "libstatssocket",
115                "libvndksupport",
116            ],
117            whole_static_libs: [
118                "libprocpartition",
119            ],
120        },
121        host: {
122            cflags: [
123                "-D__INTRODUCED_IN(n)=",
124            ],
125        },
126    },
127
128    // TODO(pszczepaniak, b/144488395): Use system libnativewindow,
129    // this would remove half of dependencies here.
130    static_libs: [
131        "android.hardware.neuralnetworks@1.0",
132        "android.hardware.neuralnetworks@1.1",
133        "android.hardware.neuralnetworks@1.2",
134        "android.hardware.neuralnetworks@1.3",
135        "android.hidl.allocator@1.0",
136        "android.hidl.memory@1.0",
137        "libaidlcommonsupport",
138        "libbase",
139        "libcrypto_static",
140        "libcutils",
141        "libfmq",
142        "libhidlbase",
143        "libhidlmemory",
144        "libjsoncpp",
145        "libmath",
146        "libneuralnetworks_common",
147        "libprocessgroup",
148        "libtextclassifier_hash_static",
149        "libutils",
150        "neuralnetworks_types",
151        "neuralnetworks_utils_hal_service",
152        "server_configurable_flags",
153    ],
154
155    stl: "libc++_static",
156
157    shared_libs: [
158        "libbinder_ndk",
159        "libcgrouprc",
160        "liblog",
161        "libneuralnetworks_packageinfo",
162    ],
163
164    header_libs: [
165        "libneuralnetworks_headers",
166    ],
167
168    export_header_lib_headers: [
169        "libneuralnetworks_headers",
170    ],
171}
172
173cc_library_shared {
174    name: "libneuralnetworks",
175    llndk: {
176        symbol_file: "libneuralnetworks.map.txt",
177        override_export_include_dirs: ["include"],
178    },
179    defaults: [
180        "libneuralnetworks_defaults",
181        "neuralnetworks_defaults",
182    ],
183    apex_available: [
184        "com.android.neuralnetworks",
185        "test_com.android.neuralnetworks",
186    ],
187
188    stubs: {
189        versions: [
190            "30",
191            "31",
192        ],
193        symbol_file: "libneuralnetworks.map.txt",
194    },
195}
196
197// Required for tests (b/147158681)
198cc_library_static {
199    name: "libneuralnetworks_static",
200    defaults: [
201        "libneuralnetworks_defaults",
202        "neuralnetworks_defaults",
203    ],
204    apex_available: ["//apex_available:platform"],
205}
206
207// Required for tests (b/147158681)
208cc_library_static {
209    name: "libneuralnetworks_static_experimental",
210    defaults: [
211        "libneuralnetworks_defaults",
212        "neuralnetworks_defaults",
213    ],
214    exclude_static_libs: [
215        "libneuralnetworks_common",
216        "neuralnetworks_types",
217        "server_configurable_flags",
218    ],
219    static_libs: [
220        "libneuralnetworks_common_experimental",
221        "neuralnetworks_types_experimental",
222    ],
223    cflags: ["-DNN_EXPERIMENTAL_FEATURE"],
224    apex_available: ["//apex_available:platform"],
225}
226
227cc_library_static {
228    name: "libneuralnetworks_cl",
229    defaults: [
230        "neuralnetworks_cl_defaults",
231        "neuralnetworks_defaults",
232    ],
233    host_supported: false,
234    apex_available: ["//apex_available:platform"],
235    // b/109953668, disable OpenMP
236    // openmp: true,
237    srcs: [
238        "BurstBuilder.cpp",
239        "CompilationBuilder.cpp",
240        "ExecutionBuilder.cpp",
241        "ExecutionCallback.cpp",
242        "ExecutionPlan.cpp",
243        "Manager.cpp",
244        "Memory.cpp",
245        "ModelArchHasher.cpp",
246        "ModelArgumentInfo.cpp",
247        "ModelBuilder.cpp",
248        "NeuralNetworks.cpp",
249        "ServerFlag.cpp",
250        "SupportLibraryDiagnostic.cpp",
251        "Telemetry.cpp",
252        "TypeManager.cpp",
253    ],
254    static_libs: [
255        "libbase_ndk",
256        "libcrypto_static",
257        "libneuralnetworks_common_cl",
258        "neuralnetworks_types_cl",
259    ],
260    shared_libs: [
261        "libnativewindow",
262    ],
263    header_libs: [
264        "libneuralnetworks_headers_ndk",
265        "neuralnetworks_supportlibrary_types_ndk",
266    ],
267    export_header_lib_headers: [
268        "libneuralnetworks_headers_ndk",
269    ],
270}
271
272ndk_headers {
273    name: "libneuralnetworks_ndk_headers",
274    from: "include",
275    to: "android",
276    srcs: [
277        "include/NeuralNetworks.h",
278        "include/NeuralNetworksTypes.h",
279    ],
280    license: "NOTICE",
281}
282
283ndk_library {
284    name: "libneuralnetworks",
285    symbol_file: "libneuralnetworks.map.txt",
286    // Android O-MR1
287    first_version: "27",
288}
289
290genrule {
291    name: "statslog_neuralnetworks.h",
292    tools: ["stats-log-api-gen"],
293    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_neuralnetworks.h --module neuralnetworks --namespace android,nn,stats",
294    out: [
295        "statslog_neuralnetworks.h",
296    ],
297}
298
299genrule {
300    name: "statslog_neuralnetworks.cpp",
301    tools: ["stats-log-api-gen"],
302    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_neuralnetworks.cpp --module neuralnetworks --namespace android,nn,stats  --importHeader statslog_neuralnetworks.h",
303    out: [
304        "statslog_neuralnetworks.cpp",
305    ],
306}
307