package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "system_nfc_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["system_nfc_license"],
}

cc_library_shared {
    arch: {
        arm: {
            instruction_set: "arm",
        },
    },
    name: "libnfc-nci",
    shared_libs: [
        "libcutils",
        "liblog",
        "libdl",
        "libhardware",
        "libz",
        "libchrome",
        "libbase",
        "libstatslog",

        // Treble configuration
        "libhidlbase",
        "libutils",
        "android.hardware.nfc@1.0",
        "android.hardware.nfc@1.1",
        "android.hardware.nfc@1.2",
    ],
    static_libs: [
        "libnfcutils",
    ],
    cflags: [
        "-DDYN_ALLOC=1",
        "-DBUILDCFG=1",
        "-Wall",
        "-Werror",
        "-Wimplicit-fallthrough",
    ],
    local_include_dirs: [
        "include",
        "gki/ulinux",
        "gki/common",
        "nfa/include",
        "nfc/include",
    ],
    srcs: [
        "nfa/ce/*.cc",
        "nfa/dm/*.cc",
        "nfa/ee/*.cc",
        "nfa/hci/*.cc",
        "nfa/p2p/*.cc",
        "nfa/rw/*.cc",
        "nfa/sys/*.cc",
        "nfc/llcp/*.cc",
        "nfc/nci/*.cc",
        "nfc/ndef/*.cc",
        "nfc/nfc/*.cc",
        "nfc/tags/*.cc",
        "adaptation/*.cc",
        "gki/common/*.cc",
        "gki/ulinux/*.cc",
    ],
    required: [
        // Provide a default libnfc-nci.conf in /system/etc for devices that
        // does not ship one in /product
        "libnfc-nci.conf-default",
    ],
    product_variables: {
        debuggable: {
            cflags: [
                "-DDCHECK_ALWAYS_ON",
            ],
        },
    },
    sanitize: {
        misc_undefined: ["bounds"],
        integer_overflow: true,
        scs: true,
    },

}

cc_defaults {
    name: "nfc_fuzzer_defaults",
    host_supported: true,
    native_coverage: true,
    static_libs: [
        "libnfcutils",
        "libcutils",
        "liblog",
        "libbase",
        "libchrome",
    ],
    cflags: [
        "-DBUILDCFG=1",
        "-Wall",
        "-Werror",
        "-Wimplicit-fallthrough",
        "-g",
        "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION",
        "-DGKI_ENABLE_BUF_CORRUPTION_CHECK=FALSE",
    ],
    product_variables: {
        debuggable: {
            cflags: [
                "-DDCHECK_ALWAYS_ON"
            ],
        },
    },
    local_include_dirs: [
        "include",
        "gki/ulinux",
        "gki/common",
        "nfc/include",
        "nfa/include",
        "fuzzers/inc",
    ],
}

cc_fuzz {
    name: "nfc_nci_fuzzer",
    defaults: ["nfc_fuzzer_defaults"],
    srcs: [
        "nfc/nci/*.cc",
        "nfc/nfc/*.cc",
        "gki/common/*.cc",
        "gki/ulinux/*.cc",
        "fuzzers/*.cc",
        "fuzzers/nci/*.cc",
    ],
}

cc_fuzz {
    name: "nfc_rw_fuzzer",
    defaults: ["nfc_fuzzer_defaults"],
    srcs: [
        "nfc/tags/rw_*.cc",
        "nfc/tags/tags_int.cc",
        "gki/common/*.cc",
        "gki/ulinux/*.cc",
        "fuzzers/*.cc",
        "fuzzers/rw/*.cc",
    ],
}

cc_fuzz {
    name: "nfc_ce_fuzzer",
    defaults: ["nfc_fuzzer_defaults"],
    srcs: [
        "nfc/tags/ce_*.cc",
        "nfc/tags/tags_int.cc",
        "gki/common/*.cc",
        "gki/ulinux/*.cc",
        "fuzzers/*.cc",
        "fuzzers/ce/*.cc",
    ],
}

cc_fuzz {
    name: "nfc_ndef_fuzzer",
    defaults: ["nfc_fuzzer_defaults"],
    srcs: [
        "nfa/dm/nfa_dm_ndef.cc",
        "nfc/ndef/*.cc",
        "gki/common/*.cc",
        "gki/ulinux/*.cc",
        "fuzzers/*.cc",
        "fuzzers/ndef/*.cc",
    ],
}

cc_fuzz {
    name: "nfc_llcp_fuzzer",
    defaults: ["nfc_fuzzer_defaults"],
    srcs: [
        "nfc/llcp/*.cc",
        "gki/common/*.cc",
        "gki/ulinux/*.cc",
        "fuzzers/*.cc",
        "fuzzers/llcp/*.cc",
    ],
}