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
# Install dependencies
brew install python3 ninja [email protected]

# Clone the repository
git clone https://github.com/google/mozc -b master --single-branch --recursive

Build mozc

# 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/[email protected]

# 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