Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fcitx
Browse files Browse the repository at this point in the history
  • Loading branch information
Fcitx Bot committed Jun 24, 2024
2 parents e379550 + 9a6c95d commit 0d3346f
Show file tree
Hide file tree
Showing 35 changed files with 937 additions and 197 deletions.
38 changes: 25 additions & 13 deletions src/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
# Common options
build --cxxopt "-std=c++20"
build --copt "-funsigned-char"
build --copt "-Wno-sign-compare"
build --copt "-Wno-char-subscripts"
build --host_cxxopt "-std=c++20"
build --host_copt "-funsigned-char"
build --host_copt "-Wno-sign-compare"
build --host_copt "-Wno-char-subscripts"
build --objccopt "-fsigned-char"
# enable_bzlmod causes the build failure. Suppress it util the fix.
build --noenable_bzlmod
common --noenable_bzlmod

common:linux --config=compiler_gcc_like
common:oss_linux --config=compiler_gcc_like
common:prod_linux --config=compiler_gcc_like
common:android --config=compiler_gcc_like
common:oss_android --config=compiler_gcc_like
common:prod_android --config=compiler_gcc_like
common:macos --config=compiler_gcc_like
common:oss_macos --config=compiler_gcc_like
common:prod_macos --config=compiler_gcc_like

# Make sure we set -std=c++20 that may affect ABI across all the compilation targets.
# https://github.com/abseil/abseil-cpp/blob/master/FAQ.md#what-is-abi-and-why-dont-you-recommend-using-a-pre-compiled-version-of-abseil
build:compiler_gcc_like --cxxopt "-std=c++20" --host_cxxopt "-std=c++20"
build:compiler_gcc_like --copt "-funsigned-char" --host_copt "-funsigned-char"
build:compiler_gcc_like --copt "-Wno-sign-compare" --host_copt "-Wno-sign-compare"
build:compiler_gcc_like --copt "-Wno-char-subscripts" --host_copt "-Wno-char-subscripts"
build:compiler_msvc_like --cxxopt "/std:c++20" --host_cxxopt "/std:c++20"
build:compiler_msvc_like --copt "/J" --host_copt "/J"
build:compiler_msvc_like --copt "/utf-8" --host_copt "/utf-8"
build:compiler_msvc_like --cxxopt "/J" --host_cxxopt "/J"
build:compiler_msvc_like --cxxopt "/utf-8" --host_cxxopt "/utf-8"

# Linux
build:linux --define TARGET=oss_linux --copt "-fPIC"
Expand All @@ -25,9 +37,9 @@ build:prod_linux --build_tag_filters=-nolinux
# macOS
build:macos --define TARGET=oss_macos --build_tag_filters=-nomac
test:macos --define TARGET=oss_macos --test_tag_filters=-nomac
build:oss_macos --define TARGET=oss_macos --build_tag_filters=-nomac
build:oss_macos --define TARGET=oss_macos --build_tag_filters=-nomac --objccopt "-fsigned-char"
test:oss_macos --define TARGET=oss_macos --test_tag_filters=-nomac
build:prod_macos --define TARGET=prod_macos --build_tag_filters=-nomac
build:prod_macos --define TARGET=prod_macos --build_tag_filters=-nomac --objccopt "-fsigned-char"

# Windows
build:windows --define TARGET=oss_windows --build_tag_filters=-nowin
Expand Down
50 changes: 50 additions & 0 deletions src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ load(
"mozc_select_enable_supplemental_model",
"mozc_select_enable_usage_rewriter",
)
load("//:config.bzl", "BAZEL_TOOLS_PREFIX")
load("//bazel:stubs.bzl", "bzl_library")

package(default_visibility = ["//:__subpackages__"])
Expand All @@ -55,6 +56,40 @@ config_setting(
visibility = ["//visibility:private"],
)

alias(
name = "compiler",
actual = BAZEL_TOOLS_PREFIX + "//tools/cpp:compiler",
visibility = ["//:__subpackages__"],
)

config_setting(
name = "compiler_msvc_cl",
flag_values = {
":compiler": "msvc-cl",
},
visibility = ["//:__subpackages__"],
)

config_setting(
name = "compiler_clang_cl",
flag_values = {
":compiler": "clang-cl",
},
visibility = ["//:__subpackages__"],
)

selects.config_setting_group(
name = "compiler_msvc_like",
match_any = [
# clang-cl.exe is a drop-in replacement for cl.exe.
# Command line options are mostly compatible.
# https://clang.llvm.org/docs/MSVCCompatibility.html
":compiler_clang_cl",
":compiler_msvc_cl",
],
visibility = ["//:__subpackages__"],
)

# Special target so as to define special macros for each platforms.
# Don't depend on this directly. Use mozc_cc_(library|binary|test) rule instead.
cc_library(
Expand Down Expand Up @@ -84,6 +119,21 @@ cc_library(
oss_macos = [
"MOZC_BUILD",
],
oss_windows = [
"MOZC_BUILD",
"WINVER=0x0A00",
"_WIN32_WINNT=0x0A00",
"_ATL_ALL_WARNINGS",
"_ATL_ALLOW_CHAR_UNSIGNED",
"_ATL_CSTRING_EXPLICIT_CONSTRUCTORS",
"_ATL_NO_AUTOMATIC_NAMESPACE",
"_ATL_NO_HOSTING",
"ID_TRACE_LEVEL=1",
"_MIDL_USE_GUIDDEF_",
"PSAPI_VERSION=2",
"UNICODE",
"_UNICODE",
],
wasm = [
"GOOGLE_JAPANESE_INPUT_BUILD",
],
Expand Down
6 changes: 6 additions & 0 deletions src/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,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
2 changes: 1 addition & 1 deletion src/base/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mozc_cc_library(
name = "init_mozc_buildtool",
srcs = ["init_mozc.cc"],
hdrs = ["init_mozc.h"],
copts = ["-DMOZC_BUILDTOOL_BUILD"],
local_defines = ["MOZC_BUILDTOOL_BUILD"],
visibility = ["//:__subpackages__"],
deps = [
":log_file",
Expand Down
1 change: 1 addition & 0 deletions src/base/win32/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ mozc_cc_library(
tags = MOZC_TAGS.WIN_ONLY,
target_compatible_with = ["@platforms//os:windows"],
visibility = [
"//gui/tool:__subpackages__",
"//renderer/win32:__subpackages__",
"//server:__pkg__",
"//win32/broker:__subpackages__",
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
1 change: 0 additions & 1 deletion src/bazel/stubs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,4 @@ def cc_stub(name, tags = None, target_compatible_with = None, **kwargs):

lexan = struct(
resource_files = cc_stub,
cc_windows_dll = cc_stub,
)
Loading

0 comments on commit 0d3346f

Please sign in to comment.