# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.

PRODUCT_NAME = "ceftests"
PKG_NAME = "//tests/{}".format(PRODUCT_NAME)

# Allow access from the parent package only.
package(default_visibility = [
    "{}:__pkg__".format(PKG_NAME),
])

load("//bazel:copy_filegroups.bzl", "copy_filegroups")

# Copy resources into the current project.
copy_target = "{}_resources".format(PRODUCT_NAME)
copy_filegroups(
    name = copy_target,
    filegroups = [
        "{}:Resources".format(PKG_NAME),
    ],
    remove_prefixes = [
        "tests/{}/resources".format(PRODUCT_NAME),
    ],
    add_prefix = "ceftests_files",
)

#
# Windows DLL target (sandbox enabled).
#

load("//bazel/win:exe_helpers.bzl", "declare_dll")

declare_dll(
    name = PRODUCT_NAME,
    srcs = [
        "{}:SrcsWin".format(PKG_NAME),
        "//tests/shared:SrcsWin",
    ],
    deps = [
        "//tests/gtest",
    ],
    rc_file = "{}.rc".format(PRODUCT_NAME),
    resources_srcs = [
        "{}.ico".format(PRODUCT_NAME),
        "small.ico",
        "//tests/shared:Resources",
    ],
    resources_deps = [
        "{}:ResourceH".format(PKG_NAME),
    ],
    data = [
        ":{}".format(copy_target),
    ],
    local_defines = [
        # Enable use of the bootstrap executable.
        "CEF_USE_BOOTSTRAP",
    ],
    # Console application.
    bootstrap_suffix = 'c',
)

#
# Windows executable target (sandbox disabled).
#

# load("//bazel/win:exe_helpers.bzl", "declare_exe")
#
# declare_exe(
#     name = PRODUCT_NAME,
#     srcs = [
#         "{}:SrcsWin".format(PKG_NAME),
#         "//tests/shared:SrcsWin",
#     ],
#     deps = [
#         "//tests/gtest",
#     ],
#     rc_file = "{}.rc".format(PRODUCT_NAME),
#     manifest_srcs = [
#         "compatibility.manifest",
#         "{}.exe.manifest".format(PRODUCT_NAME),
#     ],
#     resources_srcs = [
#         "{}.ico".format(PRODUCT_NAME),
#         "small.ico",
#         "//tests/shared:Resources",
#     ],
#     resources_deps = [
#         "{}:ResourceH".format(PKG_NAME),
#     ],
#     linkopts = [
#         "/SUBSYSTEM:CONSOLE",
#     ],
#     data = [
#         ":{}".format(copy_target),
#     ],
# )
