# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("@fbsource//tools/build_defs:platform_defs.bzl", "ANDROID", "APPLE", "CXX", "FBCODE", "WINDOWS")
load("//tools/build_defs/oss:yoga_defs.bzl", "JNI_TARGET", "YOGA_ROOTS", "subdir_glob", "yoga_cxx_library", "yoga_prebuilt_cxx_library")

yoga_prebuilt_cxx_library(
    name = "ndklog",
    exported_platform_linker_flags = [
        (
            "^android.*",
            ["-llog"],
        ),
    ],
    header_only = True,
    platforms = (ANDROID, APPLE, CXX, FBCODE, WINDOWS),
    visibility = YOGA_ROOTS,
)

yoga_cxx_library(
    name = "fbjni",
    srcs = glob(["src/main/cpp/**/*.cpp"]),
    header_namespace = "",
    exported_headers = subdir_glob([("src/main/cpp/include", "**/*.h")]),
    compiler_flags = [
        "-DLOG_TAG=\"libfb\"",
        "-DDISABLE_CPUCAP",
        "-DDISABLE_XPLAT",
        "-DHAVE_POSIX_CLOCKS",
        "-fno-omit-frame-pointer",
        "-fexceptions",
        "-frtti",
        "-Wall",
        "-Werror",
        "-Wno-unused-parameter",
        "-Wno-unused-variable",
        "-std=c++11",
    ],
    platforms = (CXX, ANDROID),
    soname = "libfbjni.$(ext)",
    visibility = ["PUBLIC"],
    deps = [
        ":ndklog",
        JNI_TARGET,
    ],
)
