# Copyright 2010-2021, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
#     * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#     * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Description:
#   Contains tools which are required to build mozc.

load("@rules_python//python:defs.bzl", "py_test")
load(
    "//:build_defs.bzl",
    "mozc_py_binary",
    "mozc_py_library",
)
load("//bazel:stubs.bzl", "bzl_library")

package(default_visibility = ["//:__subpackages__"])

mozc_py_binary(
    name = "replace_macros",
    srcs = ["replace_macros.py"],
)

# TODO(noriyukit): Stop using //testing/pybase to support tests on iOS.
py_test(
    name = "replace_macros_test",
    size = "small",
    srcs = ["replace_macros_test.py"],
    tags = ["manual"],
    deps = [
        ":replace_macros.testonly_lib",
        "//testing/pybase",  # NOLINT(mozc/testing): TODO
    ],
)

mozc_py_library(
    name = "code_generator_util",
    srcs = ["code_generator_util.py"],
)

# TODO(noriyukit): Stop using //testing/pybase to support tests on iOS.
py_test(
    name = "code_generator_util_test",
    size = "small",
    srcs = ["code_generator_util_test.py"],
    tags = ["manual"],
    deps = [
        ":code_generator_util",
        "//testing/pybase",  # NOLINT(mozc/testing): TODO
    ],
)

mozc_py_library(
    name = "mozc_version_lib",
    srcs = ["mozc_version.py"],
)

mozc_py_binary(
    name = "mozc_version",
    srcs = ["mozc_version.py"],
)

# TODO(noriyukit): Stop using //testing/pybase to support tests on iOS.
py_test(
    name = "mozc_version_test",
    size = "small",
    srcs = ["mozc_version_test.py"],
    tags = ["manual"],
    deps = [
        ":mozc_version_lib",
        "//testing/pybase",  # NOLINT(mozc/testing): TODO
    ],
)

mozc_py_binary(
    name = "replace_version",
    srcs = ["replace_version.py"],
    deps = [":mozc_version_lib"],
)

mozc_py_library(
    name = "util",
    srcs = ["util.py"],
)

mozc_py_library(
    name = "zlib_util_lib",
    srcs = ["zlib_util.py"],
)

mozc_py_binary(
    name = "zlib_util",
    srcs = ["zlib_util.py"],
)

mozc_py_binary(
    name = "embed_pathname",
    srcs = ["embed_pathname.py"],
)

mozc_py_binary(
    name = "embed_file",
    srcs = ["embed_file.py"],
)

mozc_py_library(
    name = "serialized_string_array_builder",
    srcs = ["serialized_string_array_builder.py"],
)

mozc_py_library(
    name = "tweak_data",
    srcs = ["tweak_data.py"],
)

mozc_py_binary(
    name = "tweak_info_plist",
    srcs = ["tweak_info_plist.py"],
    deps = [
        ":mozc_version_lib",
        ":tweak_data",
    ],
)

mozc_py_binary(
    name = "tweak_info_plist_strings",
    srcs = ["tweak_info_plist_strings.py"],
    deps = [
        ":tweak_data",
    ],
)

mozc_py_binary(
    name = "tweak_macinstaller_script",
    srcs = ["tweak_macinstaller_script.py"],
    deps = [":mozc_version_lib"],
)

mozc_py_binary(
    name = "tweak_pkgproj",
    srcs = ["tweak_pkgproj.py"],
    deps = [":mozc_version_lib"],
)

mozc_py_binary(
    name = "build_diskimage_mac",
    srcs = ["build_diskimage_mac.py"],
)

bzl_library(
    name = "embed_file_bzl",
    srcs = ["embed_file.bzl"],
    test_size = "small",
    deps = [
        "//bazel:run_build_tool_bzl",
    ],
)

exports_files([
    "mozc_win32_resource_template.rc",
])

mozc_py_binary(
    name = "gen_win32_resource_header",
    srcs = ["gen_win32_resource_header.py"],
    deps = [":mozc_version_lib"],
)

mozc_py_library(
    name = "vs_util",
    srcs = ["vs_util.py"],
)
