//
// Copyright (C) 2015 The Android Open-Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

cc_binary {
    name: "android.hardware.keymaster@3.0-service.trusty",
    defaults: ["hidl_defaults"],
    relative_install_path: "hw",
    vendor: true,
    init_rc: ["3.0/android.hardware.keymaster@3.0-service.trusty.rc"],
    srcs: [
        "3.0/service.cpp",
        "3.0/TrustyKeymaster3Device.cpp",
        "ipc/trusty_keymaster_ipc.cpp",
        "TrustyKeymaster.cpp",
    ],

    local_include_dirs: ["include"],

    shared_libs: [
        "liblog",
        "libcutils",
        "libdl",
        "libbase",
        "libutils",
        "libhardware",
        "libhidlbase",
        "libtrusty",
        "libkeymaster_messages",
        "libkeymaster3device",
        "android.hardware.keymaster@3.0",
    ],
}

cc_binary {
    name: "android.hardware.keymaster@4.0-service.trusty",
    defaults: ["hidl_defaults"],
    relative_install_path: "hw",
    vendor: true,
    init_rc: ["4.0/android.hardware.keymaster@4.0-service.trusty.rc"],
    srcs: [
        "4.0/service.cpp",
        "4.0/TrustyKeymaster4Device.cpp",
        "ipc/trusty_keymaster_ipc.cpp",
        "TrustyKeymaster.cpp",
    ],

    local_include_dirs: ["include"],

    shared_libs: [
        "liblog",
        "libcutils",
        "libdl",
        "libbase",
        "libutils",
        "libhardware",
        "libhidlbase",
        "libtrusty",
        "libkeymaster_messages",
        "libkeymaster4",
        "android.hardware.keymaster@4.0",
    ],

    vintf_fragments: ["4.0/android.hardware.keymaster@4.0-service.trusty.xml"],
}

cc_binary {
    name: "android.hardware.security.keymint-service.trusty",
    relative_install_path: "hw",
    init_rc: ["keymint/android.hardware.security.keymint-service.trusty.rc"],
    vintf_fragments: [
        "keymint/android.hardware.security.keymint-service.trusty.xml",
    ],
    vendor: true,
    cflags: [
        "-Wall",
        "-Wextra",
    ],
    local_include_dirs: [
        "include",
    ],
    srcs: [
        "TrustyKeymaster.cpp",
        "ipc/trusty_keymaster_ipc.cpp",
        "keymint/TrustyKeyMintDevice.cpp",
        "keymint/TrustyKeyMintOperation.cpp",
        "keymint/TrustyRemotelyProvisionedComponentDevice.cpp",
        "keymint/TrustySecureClock.cpp",
        "keymint/TrustySharedSecret.cpp",
        "keymint/service.cpp",
    ],
    defaults: [
        "keymint_use_latest_hal_aidl_ndk_shared",
    ],
    shared_libs: [
        "android.hardware.security.rkp-V3-ndk",
        "android.hardware.security.secureclock-V1-ndk",
        "android.hardware.security.sharedsecret-V1-ndk",
        "lib_android_keymaster_keymint_utils",
        "libbase",
        "libbinder_ndk",
        "libhardware",
        "libkeymaster_messages",
        "libkeymint",
        "liblog",
        "libtrusty",
        "libutils",
    ],
    required: [
        "android.hardware.hardware_keystore.xml",
    ],
}

prebuilt_etc {
    name: "keymaster_soft_attestation_keys.xml",
    vendor: true,
    src: "set_attestation_key/keymaster_soft_attestation_keys.xml",
}

cc_library {
    name: "libtrusty_ipc",
    vendor: true,
    srcs: ["ipc/trusty_keymaster_ipc.cpp"],
    local_include_dirs: ["include"],
    shared_libs: [
        "libc",
        "libcrypto",
        "liblog",
        "libtrusty",
        "libhardware",
        "libkeymaster_messages",
        "libutils",
        "libxml2",
    ],
    export_include_dirs: ["include"],
    cflags: [
        "-Wall",
        "-Werror",
    ],
}

cc_binary {
    name: "trusty_keymaster_set_attestation_key",
    vendor: true,

    srcs: [
        "set_attestation_key/set_attestation_key.cpp",
        "ipc/trusty_keymaster_ipc.cpp",
    ],

    local_include_dirs: ["include"],

    shared_libs: [
        "libc",
        "libcrypto",
        "liblog",
        "libtrusty",
        "libhardware",
        "libkeymaster_messages",
        "libutils",
        "libxml2",
    ],
    cflags: [
        "-Wall",
        "-Werror",
    ],
}

cc_binary {
    name: "trusty_keymaster_set_attestation_ids",
    vendor: true,

    srcs: [
        "set_attestation_ids/set_attestation_ids.cpp",
        "ipc/trusty_keymaster_ipc.cpp",
    ],

    local_include_dirs: ["include"],

    shared_libs: [
        "libbase",
        "libc",
        "libcrypto",
        "liblog",
        "libtrusty",
        "libhardware",
        "libkeymaster_messages",
        "libutils",
    ],
    cflags: [
        "-Wall",
        "-Werror",
    ],
}

prebuilt_etc {
    name: "rkp_uds_cert_test.xml",
    vendor: true,
    src: "set_uds_certs/rkp_uds_cert_test.xml",
}

cc_binary {
    name: "trusty_rkp_set_uds_cert",
    vendor: true,

    srcs: [
        "set_uds_certs/set_uds_certificates.cpp",
        "ipc/trusty_keymaster_ipc.cpp",
    ],

    local_include_dirs: ["include"],

    shared_libs: [
        "libc",
        "libcrypto",
        "liblog",
        "libtrusty",
        "libhardware",
        "libkeymaster_messages",
        "libutils",
        "libxml2",
    ],
    cflags: [
        "-Wall",
        "-Werror",
    ],
}
