From bc546b239bccff494773104e108ba08fcff40d5b Mon Sep 17 00:00:00 2001 From: Hiroyuki Komatsu Date: Mon, 9 Dec 2024 10:25:27 +0000 Subject: [PATCH] Update a part of PR#1109 as a preparation to merge that PR. * https://github.com/google/mozc/pull/1109 This change is a preparation to merge PR#1109. The difference from PR#1109 is the implementation of `mozc_win32_cc_prod_binary` and `mozc_cc_win32_library`. * mozc_win32_cc_prod_binary: In this change, this is a wrapper of `mozc_win_build_target` migrated from `trasition.bzl` to `build_defs.bzl`. * mozc_cc_win32_library: In this change, nothing is changed. PiperOrigin-RevId: 704201709 --- src/build_defs.bzl | 175 +++++++++++++++++++++++++ src/gui/tool/BUILD.bazel | 19 +++ src/renderer/win32/BUILD.bazel | 9 +- src/server/BUILD.bazel | 18 +++ src/win32/broker/BUILD.bazel | 10 +- src/win32/cache_service/BUILD.bazel | 10 +- src/win32/custom_action/BUILD.bazel | 11 +- src/win32/installer/BUILD.bazel | 104 +++------------ src/win32/installer/build_installer.py | 3 + src/win32/installer/transition.bzl | 161 ----------------------- src/win32/tip/BUILD.bazel | 51 +++++-- 11 files changed, 305 insertions(+), 266 deletions(-) delete mode 100644 src/win32/installer/transition.bzl diff --git a/src/build_defs.bzl b/src/build_defs.bzl index 22055fb44..da63eecaf 100644 --- a/src/build_defs.bzl +++ b/src/build_defs.bzl @@ -46,6 +46,7 @@ load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application", "macos_bu load("@windows_sdk//:windows_sdk_rules.bzl", "windows_resource") load( "//:config.bzl", + "BAZEL_TOOLS_PREFIX", "BRANDING", "MACOS_BUNDLE_ID_PREFIX", "MACOS_MIN_OS_VER", @@ -203,6 +204,180 @@ register_extension_info( label_regex_for_dep = "{extension_name}", ) +def _win_executable_transition_impl( + settings, # @unused + attr): + features = [] + if attr.static_crt: + features = ["static_link_msvcrt"] + return { + "//command_line_option:features": features, + "//command_line_option:cpu": attr.cpu, + } + +_win_executable_transition = transition( + implementation = _win_executable_transition_impl, + inputs = [], + outputs = [ + "//command_line_option:features", + "//command_line_option:cpu", + ], +) + +def _mozc_win_build_rule_impl(ctx): + input_file = ctx.file.target + output = ctx.actions.declare_file( + ctx.label.name + "." + input_file.extension, + ) + if input_file.path == output.path: + fail("input=%d and output=%d are the same." % (input_file.path, output.path)) + + # Create a symlink as we do not need to create an actual copy. + ctx.actions.symlink( + output = output, + target_file = input_file, + is_executable = True, + ) + return [DefaultInfo( + files = depset([output]), + executable = output, + )] + +# The follwoing CPU values are mentioned in https://bazel.build/configure/windows#build_cpp +CPU = struct( + ARM64 = "arm64_windows", # aarch64 (64-bit) environment + X64 = "x64_windows", # x86-64 (64-bit) environment + X86 = "x64_x86_windows", # x86 (32-bit) environment +) + +_mozc_win_build_rule = rule( + implementation = _mozc_win_build_rule_impl, + cfg = _win_executable_transition, + attrs = { + "_allowlist_function_transition": attr.label( + default = BAZEL_TOOLS_PREFIX + "//tools/allowlists/function_transition_allowlist", + ), + "target": attr.label( + allow_single_file = [".dll", ".exe"], + doc = "the actual Bazel target to be built.", + mandatory = True, + ), + "static_crt": attr.bool(), + "cpu": attr.string(), + }, +) + +# Define a transition target with the given build target with the given build configurations. +# +# For instance, the following code creates a target "my_target" with setting "cpu" as "x64_windows" +# and setting "static_link_msvcrt" feature. +# +# mozc_win_build_rule( +# name = "my_target", +# cpu = CPU.X64, +# static_crt = True, +# target = "//bath/to/target:my_target", +# ) +# +# See the following page for the details on transition. +# https://bazel.build/rules/lib/builtins/transition +def mozc_win_build_target( + name, + target, + cpu = CPU.X64, + static_crt = False, + target_compatible_with = [], + tags = [], + **kwargs): + """Define a transition target with the given build target with the given build configurations. + + The following code creates a target "my_target" with setting "cpu" as "x64_windows" and setting + "static_link_msvcrt" feature. + + mozc_win_build_target( + name = "my_target", + cpu = CPU.X64, + static_crt = True, + target = "//bath/to/target:my_target", + ) + + Args: + name: name of the target. + target: the actual Bazel target to be built with the specified configurations. + cpu: CPU type of the target. + static_crt: True if the target should be built with static CRT. + target_compatible_with: optional. Visibility for the unit test target. + tags: optional. Tags for both the library and unit test targets. + **kwargs: other arguments passed to mozc_objc_library. + """ + mandatory_target_compatible_with = [ + "@platforms//os:windows", + ] + for item in mandatory_target_compatible_with: + if item not in target_compatible_with: + target_compatible_with.append(item) + + mandatory_tags = MOZC_TAGS.WIN_ONLY + for item in mandatory_tags: + if item not in tags: + tags.append(item) + + _mozc_win_build_rule( + name = name, + target = target, + cpu = cpu, + static_crt = static_crt, + target_compatible_with = target_compatible_with, + tags = tags, + **kwargs + ) + +def mozc_win32_cc_prod_binary( + name, + executable_name_map = {}, # @unused + srcs = [], # @unused + deps = [], # @unused + linkopts = [], # @unused + cpu = CPU.X64, + static_crt = False, + tags = MOZC_TAGS.WIN_ONLY, + win_def_file = None, # @unused + target_compatible_with = ["@platforms//os:windows"], + visibility = ["//visibility:public"], # @unused + **kwargs): + """A rule to build production binaries for Windows. + + This wraps mozc_cc_binary so that you can specify the target CPU + architecture and CRT linkage type in a declarative manner with also building + a debug symbol file (*.pdb). + + Implicit output targets: + name.pdb: A debug symbol file. + + Args: + name: name of the target. + executable_name_map: a map from the branding name to the executable name. + srcs: .cc files to build the executable. + deps: deps to build the executable. + linkopts: linker options to build the executable. + cpu: optional. The target CPU architecture. + static_crt: optional. True if the target should be built with static CRT. + tags: optional. Tags for both the library and unit test targets. + win_def_file: optional. win32 def file to define exported functions. + target_compatible_with: optional. Defines target platforms. + visibility: optional. The visibility of the target. + **kwargs: other arguments passed to mozc_cc_binary. + """ + mozc_win_build_target( + name = name, + target = "//data/prod:prod_binary", + cpu = cpu, + static_crt = static_crt, + target_compatible_with = target_compatible_with, + tags = tags, + **kwargs + ) + def mozc_cc_win32_library( name, srcs = [], diff --git a/src/gui/tool/BUILD.bazel b/src/gui/tool/BUILD.bazel index f1fc5c3dc..0ccf15e50 100644 --- a/src/gui/tool/BUILD.bazel +++ b/src/gui/tool/BUILD.bazel @@ -32,6 +32,7 @@ load( "MOZC_TAGS", "mozc_cc_library", "mozc_select", + "mozc_win32_cc_prod_binary", "mozc_win32_resource_from_template", ) load("//:config.bzl", "BRANDING") @@ -132,6 +133,24 @@ mozc_cc_qt_binary( ), ) +mozc_win32_cc_prod_binary( + name = "mozc_tool_win", + cpu = "x64_windows", + executable_name_map = { + "Mozc": "mozc_tool.exe", + "GoogleJapaneseInput": "GoogleIMEJaTool.exe", + }, + static_crt = False, + tags = MOZC_TAGS.WIN_ONLY, + target_compatible_with = ["@platforms//os:windows"], + visibility = ["//:__subpackages__"], + deps = [ + ":mozc_tool_main_lib", + ":mozc_tool_win32_resource", + "@qt_win", + ], +) + mozc_macos_qt_application( name = "mozc_tool_macos", bundle_name = "MozcTool", diff --git a/src/renderer/win32/BUILD.bazel b/src/renderer/win32/BUILD.bazel index eb2a1c875..f27116551 100644 --- a/src/renderer/win32/BUILD.bazel +++ b/src/renderer/win32/BUILD.bazel @@ -35,6 +35,7 @@ load( "mozc_cc_binary", "mozc_cc_library", "mozc_cc_test", + "mozc_win32_cc_prod_binary", "mozc_win32_resource_from_template", ) @@ -44,9 +45,15 @@ package( features = ["gdi"], ) -mozc_cc_binary( +mozc_win32_cc_prod_binary( name = "win32_renderer_main", srcs = ["win32_renderer_main.cc"], + cpu = "x64_windows", + executable_name_map = { + "Mozc": "mozc_renderer.exe", + "GoogleJapaneseInput": "GoogleIMEJaRenderer.exe", + }, + static_crt = False, tags = MOZC_TAGS.WIN_ONLY, target_compatible_with = ["@platforms//os:windows"], visibility = ["//win32/installer:__subpackages__"], # Scheuklappen: keep diff --git a/src/server/BUILD.bazel b/src/server/BUILD.bazel index 2cdd43b19..50cb9acca 100644 --- a/src/server/BUILD.bazel +++ b/src/server/BUILD.bazel @@ -32,10 +32,12 @@ load( "//:build_defs.bzl", + "MOZC_TAGS", "mozc_cc_binary", "mozc_cc_library", "mozc_macos_application", "mozc_select", + "mozc_win32_cc_prod_binary", "mozc_win32_resource_from_template", ) load( @@ -55,6 +57,22 @@ mozc_cc_binary( ), ) +mozc_win32_cc_prod_binary( + name = "mozc_server_win", + cpu = "x64_windows", + executable_name_map = { + "Mozc": "mozc_server.exe", + "GoogleJapaneseInput": "GoogleIMEJaConverter.exe", + }, + static_crt = False, + tags = MOZC_TAGS.WIN_ONLY, + target_compatible_with = ["@platforms//os:windows"], + deps = [ + ":mozc_server_lib", + ":mozc_server_resources", + ], +) + mozc_win32_resource_from_template( name = "mozc_server_resources", src = "mozc_server.rc", diff --git a/src/win32/broker/BUILD.bazel b/src/win32/broker/BUILD.bazel index 88c068420..e8cc03a2a 100644 --- a/src/win32/broker/BUILD.bazel +++ b/src/win32/broker/BUILD.bazel @@ -32,8 +32,8 @@ load( "//:build_defs.bzl", "MOZC_TAGS", - "mozc_cc_binary", "mozc_cc_library", + "mozc_win32_cc_prod_binary", "mozc_win32_resource_from_template", ) @@ -41,9 +41,15 @@ package( default_visibility = ["//visibility:private"], ) -mozc_cc_binary( +mozc_win32_cc_prod_binary( name = "mozc_broker_main", srcs = ["mozc_broker_main.cc"], + cpu = "x64_windows", + executable_name_map = { + "Mozc": "mozc_broker.exe", + "GoogleJapaneseInput": "GoogleIMEJaBroker.exe", + }, + static_crt = False, tags = MOZC_TAGS.WIN_ONLY, target_compatible_with = ["@platforms//os:windows"], visibility = ["//win32/installer:__subpackages__"], # Scheuklappen: keep diff --git a/src/win32/cache_service/BUILD.bazel b/src/win32/cache_service/BUILD.bazel index 602518ffc..1241c0f42 100644 --- a/src/win32/cache_service/BUILD.bazel +++ b/src/win32/cache_service/BUILD.bazel @@ -35,16 +35,22 @@ load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") load( "//:build_defs.bzl", "MOZC_TAGS", - "mozc_cc_binary", "mozc_cc_library", + "mozc_win32_cc_prod_binary", "mozc_win32_resource_from_template", ) package(default_visibility = ["//:__subpackages__"]) -mozc_cc_binary( +mozc_win32_cc_prod_binary( name = "mozc_cache_service", srcs = ["mozc_cache_service.cc"], + cpu = "x64_windows", + executable_name_map = { + "Mozc": "mozc_cache_service.exe", + "GoogleJapaneseInput": "GoogleIMEJaCacheService.exe", + }, + static_crt = False, tags = MOZC_TAGS.WIN_ONLY, target_compatible_with = ["@platforms//os:windows"], deps = [ diff --git a/src/win32/custom_action/BUILD.bazel b/src/win32/custom_action/BUILD.bazel index d3182bb98..b17fbd488 100644 --- a/src/win32/custom_action/BUILD.bazel +++ b/src/win32/custom_action/BUILD.bazel @@ -30,18 +30,23 @@ load( "//:build_defs.bzl", "MOZC_TAGS", - "mozc_cc_binary", + "mozc_win32_cc_prod_binary", "mozc_win32_resource_from_template", ) -mozc_cc_binary( +mozc_win32_cc_prod_binary( name = "custom_action", srcs = [ "custom_action.cc", "custom_action.h", "resource.h", ], - linkshared = True, + cpu = "x64_windows", + executable_name_map = { + "Mozc": "mozc_installer_helper.dll", + "GoogleJapaneseInput": "GoogleIMEJaInstallerHelper.dll", + }, + static_crt = True, tags = MOZC_TAGS.WIN_ONLY, target_compatible_with = ["@platforms//os:windows"], visibility = ["//win32/installer:__subpackages__"], # Scheuklappen: keep diff --git a/src/win32/installer/BUILD.bazel b/src/win32/installer/BUILD.bazel index bb1231555..925f6ada1 100644 --- a/src/win32/installer/BUILD.bazel +++ b/src/win32/installer/BUILD.bazel @@ -29,9 +29,8 @@ # Build rules for the Windows installer. -load("//:build_defs.bzl", "MOZC_TAGS", "mozc_py_binary") +load("//:build_defs.bzl", "mozc_py_binary") load("//:config.bzl", "BRANDING") -load(":transition.bzl", "mozc_win_build_target") package(default_visibility = ["//visibility:private"]) @@ -39,73 +38,6 @@ _TARGET_COMPATIBLE_WITH = [ "@platforms//os:windows", ] -mozc_win_build_target( - name = "mozc_tool", - cpu = "x64_windows", - tags = MOZC_TAGS.WIN_ONLY, - target = "//gui/tool:mozc_tool", - target_compatible_with = _TARGET_COMPATIBLE_WITH, -) - -mozc_win_build_target( - name = "mozc_renderer", - cpu = "x64_windows", - tags = MOZC_TAGS.WIN_ONLY, - target = "//renderer/win32:win32_renderer_main", - target_compatible_with = _TARGET_COMPATIBLE_WITH, -) - -mozc_win_build_target( - name = "mozc_server", - cpu = "x64_windows", - tags = MOZC_TAGS.WIN_ONLY, - target = "//server:mozc_server", - target_compatible_with = _TARGET_COMPATIBLE_WITH, -) - -mozc_win_build_target( - name = "mozc_broker", - cpu = "x64_windows", - tags = MOZC_TAGS.WIN_ONLY, - target = "//win32/broker:mozc_broker_main", - target_compatible_with = _TARGET_COMPATIBLE_WITH, -) - -mozc_win_build_target( - name = "mozc_cache_service", - cpu = "x64_windows", - tags = MOZC_TAGS.WIN_ONLY, - target = "//win32/cache_service:mozc_cache_service", - target_compatible_with = _TARGET_COMPATIBLE_WITH, -) - -mozc_win_build_target( - name = "mozc_tip32", - cpu = "x64_x86_windows", - static_crt = True, - tags = MOZC_TAGS.WIN_ONLY, - target = "//win32/tip:mozc_tip", - target_compatible_with = _TARGET_COMPATIBLE_WITH, -) - -mozc_win_build_target( - name = "mozc_tip64", - cpu = "x64_windows", - static_crt = True, - tags = MOZC_TAGS.WIN_ONLY, - target = "//win32/tip:mozc_tip", - target_compatible_with = _TARGET_COMPATIBLE_WITH, -) - -mozc_win_build_target( - name = "custom_action", - cpu = "x64_windows", - static_crt = True, - tags = MOZC_TAGS.WIN_ONLY, - target = "//win32/custom_action", - target_compatible_with = _TARGET_COMPATIBLE_WITH, -) - mozc_py_binary( name = "build_installer", srcs = ["build_installer.py"], @@ -136,14 +68,15 @@ _MSI_FILE = "Mozc64.msi" if BRANDING == "Mozc" else "GoogleJapaneseInput64.msi" genrule( name = "installer", srcs = [ - ":mozc_tool", - ":mozc_renderer", - ":mozc_server", - ":mozc_broker", - ":mozc_cache_service", - ":mozc_tip32", - ":mozc_tip64", - ":custom_action", + "//gui/tool:mozc_tool_win", + "//renderer/win32:win32_renderer_main", + "//server:mozc_server_win", + "//win32/broker:mozc_broker_main", + "//win32/cache_service:mozc_cache_service", + "//win32/tip:mozc_tip32", + "//win32/tip:mozc_tip64", + "//win32/tip:mozc_tip64.pdb", + "//win32/custom_action", _WXS_FILE, "//base:mozc_version_txt", "//data/images/win:product_icon.ico", @@ -156,14 +89,15 @@ genrule( "$(location :build_installer)", "--output=$@", "--version_file=$(location //base:mozc_version_txt)", - "--mozc_tool=$(location :mozc_tool)", - "--mozc_renderer=$(location :mozc_renderer)", - "--mozc_server=$(location :mozc_server)", - "--mozc_broker=$(location :mozc_broker)", - "--mozc_cache_service=$(location :mozc_cache_service)", - "--mozc_tip32=$(location :mozc_tip32)", - "--mozc_tip64=$(location :mozc_tip64)", - "--custom_action=$(location :custom_action)", + "--mozc_tool=$(location //gui/tool:mozc_tool_win)", + "--mozc_renderer=$(location //renderer/win32:win32_renderer_main)", + "--mozc_server=$(location //server:mozc_server_win)", + "--mozc_broker=$(location //win32/broker:mozc_broker_main)", + "--mozc_cache_service=$(location //win32/cache_service:mozc_cache_service)", + "--mozc_tip32=$(location //win32/tip:mozc_tip32)", + "--mozc_tip64=$(location //win32/tip:mozc_tip64)", + "--mozc_tip64_pdb=$(location //win32/tip:mozc_tip64.pdb)", + "--custom_action=$(location //win32/custom_action)", "--icon_path=$(location //data/images/win:product_icon.ico)", "--credit_file=$(location //data/installer:credits_en.html)", "--qt_core_dll=$(location @qt_win//:bin/Qt6Core.dll)", diff --git a/src/win32/installer/build_installer.py b/src/win32/installer/build_installer.py index 69d51b941..afd28e483 100644 --- a/src/win32/installer/build_installer.py +++ b/src/win32/installer/build_installer.py @@ -89,6 +89,8 @@ def run_wix4(args) -> None: mozc_tip32 = pathlib.Path(args.mozc_tip32).resolve() mozc_tip64 = pathlib.Path(args.mozc_tip64).resolve() mozc_tip64_pdb = mozc_tip64.with_suffix('.pdb') + if args.mozc_tip64_pdb: + mozc_tip64_pdb = pathlib.Path(args.mozc_tip64_pdb).resolve() mozc_broker = pathlib.Path(args.mozc_broker).resolve() mozc_server = pathlib.Path(args.mozc_server).resolve() mozc_cache_service = pathlib.Path(args.mozc_cache_service).resolve() @@ -159,6 +161,7 @@ def main(): parser.add_argument('--mozc_cache_service', type=str) parser.add_argument('--mozc_tip32', type=str) parser.add_argument('--mozc_tip64', type=str) + parser.add_argument('--mozc_tip64_pdb', type=str) parser.add_argument('--custom_action', type=str) parser.add_argument('--icon_path', type=str) parser.add_argument('--credit_file', type=str) diff --git a/src/win32/installer/transition.bzl b/src/win32/installer/transition.bzl deleted file mode 100644 index c4e32e70c..000000000 --- a/src/win32/installer/transition.bzl +++ /dev/null @@ -1,161 +0,0 @@ -# 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. - -"""Define a transition rules for Windows build.""" - -load("//:build_defs.bzl", "MOZC_TAGS") -load("//:config.bzl", "BAZEL_TOOLS_PREFIX") - -def _win_executable_transition_impl( - settings, # @unused - attr): - features = [] - if attr.static_crt: - features = ["static_link_msvcrt"] - return { - "//command_line_option:features": features, - "//command_line_option:cpu": attr.cpu, - } - -_win_executable_transition = transition( - implementation = _win_executable_transition_impl, - inputs = [], - outputs = [ - "//command_line_option:features", - "//command_line_option:cpu", - ], -) - -def _mozc_win_build_rule_impl(ctx): - input_file = ctx.file.target - output = ctx.actions.declare_file( - ctx.label.name + "." + input_file.extension, - ) - if input_file.path == output.path: - fail("input=%d and output=%d are the same." % (input_file.path, output.path)) - - # Create a symlink as we do not need to create an actual copy. - ctx.actions.symlink( - output = output, - target_file = input_file, - is_executable = True, - ) - return [DefaultInfo( - files = depset([output]), - executable = output, - )] - -# The follwoing CPU values are mentioned in https://bazel.build/configure/windows#build_cpp -CPU = struct( - ARM64 = "arm64_windows", # aarch64 (64-bit) environment - X64 = "x64_windows", # x86-64 (64-bit) environment - X86 = "x64_x86_windows", # x86 (32-bit) environment -) - -_mozc_win_build_rule = rule( - implementation = _mozc_win_build_rule_impl, - cfg = _win_executable_transition, - attrs = { - "_allowlist_function_transition": attr.label( - default = BAZEL_TOOLS_PREFIX + "//tools/allowlists/function_transition_allowlist", - ), - "target": attr.label( - allow_single_file = [".dll", ".exe"], - doc = "the actual Bazel target to be built.", - mandatory = True, - ), - "static_crt": attr.bool(), - "cpu": attr.string(), - }, -) - -# Define a transition target with the given build target with the given build configurations. -# -# For instance, the following code creates a target "my_target" with setting "cpu" as "x64_windows" -# and setting "static_link_msvcrt" feature. -# -# mozc_win_build_rule( -# name = "my_target", -# cpu = CPU.X64, -# static_crt = True, -# target = "//bath/to/target:my_target", -# ) -# -# See the following page for the details on transition. -# https://bazel.build/rules/lib/builtins/transition -def mozc_win_build_target( - name, - target, - cpu = CPU.X64, - static_crt = False, - target_compatible_with = [], - tags = [], - **kwargs): - """Define a transition target with the given build target with the given build configurations. - - The following code creates a target "my_target" with setting "cpu" as "x64_windows" and setting - "static_link_msvcrt" feature. - - mozc_win_build_target( - name = "my_target", - cpu = CPU.X64, - static_crt = True, - target = "//bath/to/target:my_target", - ) - - Args: - name: name of the target. - target: the actual Bazel target to be built with the specified configurations. - cpu: CPU type of the target. - static_crt: True if the target should be built with static CRT. - target_compatible_with: optional. Visibility for the unit test target. - tags: optional. Tags for both the library and unit test targets. - **kwargs: other arguments passed to mozc_objc_library. - """ - mandatory_target_compatible_with = [ - "@platforms//os:windows", - ] - for item in mandatory_target_compatible_with: - if item not in target_compatible_with: - target_compatible_with.append(item) - - mandatory_tags = MOZC_TAGS.WIN_ONLY - for item in mandatory_tags: - if item not in tags: - tags.append(item) - - _mozc_win_build_rule( - name = name, - target = target, - cpu = cpu, - static_crt = static_crt, - target_compatible_with = target_compatible_with, - tags = tags, - **kwargs - ) diff --git a/src/win32/tip/BUILD.bazel b/src/win32/tip/BUILD.bazel index 8408fa910..701678e81 100644 --- a/src/win32/tip/BUILD.bazel +++ b/src/win32/tip/BUILD.bazel @@ -32,9 +32,9 @@ load( "//:build_defs.bzl", "MOZC_TAGS", - "mozc_cc_binary", "mozc_cc_library", "mozc_cc_test", + "mozc_win32_cc_prod_binary", "mozc_win32_resource_from_template", ) load( @@ -42,19 +42,10 @@ load( "features_gdi", ) -mozc_cc_binary( - name = "mozc_tip", - srcs = ["mozc_tip_main.cc"], - features = ["generate_pdb_file"], - linkopts = [ - "/DEBUG:FULL", - "/PDBALTPATH:%_PDB%", - ], - linkshared = True, +mozc_cc_library( + name = "mozc_tip_deps", tags = MOZC_TAGS.WIN_ONLY, target_compatible_with = ["@platforms//os:windows"], - visibility = ["//win32/installer:__subpackages__"], # Scheuklappen: keep - win_def_file = "mozc_tip.def", deps = [ ":mozc_tip_resource", ":tip_class_factory", @@ -74,6 +65,42 @@ mozc_cc_binary( ], ) +mozc_win32_cc_prod_binary( + name = "mozc_tip32", + srcs = ["mozc_tip_main.cc"], + cpu = "x64_x86_windows", + executable_name_map = { + "Mozc": "mozc_tip32.dll", + "GoogleJapaneseInput": "GoogleIMEJaTIP32.dll", + }, + static_crt = True, + tags = MOZC_TAGS.WIN_ONLY, + target_compatible_with = ["@platforms//os:windows"], + visibility = ["//win32/installer:__subpackages__"], # Scheuklappen: keep + win_def_file = "mozc_tip.def", + deps = [ + ":mozc_tip_deps", + ], +) + +mozc_win32_cc_prod_binary( + name = "mozc_tip64", + srcs = ["mozc_tip_main.cc"], + cpu = "x64_windows", + executable_name_map = { + "Mozc": "mozc_tip64.dll", + "GoogleJapaneseInput": "GoogleIMEJaTIP64.dll", + }, + static_crt = True, + tags = MOZC_TAGS.WIN_ONLY, + target_compatible_with = ["@platforms//os:windows"], + visibility = ["//win32/installer:__subpackages__"], # Scheuklappen: keep + win_def_file = "mozc_tip.def", + deps = [ + ":mozc_tip_deps", + ], +) + mozc_win32_resource_from_template( name = "mozc_tip_resource", src = "tip_resource.rc",