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

cc_library_static {
    name: "android.hardware.identity-libeic-hal-common",
    vendor_available: true,
    defaults: [
        "identity_use_latest_hal_aidl_ndk_static",
        "keymint_use_latest_hal_aidl_ndk_static",
    ],
    srcs: [
        "common/IdentityCredential.cpp",
        "common/IdentityCredentialStore.cpp",
        "common/PresentationSession.cpp",
        "common/WritableIdentityCredential.cpp",
    ],
    export_include_dirs: [
        "common",
    ],
    cflags: [
        "-Wall",
        "-Wextra",
        "-Wno-deprecated-declarations",
    ],
    shared_libs: [
        "liblog",
        "libcrypto",
        "libbinder_ndk",
        "libkeymaster_messages",
    ],
    static_libs: [
        "libbase",
        "libcppbor_external",
        "libcppcose_rkp",
        "libutils",
        "libsoft_attestation_cert",
        "libkeymaster_portable",
        "libsoft_attestation_cert",
        "libpuresoftkeymasterdevice",
        "android.hardware.identity-support-lib",
        "android.hardware.keymaster-V3-ndk",
        "android.hardware.security.rkp-V3-ndk",
    ],
}

cc_library_static {
    name: "android.hardware.identity-libeic-library",
    vendor_available: true,
    srcs: [
        "libeic/EicCbor.c",
        "libeic/EicSession.c",
        "libeic/EicPresentation.c",
        "libeic/EicProvisioning.c",
        "EicOpsImpl.cc",
    ],
    export_include_dirs: [
        "libeic",
    ],
    cflags: [
        "-DEIC_COMPILATION",
        "-Wall",
        "-Wextra",
        "-DEIC_DEBUG",
        // Allow using C2x extensions such as omitting parameter names
        "-Wno-c2x-extensions",
    ],
    shared_libs: [
        "libbase",
        "libcrypto",
    ],
    static_libs: [
        "android.hardware.identity-support-lib",
    ],
}

cc_binary {
    name: "android.hardware.identity-service.example",
    relative_install_path: "hw",
    init_rc: ["identity-default.rc"],
    vintf_fragments: ["identity-default.xml"],
    vendor: true,
    defaults: [
        "identity_use_latest_hal_aidl_ndk_static",
        "keymint_use_latest_hal_aidl_ndk_static",
    ],
    cflags: [
        "-Wall",
        "-Wextra",
        "-g",
    ],
    shared_libs: [
        "liblog",
        "libcrypto",
        "libbinder_ndk",
        "libkeymaster_messages",
    ],
    static_libs: [
        "libbase",
        "libcppbor_external",
        "libcppcose_rkp",
        "libutils",
        "libsoft_attestation_cert",
        "libkeymaster_portable",
        "libsoft_attestation_cert",
        "libpuresoftkeymasterdevice",
        "android.hardware.identity-support-lib",
        "android.hardware.keymaster-V3-ndk",
        "android.hardware.identity-libeic-hal-common",
        "android.hardware.identity-libeic-library",
        "android.hardware.security.rkp-V3-ndk",
    ],
    srcs: [
        "service.cpp",
        "FakeSecureHardwareProxy.cpp",
    ],
    required: [
        "android.hardware.identity_credential.xml",
    ],
}

cc_test {
    name: "libeic_test",
    srcs: [
        "EicTests.cpp",
        "FakeSecureHardwareProxy.cpp",
    ],
    cflags: [
        "-Wall",
        "-Wextra",
        "-g",
        "-DEIC_DEBUG",
    ],
    local_include_dirs: [
        "common",
    ],
    shared_libs: [
        "liblog",
        "libcrypto",
        "libkeymaster_messages",
    ],
    static_libs: [
        "libbase",
        "libcppbor_external",
        "libcppcose_rkp",
        "libutils",
        "libsoft_attestation_cert",
        "libkeymaster_portable",
        "libsoft_attestation_cert",
        "libpuresoftkeymasterdevice",
        "android.hardware.identity-support-lib",
        "android.hardware.identity-libeic-library",
    ],
    test_suites: [
        "general-tests",
    ],
}

prebuilt_etc {
    name: "android.hardware.identity_credential.xml",
    sub_dir: "permissions",
    vendor: true,
    src: "android.hardware.identity_credential.xml",
}
