Skip to content

Commit

Permalink
Switch to Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
yukawa committed Aug 18, 2023
1 parent 89c7008 commit f4d7ba7
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 66 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,6 @@ concurrency:
cancel-in-progress: true

jobs:
build_qt6_only:
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md
runs-on: macos-11
timeout-minutes: 90

steps:
- name: checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Set up Python
uses: actions/setup-python@v4
with:
cache: 'pip'
python-version: '3.9'

- name: Install pip dependencies
working-directory: ./src
run: |
python3 -m pip install requests
- name: Try to restore update_deps cache
uses: actions/cache@v3
with:
path: src/third_party_cache
key: update_deps-${{ runner.os }}-${{ hashFiles('src/build_tools/update_deps.py') }}

- name: Install dependencies
working-directory: ./src
# This command uses src/third_party_cache as the download cache.
run: |
python3 build_tools/update_deps.py
- name: Build Qt
working-directory: ./src
run: |
python3 build_tools/build_qt.py --release --confirm_license --qt_archive=third_party_cache/qtbase-everywhere-src-6.5.2.tar.xz
echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV
build:
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md
runs-on: macos-11
Expand Down
2 changes: 1 addition & 1 deletion docs/build_mozc_in_osx.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ python build_tools/update_deps.py
In this step, additional build dependencies will be downloaded.

* [Ninja 1.11.0](https://github.com/ninja-build/ninja/releases/download/v1.11.0/ninja-mac.zip)
* [Qt 5.15.10](https://download.qt.io/archive/qt/5.15/5.15.10/submodules/qtbase-everywhere-opensource-src-5.15.10.tar.xz)
* [Qt 6.5.2](https://download.qt.io/archive/qt/6.5/6.5.2/submodules/qtbase-everywhere-src-6.5.2.tar.xz)
* [git submodules](../.gitmodules)

You can specify `--noqt` option if you would like to use your own Qt binaries.
Expand Down
10 changes: 5 additions & 5 deletions src/bazel/BUILD.qt.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ apple_dynamic_framework_import(
name = "QtCore_mac",
framework_imports = glob(
include = [
"lib/QtCore.framework/Versions/5/QtCore",
"lib/QtCore.framework/Versions/A/QtCore",
"lib/QtCore.framework/QtCore",
"lib/QtCore.framework/Resoures/**",
],
Expand All @@ -69,7 +69,7 @@ apple_dynamic_framework_import(
name = "QtGui_mac",
framework_imports = glob(
include = [
"lib/QtGui.framework/Versions/5/QtGui",
"lib/QtGui.framework/Versions/A/QtGui",
"lib/QtGui.framework/QtGui",
"lib/QtGui.framework/Resoures/**",
],
Expand All @@ -80,7 +80,7 @@ apple_dynamic_framework_import(
name = "QtPrintSupport_mac",
framework_imports = glob(
include = [
"lib/QtPrintSupport.framework/Versions/5/QtPrintSupport",
"lib/QtPrintSupport.framework/Versions/A/QtPrintSupport",
"lib/QtPrintSupport.framework/QtPrintSupport",
"lib/QtPrintSupport.framework/Resoures/**",
],
Expand All @@ -91,7 +91,7 @@ apple_dynamic_framework_import(
name = "QtWidgets_mac",
framework_imports = glob(
include = [
"lib/QtWidgets.framework/Versions/5/QtWidgets",
"lib/QtWidgets.framework/Versions/A/QtWidgets",
"lib/QtWidgets.framework/QtWidgets",
"lib/QtWidgets.framework/Resoures/**",
],
Expand All @@ -103,4 +103,4 @@ filegroup(
srcs = ["plugins/platforms/libqcocoa.dylib"],
)

exports_files(glob(["bin/*"]))
exports_files(glob(["libexec/*"]))
12 changes: 6 additions & 6 deletions src/bazel/qt.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ def mozc_qt_moc(name, srcs, outs):
cmd = mozc_select(
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//:bin/moc) -p $$(dirname $<) -o $@ $(SRCS)",
oss_macos = "$(location @qt_mac//:libexec/moc) -p $$(dirname $<) -o $@ $(SRCS)",
),
tools = mozc_select(
default = ["//third_party/qt:moc"],
oss_linux = ["@qt_linux//:libexec/moc"],
oss_macos = ["@qt_mac//:bin/moc"],
oss_macos = ["@qt_mac//:libexec/moc"],
),
)

Expand All @@ -100,12 +100,12 @@ def mozc_qt_uic(name, srcs, outs):
cmd = mozc_select(
default = "$(location //third_party/qt:uic) -o $@ $(SRCS)",
oss_linux = "$(location @qt_linux//:libexec/uic) -o $@ $(SRCS)",
oss_macos = "$(location @qt_mac//:bin/uic) -o $@ $(SRCS)",
oss_macos = "$(location @qt_mac//:libexec/uic) -o $@ $(SRCS)",
),
tools = mozc_select(
default = ["//third_party/qt:uic"],
oss_linux = ["@qt_linux//:libexec/uic"],
oss_macos = ["@qt_mac//:bin/uic"],
oss_macos = ["@qt_mac//:libexec/uic"],
),
)

Expand All @@ -117,12 +117,12 @@ def mozc_qt_rcc(name, qrc_name, qrc_file, srcs, outs):
cmd = mozc_select(
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//:bin/rcc) -o $@ -name " + qrc_name + " $(location " + qrc_file + ")",
oss_macos = "$(location @qt_mac//:libexec/rcc) -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//:bin/rcc"],
oss_macos = ["@qt_mac//:libexec/rcc"],
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/bazel/qt_mac_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def _qt_mac_repository_impl(repo_ctx):
return

qt_path = repo_ctx.path(repo_ctx.os.environ.get("MOZC_QT_PATH", repo_ctx.attr.default_path))
repo_ctx.symlink(qt_path.get_child("bin"), "bin")
repo_ctx.symlink(qt_path.get_child("lib"), "lib")
repo_ctx.symlink(qt_path.get_child("libexec"), "libexec")
repo_ctx.symlink(qt_path.get_child("plugins"), "plugins")
repo_ctx.template("BUILD.bazel", repo_ctx.path(Label("@//bazel:BUILD.qt.bazel")))

Expand Down
6 changes: 1 addition & 5 deletions src/build_tools/build_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,8 @@ def parse_args() -> argparse.Namespace:
help='make release build')
parser.add_argument('--qt_src_dir', help='qt src directory', type=str,
default=str(ABS_QT_SRC_DIR))
if is_windows():
qt_archive_path_default = ABS_QT6_ARCHIVE_PATH
else:
qt_archive_path_default = ABS_QT5_ARCHIVE_PATH
parser.add_argument('--qt_archive_path', help='qtbase archive path', type=str,
default=str(qt_archive_path_default))
default=str(ABS_QT6_ARCHIVE_PATH))
parser.add_argument('--jom_archive_path', help='qtbase archive path',
type=str, default=str(ABS_JOM_ARCHIVE_PATH))
parser.add_argument('--qt_dest_dir', help='qt dest directory', type=str,
Expand Down
6 changes: 3 additions & 3 deletions src/config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ EMACS_MOZC_CLIENT_DIR = "/usr/share/emacs/site-lisp/emacs-mozc"
EMACS_MOZC_HELPER_DIR = "/usr/bin"

MACOS_BUNDLE_ID_PREFIX = "org.mozc.inputmethod.Japanese"
MACOS_MIN_OS_VER = "10.13"
MACOS_MIN_OS_VER = "11.0"

## Qt path for macOS
# The paths are the default paths of Qt 5.15.2 installed by "make install".
# The paths are the default paths of Qt 6.5.2 installed by "make install".
#
# If MOZC_QT_PATH env var is specified, it is used for MACOS_QT_PATH instead.
#
# For Linux, Qt paths are managed by pkg_config_repository in WORKSPACE.bazel.
MACOS_QT_PATH = "/usr/local/Qt-5.15.2"
MACOS_QT_PATH = "/usr/local/Qt-6.5.2"
12 changes: 6 additions & 6 deletions src/mac/tweak_installer_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def RemoveQtFrameworks(app_dir: str, app_name: str) -> None:
cmd = [
'install_name_tool',
'-change',
f'@rpath/{framework}.framework/Versions/5/{framework}',
f'@rpath/{framework}.framework/Versions/A/{framework}',
f'{host_dir}/{framework}.framework/{framework}',
app_file,
]
Expand All @@ -77,14 +77,14 @@ def SymlinkQtFrameworks(app_dir: str) -> None:
frameworks = ['QtCore', 'QtGui', 'QtPrintSupport', 'QtWidgets']
for framework in frameworks:
# Creates the following symbolic links.
# QtCore.framwwork/QtCore@ -> Versions/5/QtCore
# QtCore.framwwork/Resources@ -> Versions/5/Resources
# QtCore.framework/Versions/Current@ -> 5
# QtCore.framwwork/QtCore@ -> Versions/A/QtCore
# QtCore.framwwork/Resources@ -> Versions/A/Resources
# QtCore.framework/Versions/Current@ -> A
framework_dir = os.path.join(app_dir,
f'Contents/Frameworks/{framework}.framework/')

# ln -s 5 {app_dir}/QtCore.framework/Versions/Current
os.symlink('5', framework_dir + 'Versions/Current')
# ln -s A {app_dir}/QtCore.framework/Versions/Current
os.symlink('A', framework_dir + 'Versions/Current')

# rm {app_dir}/QtCore.framework/QtCore
os.remove(framework_dir + framework)
Expand Down

0 comments on commit f4d7ba7

Please sign in to comment.