# 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: Version configuration for Google Japanese Input

load("@build_bazel_rules_apple//apple:versioning.bzl", "apple_bundle_version")
load("//bazel:stubs.bzl", "bzl_library")
load("//data/version:mozc_version_template.bzl", "DEFAULT_BUILD_LABEL_MACOS")

exports_files(
    ["mozc_version_template.bzl"],
    visibility = [
        "//base:__pkg__",
        "//data_manager:__subpackages__",
        "//tools:__subpackages__",
        "//tools/release:__pkg__",
    ],
)

bzl_library(
    name = "mozc_version_template_bzl",
    srcs = ["mozc_version_template.bzl"],
    test_size = "small",
    visibility = ["//visibility:private"],
)

# The version can be specifyed by the --embed_label flag.
# e.g. bazel build --embed_label="2.32.5994.101" package
# The default version is specified by DEFAULT_BUILD_LABEL_MACOS in mozc_version_template.bzl.
# LINT.IfChange
apple_bundle_version(
    name = "version_macos",
    build_label_pattern = "{version}.{revision}",  # e.g. 2.32.5994.101
    build_version = "{version}.{revision}",  # e.g. 2.32.5994.101
    capture_groups = {
        "version": "\\d+\\.\\d+\\.\\d+",  # e.g. 2.32.5994
        "revision": "\\d+",  # e.g. 101
    },
    fallback_build_label = DEFAULT_BUILD_LABEL_MACOS,  # e.g. 2.32.5994.101
    short_version_string = "{version}",  # e.g. 2.32.5994
    visibility = ["//:__subpackages__"],
)
# LINT.ThenChange(//data/version/mozc_version_template.bzl)
