• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    // See: http://go/android-license-faq
3    // A large-scale-change added 'default_applicable_licenses' to import
4    // all of the 'license_kinds' from "system_nfc_license"
5    // to get the below license kinds:
6    //   SPDX-license-identifier-Apache-2.0
7    default_applicable_licenses: ["system_nfc_license"],
8}
9
10cc_library_shared {
11    arch: {
12        arm: {
13            instruction_set: "arm",
14        },
15    },
16    name: "libnfc-nci",
17    shared_libs: [
18        "libcutils",
19        "liblog",
20        "libdl",
21        "libz",
22        "libchrome",
23        "libbase",
24        "libstatslog_nfc",
25
26        // Treble configuration
27        "libhidlbase",
28        "libutils",
29        "android.hardware.nfc@1.0",
30        "android.hardware.nfc@1.1",
31        "android.hardware.nfc@1.2",
32        // Add for AIDL
33        "android.hardware.nfc-V1-ndk",
34        "libbinder_ndk",
35    ],
36    static_libs: [
37        "libnfcutils",
38    ],
39    cflags: [
40        "-DDYN_ALLOC=1",
41        "-DBUILDCFG=1",
42        "-DGKI_PTHREAD_JOINABLE",
43        "-Wall",
44        "-Werror",
45        "-Wimplicit-fallthrough",
46    ],
47    local_include_dirs: [
48        "include",
49        "gki/ulinux",
50        "gki/common",
51        "nfa/include",
52        "nfc/include",
53    ],
54    srcs: [
55        "nfa/ce/*.cc",
56        "nfa/dm/*.cc",
57        "nfa/ee/*.cc",
58        "nfa/hci/*.cc",
59        "nfa/p2p/*.cc",
60        "nfa/rw/*.cc",
61        "nfa/sys/*.cc",
62        "nfc/llcp/*.cc",
63        "nfc/nci/*.cc",
64        "nfc/ndef/*.cc",
65        "nfc/nfc/*.cc",
66        "nfc/tags/*.cc",
67        "adaptation/*.cc",
68        "gki/common/*.cc",
69        "gki/ulinux/*.cc",
70    ],
71    required: [
72        // Provide a default libnfc-nci.conf in /system/etc for devices that
73        // does not ship one in /product
74        "libnfc-nci.conf-default",
75    ],
76    product_variables: {
77        debuggable: {
78            cflags: [
79                "-DDCHECK_ALWAYS_ON",
80            ],
81        },
82    },
83    sanitize: {
84        misc_undefined: ["bounds"],
85        integer_overflow: true,
86        scs: true,
87    },
88
89}
90
91cc_defaults {
92    name: "nfc_fuzzer_defaults",
93    host_supported: true,
94    native_coverage: true,
95    static_libs: [
96        "libnfcutils",
97        "libcutils",
98        "liblog",
99        "libbase",
100        "libchrome",
101    ],
102    cflags: [
103        "-DBUILDCFG=1",
104        "-Wall",
105        "-Werror",
106        "-Wimplicit-fallthrough",
107        "-g",
108        "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION",
109        "-DGKI_ENABLE_BUF_CORRUPTION_CHECK=FALSE",
110    ],
111    product_variables: {
112        debuggable: {
113            cflags: [
114                "-DDCHECK_ALWAYS_ON"
115            ],
116        },
117    },
118    local_include_dirs: [
119        "include",
120        "gki/ulinux",
121        "gki/common",
122        "nfc/include",
123        "nfa/include",
124        "fuzzers/inc",
125    ],
126    fuzz_config: {
127       cc: [
128            "android-security-assurance-redteam@google.com",
129            "zachoverflow@google.com",
130            "jackcwyu@google.com",
131            "georgekgchang@google.com",
132            "alisher@google.com",
133        ],
134    },
135}
136
137cc_library {
138    name: "libstatslog_nfc",
139    host_supported: true,
140    generated_sources: ["statslog_nfc.cpp"],
141    generated_headers: ["statslog_nfc.h"],
142    export_generated_headers: ["statslog_nfc.h"],
143    shared_libs: [
144        "libcutils",
145    ],
146    target: {
147        android: {
148            shared_libs: [
149                "libstatssocket",
150            ],
151        },
152        host: {
153            static_libs: [
154                "libstatssocket",
155            ],
156        },
157        darwin: {
158            enabled: false,
159        },
160    },
161}
162
163genrule {
164    name: "statslog_nfc.h",
165    tools: ["stats-log-api-gen"],
166    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_nfc.h --module nfc --namespace nfc,stats",
167    out: [
168        "statslog_nfc.h",
169    ],
170}
171
172genrule {
173    name: "statslog_nfc.cpp",
174    tools: ["stats-log-api-gen"],
175    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_nfc.cpp --module nfc --namespace nfc,stats --importHeader statslog_nfc.h",
176    out: [
177        "statslog_nfc.cpp",
178    ],
179}
180
181cc_fuzz {
182    name: "nfc_nci_fuzzer",
183    defaults: ["nfc_fuzzer_defaults"],
184    fuzzing_frameworks: {
185      afl: false,
186    },
187    srcs: [
188        "nfc/nci/*.cc",
189        "nfc/nfc/*.cc",
190        "adaptation/debug_lmrt.cc",
191        "gki/common/*.cc",
192        "gki/ulinux/*.cc",
193        "fuzzers/*.cc",
194        "fuzzers/nci/*.cc",
195    ],
196    shared_libs: [
197        "libstatslog_nfc",
198    ]
199}
200
201cc_fuzz {
202    name: "nfc_rw_fuzzer",
203    defaults: ["nfc_fuzzer_defaults"],
204    fuzzing_frameworks: {
205      afl: false,
206    },
207    srcs: [
208        "nfc/tags/rw_*.cc",
209        "nfc/tags/tags_int.cc",
210        "gki/common/*.cc",
211        "gki/ulinux/*.cc",
212        "fuzzers/*.cc",
213        "fuzzers/rw/*.cc",
214    ],
215}
216
217cc_fuzz {
218    name: "nfc_ce_fuzzer",
219    defaults: ["nfc_fuzzer_defaults"],
220    fuzzing_frameworks: {
221      afl: false,
222    },
223    srcs: [
224        "nfc/tags/ce_*.cc",
225        "nfc/tags/tags_int.cc",
226        "gki/common/*.cc",
227        "gki/ulinux/*.cc",
228        "fuzzers/*.cc",
229        "fuzzers/ce/*.cc",
230    ],
231}
232
233cc_fuzz {
234    name: "nfc_ndef_fuzzer",
235    defaults: ["nfc_fuzzer_defaults"],
236    fuzzing_frameworks: {
237      afl: false,
238    },
239    srcs: [
240        "nfa/dm/nfa_dm_ndef.cc",
241        "nfc/ndef/*.cc",
242        "gki/common/*.cc",
243        "gki/ulinux/*.cc",
244        "fuzzers/*.cc",
245        "fuzzers/ndef/*.cc",
246    ],
247}
248
249cc_fuzz {
250    name: "nfc_llcp_fuzzer",
251    defaults: ["nfc_fuzzer_defaults"],
252    fuzzing_frameworks: {
253      afl: false,
254    },
255    srcs: [
256        "nfc/llcp/*.cc",
257        "gki/common/*.cc",
258        "gki/ulinux/*.cc",
259        "fuzzers/*.cc",
260        "fuzzers/llcp/*.cc",
261    ],
262}
263
264cc_library_static {
265    name: "nfc_integration_fuzzer_proto",
266    owner: "google",
267    host_supported: true,
268    srcs: ["fuzzers/integration/nfc_integration_fuzzer.proto"],
269    proto: {
270        type: "full",
271        export_proto_headers: true,
272    },
273    shared_libs: ["libprotobuf-cpp-full"],
274}
275
276cc_fuzz {
277    name: "nfc_integration_fuzzer",
278    defaults: ["nfc_fuzzer_defaults"],
279    fuzzing_frameworks: {
280      afl: false,
281    },
282    srcs: [
283        "adaptation/debug_nfcsnoop.cc",
284        "fuzzers/integration/*.cc",
285        "fuzzers/integration/fakes/*.cc",
286        "gki/common/gki_buffer.cc",
287        "adaptation/debug_lmrt.cc",
288        "nfa/ce/*.cc",
289        "nfa/dm/*.cc",
290        "nfa/ee/*.cc",
291        "nfa/hci/*.cc",
292        "nfa/p2p/*.cc",
293        "nfa/rw/*.cc",
294        "nfa/sys/*.cc",
295        "nfc/llcp/*.cc",
296        "nfc/nci/*.cc",
297        "nfc/ndef/*.cc",
298        "nfc/nfc/*.cc",
299        "nfc/tags/*.cc",
300    ],
301    cflags: [
302        "-DNFC_INTEGRATION_FUZZER",
303    ],
304    local_include_dirs: [
305        "fuzzers/integration",
306        "fuzzers/integration/fakes",
307    ],
308    static_libs: [
309        "libprotobuf-mutator",
310        "libutils",
311        "nfc_integration_fuzzer_proto",
312    ],
313    shared_libs: [
314        "libprotobuf-cpp-full",
315        "libstatslog_nfc",
316        "libz",
317    ]
318}
319
320genrule {
321    name: "NfcGeneratedPackets_rust",
322    tools: [
323        "bluetooth_packetgen",
324    ],
325    cmd: "$(location bluetooth_packetgen) --include=system/nfc/src --out=$(genDir) $(in) --rust",
326    srcs: [
327        "nci_packets.pdl",
328    ],
329    out: [
330        "nci_packets.rs",
331    ],
332}
333
334rust_library {
335    name: "libnfc_packets",
336    defaults: ["nfc_rust_defaults"],
337    crate_name: "nfc_packets",
338    srcs: ["rust/packets/lib.rs", ":NfcGeneratedPackets_rust"],
339    host_supported: true,
340    proc_macros: ["libnum_derive"],
341    rustlibs: [
342        "libbytes",
343        "libnum_traits",
344        "libthiserror",
345        "liblog_rust",
346    ],
347}
348
349rust_test_host {
350    name: "libnfc_packets_test",
351    defaults: ["nfc_rust_defaults"],
352    srcs: ["rust/packets/lib.rs", ":NfcGeneratedPackets_rust"],
353    test_suites: ["general-tests"],
354    proc_macros: ["libnum_derive"],
355    rustlibs: [
356        "libbytes",
357        "libnum_traits",
358        "libthiserror",
359        "liblog_rust",
360    ],
361}
362