// Copyright (C) 2016 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.

// Headers module is in frameworks/av/Android.bp because modules are not allowed
// to refer to headers in parent directories and the headers live in
// frameworks/av/include.

package {
    default_team: "trendy_team_camera_framework",
    default_applicable_licenses: ["frameworks_av_camera_ndk_license"],
}

// Added automatically by a large-scale-change that took the approach of
// 'apply every license found to every target'. While this makes sure we respect
// every license restriction, it may not be entirely correct.
//
// e.g. GPL in an MIT project might only apply to the contrib/ directory.
//
// Please consider splitting the single license below into multiple licenses,
// taking care not to lose any license_kind information, and overriding the
// default license using the 'licenses: [...]' property on targets as needed.
//
// For unused files, consider creating a 'fileGroup' with "//visibility:private"
// to attach the license to, and including a comment whether the files may be
// used in the current project.
// See: http://go/android-license-faq
license {
    name: "frameworks_av_camera_ndk_license",
    visibility: [":__subpackages__"],
    license_kinds: [
        "SPDX-license-identifier-Apache-2.0",
        "SPDX-license-identifier-MIT",
        "SPDX-license-identifier-Unicode-DFS",
    ],
    license_text: [
        "NOTICE",
    ],
}

ndk_library {
    name: "libcamera2ndk",
    symbol_file: "libcamera2ndk.map.txt",
    first_version: "24",
    unversioned_until: "current",
}

ndk_headers {
    name: "libcamera2ndk_headers",
    from: "include/camera",
    to: "camera",
    srcs: ["include/camera/**/*.h"],
    license: "NOTICE",
}

cc_library_shared {
    name: "libcamera2ndk",
    srcs: [
        "NdkCameraCaptureSession.cpp",
        "NdkCameraDevice.cpp",
        "NdkCameraManager.cpp",
        "NdkCameraMetadata.cpp",
        "NdkCaptureRequest.cpp",
        "impl/ACameraCaptureSession.cpp",
        "impl/ACameraDevice.cpp",
        "impl/ACameraManager.cpp",
        "impl/ACameraMetadata.cpp",
    ],
    shared_libs: [
        "android.companion.virtual.virtualdevice_aidl-cpp",
        "android.companion.virtualdevice.flags-aconfig-cc",
        "camera_platform_flags_c_lib",
        "framework-permission-aidl-cpp",
        "libandroid_runtime",
        "libbinder",
        "libcamera_client",
        "libcamera_metadata",
        "libcutils",
        "libgui",
        "liblog",
        "libmediandk",
        "libnativewindow",
        "libstagefright_foundation",
        "libutils",
    ],
    header_libs: [
        "jni_headers",
    ],
    cflags: [
        "-DEXPORT=__attribute__((visibility(\"default\")))",
        "-Wall",
        "-Werror",
        "-Wextra",
        "-fvisibility=hidden",
    ],
    // TODO: jchowdhary@, use header_libs instead b/131165718
    include_dirs: [
        "system/media/private/camera/include",
    ],
    export_include_dirs: ["include"],
    export_shared_lib_headers: [
        "libnativewindow",
    ],
    version_script: "libcamera2ndk.map.txt",
}

cc_library_shared {
    name: "libcamera2ndk_vendor",
    cpp_std: "gnu++17",
    vendor: true,
    srcs: [
        "NdkCameraCaptureSession.cpp",
        "NdkCameraDevice.cpp",
        "NdkCameraManager.cpp",
        "NdkCameraMetadata.cpp",
        "NdkCaptureRequest.cpp",
        "impl/ACameraCaptureSession.cpp",
        "impl/ACameraMetadata.cpp",
        "ndk_vendor/impl/ACameraDevice.cpp",
        "ndk_vendor/impl/ACameraManager.cpp",
        "ndk_vendor/impl/utils.cpp",
    ],

    export_include_dirs: ["include"],
    export_shared_lib_headers: [
        "libcutils",
    ],
    local_include_dirs: [
        ".",
        "impl",
        "include",
    ],
    cflags: [
        "-DEXPORT=__attribute__((visibility(\"default\")))",
        "-D__ANDROID_VNDK__",
        "-fvisibility=hidden",
    ],

    shared_libs: [
        "android.frameworks.cameraservice.common-V1-ndk",
        "android.frameworks.cameraservice.device-V3-ndk",
        "android.frameworks.cameraservice.service-V3-ndk",
        "libbinder_ndk",
        "libcamera_metadata",
        "libcutils",
        "libfmq",
        "libhardware",
        "libhidlbase",
        "liblog",
        "libmediandk",
        "libnativewindow",
        "libstagefright_foundation",
        "libutils",
    ],
    static_libs: [
        "android.hardware.camera.common@1.0-helper",
        "libaidlcommonsupport",
        "libarect",
    ],
    // TODO: jchowdhary@, use header_libs instead b/131165718
    include_dirs: [
        "system/media/private/camera/include",
    ],
}

cc_test {
    name: "ACameraNdkVendorTest",
    vendor: true,
    srcs: [
        "ndk_vendor/tests/ACameraManagerTest.cpp",
        "ndk_vendor/tests/AImageReaderVendorTest.cpp",
    ],
    shared_libs: [
        "libcamera2ndk_vendor",
        "libcamera_metadata",
        "libcutils",
        "libhidlbase",
        "liblog",
        "libmediandk",
        "libnativewindow",
        "libui",
        "libutils",
    ],
    static_libs: [
        "android.hardware.camera.common@1.0-helper",
    ],
    cflags: [
        "-D__ANDROID_VNDK__",
    ],
}
