Fcitx maintains a fork of mozc that contains the support for Mozc.
Build Mozc with bazel
While the command to build fcitx with bazel is simple, making bazel to locate the correct dependencies can be tricky, because the path of dependencies are all hard coded in the bazel's config file under src/. You are likely need to adjust QT_BASE_PATH if you are not building it under debian.
BUILD.fcitx5.bazel and WORKSPACE.bazel may also need to be updated to match your path. If you need custom prefix, the mozc server path also needs to be adjusted in config.bzl accordingly.
If you are using bazel 5.0.0, you will hit an issue that always require android NDK even if it is not used. It need to workaround by commenting out the
android_ndk_repository line in WORKSPACE.bazel.
cd src # Need to run the bazel command under src/ # Build 3 target: mozc_server, qt based GUI tool and fcitx5's plugin. bazel build -c opt --copt=-fPIC --config oss_linux unix/fcitx5:fcitx5-mozc.so server:mozc_server gui/tool:mozc_tool
The command above will generate following files required by mozc:
bazel-bin/unix/fcitx5/fcitx5-mozc.so bazel-bin/server/mozc_server bazel-bin/gui/tool/mozc_tool
You'll need to put those files to the corresponding places:
../scripts/install_server_bazel can be used to help you as a reference on what needs to be done.
Build Mozc with gyp
This method may be deprecated any time depending on the upstream. In fcitx/mozc repository, there are some scripts that helps to build it with gyp. As for now, it does not support python 3.10. Another issue is that it will also use libc++ to build, which is not an option if fcitx5 links to stdc++.
cd src/ # Set this environment variable if you want Release build: _bldtype=Release GYP_DEFINES="use_fcitx=0 use_libibus=0" ../scripts/configure # Pass --server_dir if you want a different mozc server directory. sed "/stdlib=libc++/d;/-lc++/d" -i gyp/common.gypi ../scripts/build_fcitx5 ../scripts/install_server ../scripts/install_fcitx5
The default path used by the script is assuming /usr as prefix, please adjust by set PREFIX environment variable if you want a custom prefix, or just do the installation manually.