uechi.io/source/_posts/2022/building-mozc-for-macos.md
2022-06-22 12:01:59 +09:00

65 lines
1.6 KiB
Markdown

---
title: Building mozc for macOS
date: 2022-05-20T00:00:00
---
[Mozc](https://github.com/google/mozc) is an open-source counterpart of Google Japanese Input, a Japanese input method developed by Google.
## Setup build environment
```
$ sw_vers
ProductName: macOS
ProductVersion: 12.2.1
BuildVersion: 21D62
$ xcodebuild -version
Xcode 13.3
Build version 13E113
```
```bash
# Install dependencies
brew install python3 ninja qt@5
# Clone the repository
git clone https://github.com/google/mozc -b master --single-branch --recursive
```
## Build mozc
```bash
# Move to the source directory
cd mozc/src
# Expose necessary variable
MAC_SDK=$(xcodebuild -showsdks 2>/dev/null | grep '\tmacOS' | awk '{print $2}')
MAC_DEPLOYMENT_TARGET=$(sw_vers -productVersion | sed -E 's/\.[^.]+$//')
export GYP_DEFINES="mac_sdk=${MAC_SDK} mac_deployment_target=${MAC_DEPLOYMENT_TARGET}"
# Apply hotfix to third party libs
cd third_party
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH="$PATH:$PWD/depot_tools"
python3 -m pip install six
cd gyp
git apply ../../gyp/gyp.patch
cd ../..
# Configure
python3 build_mozc.py gyp --qtdir=/usr/local/opt/qt@5
# Build main converter and GUI tools
python3 build_mozc.py build -c Release mac/mac.gyp:GoogleJapaneseInput gui/gui.gyp:config_dialog_main
# Install
sudo cp -r out_mac/Release/Mozc.app /Library/Input\ Methods/
sudo cp mac/installer/LaunchAgents/org.mozc.inputmethod.Japanese.Converter.plist /Library/LaunchAgents
sudo cp mac/installer/LaunchAgents/org.mozc.inputmethod.Japanese.Renderer.plist /Library/LaunchAgents
# Clean up the tree
python3 build_mozc.py clean
reboot
```