Skip to content

Commit

Permalink
Add Qt for Windows support to Bazel build.
Browse files Browse the repository at this point in the history
As a preparation to support Bazel for Windows build (#948), this makes
"qt_win" repository available for Bazel build on Windows.

There must be no observable behavior change in mac/Linux Bazel builds.

PiperOrigin-RevId: 645598529
  • Loading branch information
yukawa authored and hiroyuki-komatsu committed Jun 22, 2024
1 parent b64ba10 commit 019911b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ qt_mac_repository(
default_path = MACOS_QT_PATH, # can be replaced with MOZC_QT_PATH envvar.
)

# Qt for Windows
new_local_repository(
name = "qt_win",
build_file = "@//bazel:BUILD.qt_win.bazel",
path = "third_party/qt",
)

# Google Toolbox for Mac
# https://github.com/google/google-toolbox-for-mac
Expand Down
43 changes: 43 additions & 0 deletions src/bazel/BUILD.qt_win.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package(
default_visibility = ["//visibility:public"],
)

config_setting(
name = "debug_build",
values = {
"compilation_mode": "dbg",
},
visibility = ["//visibility:private"],
)

cc_library(
name = "qt_win",
srcs = select({
":debug_build": [
"lib/Qt6Cored.lib",
"lib/Qt6Guid.lib",
"lib/Qt6Widgetsd.lib",
],
"//conditions:default": [
"lib/Qt6Core.lib",
"lib/Qt6Gui.lib",
"lib/Qt6Widgets.lib",
],
}),
hdrs = glob([
"include"
]),
includes = [
"include",
"include/QtCore",
"include/QtGui",
"include/QtWidgets",
],
target_compatible_with = ["@platforms//os:windows"],
)

exports_files([
"bin/moc.exe",
"bin/uic.exe",
"bin/rcc.exe",
])
8 changes: 8 additions & 0 deletions src/bazel/qt.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def mozc_cc_qt_library(name, deps = [], **kwargs):
default = ["//third_party/qt:qt_native"],
oss_linux = ["@qt_linux//:qt_linux"],
oss_macos = ["@qt_mac//:qt_mac"],
oss_windows = ["@qt_win//:qt_win"],
),
**kwargs
)
Expand All @@ -66,6 +67,7 @@ def mozc_cc_qt_binary(name, deps = [], **kwargs):
default = ["//third_party/qt:qt_native"],
oss_linux = ["@qt_linux//:qt_linux"],
oss_macos = ["@qt_mac//:qt_mac"],
oss_windows = ["@qt_win//:qt_win"],
),
**kwargs
)
Expand All @@ -84,11 +86,13 @@ def mozc_qt_moc(name, srcs, outs):
default = "$(location //third_party/qt:moc) -p $$(dirname $<) -o $@ $(SRCS)",
oss_linux = "$(location @qt_linux//:libexec/moc) -p $$(dirname $<) -o $@ $(SRCS)",
oss_macos = "$(location @qt_mac//:libexec/moc) -p $$(dirname $<) -o $@ $(SRCS)",
oss_windows = "$(location @qt_win//:bin/moc.exe) -p $$(dirname $<) -o $@ $(SRCS)",
),
tools = mozc_select(
default = ["//third_party/qt:moc"],
oss_linux = ["@qt_linux//:libexec/moc"],
oss_macos = ["@qt_mac//:libexec/moc"],
oss_windows = ["@qt_win//:bin/moc.exe"],
),
)

Expand All @@ -101,11 +105,13 @@ def mozc_qt_uic(name, srcs, outs):
default = "$(location //third_party/qt:uic) -o $@ $(SRCS)",
oss_linux = "$(location @qt_linux//:libexec/uic) -o $@ $(SRCS)",
oss_macos = "$(location @qt_mac//:libexec/uic) -o $@ $(SRCS)",
oss_windows = "$(location @qt_win//:bin/uic.exe) -o $@ $(SRCS)",
),
tools = mozc_select(
default = ["//third_party/qt:uic"],
oss_linux = ["@qt_linux//:libexec/uic"],
oss_macos = ["@qt_mac//:libexec/uic"],
oss_windows = ["@qt_win//:bin/uic.exe"],
),
)

Expand All @@ -118,11 +124,13 @@ def mozc_qt_rcc(name, qrc_name, qrc_file, srcs, outs):
default = "$(location //third_party/qt:rcc) -o $@ -name " + qrc_name + " " + qrc_file,
oss_linux = "$(location @qt_linux//:libexec/rcc) -o $@ -name " + qrc_name + " $(location " + qrc_file + ")",
oss_macos = "$(location @qt_mac//:libexec/rcc) -o $@ -name " + qrc_name + " $(location " + qrc_file + ")",
oss_windows = "$(location @qt_win//:bin/rcc.exe) -o $@ -name " + qrc_name + " $(location " + qrc_file + ")",
),
tools = mozc_select(
default = ["//third_party/qt:rcc"],
oss_linux = ["@qt_linux//:libexec/rcc"],
oss_macos = ["@qt_mac//:libexec/rcc"],
oss_windows = ["@qt_win//:bin/rcc.exe"],
),
)

Expand Down

0 comments on commit 019911b

Please sign in to comment.