diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..82ad24f89 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,9 @@ +# docker/ + + * [`ubuntu22.04/Dockerfile`](./ubuntu22.04/Dockerfile) + * [`ubuntu24.04/Dockerfile`](./ubuntu24.04/Dockerfile) + +⚠️ `Dockerfile` provided in this directory are deprecated. See the following documents on how to build Mozc for Linux desktop or Android. + +* [How to build Mozc for Android](../docs/build_mozc_for_android.md): for Android library (`libmozc.so`) +* [How to build Mozc for Linux](../docs/build_mozc_for_linux.md): for Linux desktop diff --git a/docker/ubuntu22.04/Dockerfile b/docker/ubuntu22.04/Dockerfile index e7a5ac317..5f6bb67bc 100644 --- a/docker/ubuntu22.04/Dockerfile +++ b/docker/ubuntu22.04/Dockerfile @@ -27,8 +27,10 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# Build instructions with this Dockerfile. -# https://github.com/google/mozc/blob/master/docs/build_mozc_in_docker.md +# This file is deprecated. +# See the following pages for the latest build instructions. +# - https://github.com/google/mozc/blob/master/docs/build_mozc_for_linux.md +# - https://github.com/google/mozc/blob/master/docs/build_mozc_for_android.md FROM ubuntu:22.04 diff --git a/docker/ubuntu22.04/README.md b/docker/ubuntu22.04/README.md new file mode 100644 index 000000000..a6bace375 --- /dev/null +++ b/docker/ubuntu22.04/README.md @@ -0,0 +1,8 @@ +# docker/ubuntu22.04 + + * [`Dockerfile`](./Dockerfile) + +⚠️ `Dockerfile` provided in this directory is deprecated. See the following documents on how to build Mozc for Linux desktop or Android. + +* [How to build Mozc for Android](../../docs/build_mozc_for_android.md): for Android library (`libmozc.so`) +* [How to build Mozc for Linux](../../docs/build_mozc_for_linux.md): for Linux desktop diff --git a/docker/ubuntu24.04/Dockerfile b/docker/ubuntu24.04/Dockerfile index b024ebd95..57ef6cdce 100644 --- a/docker/ubuntu24.04/Dockerfile +++ b/docker/ubuntu24.04/Dockerfile @@ -27,8 +27,10 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# Build instructions with this Dockerfile. -# https://github.com/google/mozc/blob/master/docs/build_mozc_in_docker.md +# This file is deprecated. +# See the following pages for the latest build instructions. +# - https://github.com/google/mozc/blob/master/docs/build_mozc_for_linux.md +# - https://github.com/google/mozc/blob/master/docs/build_mozc_for_android.md FROM ubuntu:24.04 diff --git a/docker/ubuntu24.04/README.md b/docker/ubuntu24.04/README.md new file mode 100644 index 000000000..49ef3b277 --- /dev/null +++ b/docker/ubuntu24.04/README.md @@ -0,0 +1,8 @@ +# docker/ubuntu24.04 + + * [`Dockerfile`](./Dockerfile) + +⚠️ `Dockerfile` provided in this directory is deprecated. See the following documents on how to build Mozc for Linux desktop or Android. + +* [How to build Mozc for Android](../../docs/build_mozc_for_android.md): for Android library (`libmozc.so`) +* [How to build Mozc for Linux](../../docs/build_mozc_for_linux.md): for Linux desktop diff --git a/docs/build_mozc_for_linux.md b/docs/build_mozc_for_linux.md new file mode 100644 index 000000000..7b0190940 --- /dev/null +++ b/docs/build_mozc_for_linux.md @@ -0,0 +1,195 @@ +# How to build Mozc for Linux desktop + +[![Linux](https://github.com/google/mozc/actions/workflows/linux.yaml/badge.svg)](https://github.com/google/mozc/actions/workflows/linux.yaml) + +## Summary + +If you are not sure what the following commands do, please check the +descriptions below and make sure the operations before running them. + +``` +git clone https://github.com/google/mozc.git --recursive +cd mozc/src + +bazelisk build package --config oss_linux --config release_build +``` + +`bazel-bin/unix/mozc.zip` contains built files. + +## System Requirements + +Due to the diverse nature of Linux desktop ecosystem, how our Linux CI is +configured is almost always the best example on how Mozc executables for Linux +desktop can be built and tested against existing test cases. + +* [`.github/workflows/linux.yaml`](../.github/workflows/linux.yaml) +* [CI for Linux](https://github.com/google/mozc/actions/workflows/linux.yaml) + +The following sections describe relevant software components that are necessary +to build Mozc for Linux desktop. + +### Bazelisk + +[Bazelisk](https://github.com/bazelbuild/bazelisk) is a wrapper of +[Bazel](https://bazel.build) to use the specific version of Bazel. + +The Bazel version specified in [`src/.bazeliskrc`](../src/.bazeliskrc) is what +our CI is testing against. + +See the following document for detail on how Bazelisk determines the Bazel +version. + + * [How does Bazelisk know which Bazel version to run?](https://github.com/bazelbuild/bazelisk/blob/master/README.md#how-does-bazelisk-know-which-bazel-version-to-run) + +⚠️ Bazel version mismatch is a major source of build failures. If you manually +install Bazel then use it instead of Bazelisk, pay extra attention to which +version of Bazel you are using. + +### C++ toolchain + +Some C++ toolchain (typically GCC or Clang) is needed to build Mozc. + +💡 [`rules_cc`](https://github.com/bazelbuild/rules_cc/) automatically detects +what C++ toolchains are available in the host environment. + +### Packages + +Packages referenced in `pkg_config_repository` at +[`src/MODULE.bazel`](../src/MODULE.bazel) need to be installed beforehand. + +``` +# iBus +pkg_config_repository( + name = "ibus", + packages = [ + "glib-2.0", + "gobject-2.0", + "ibus-1.0", + ], +) +``` +``` +# Qt for Linux +pkg_config_repository( + name = "qt_linux", + packages = [ + "Qt6Core", + "Qt6Gui", + "Qt6Widgets", + ], +) +``` + +## Get the Code + +You can download Mozc source code as follows. + +``` +git clone https://github.com/google/mozc.git --recursive +cd mozc/src +``` + +Hereafter you can do all the operations without changing directory. + +## Build Mozc + +You should be able to build Mozc for Linux desktop as follows, assuming +`bazelisk` is in your `$PATH`. + +``` +bazelisk build package --config oss_linux --config release_build +``` + +`package` is an alias to build Mozc executables and archive them into `mozc.zip`. + +💡 You may have some build errors when you update the build environment or +configurations. Try the following command to +[clean Bazel's build cache](https://bazel.build/docs/user-manual#clean). + +``` +bazelisk clean --expunge +``` + +### Mozc installation locations + +Here is a table of contents in `mozc.zip` and their actual build target names. + +| build target | installation location | +| -------------------------------- | --------------------- | +| `//server:mozc_server` | `/usr/lib/mozc/mozc_server` | +| `//gui/tool:mozc_tool` | `/usr/lib/mozc/mozc_tool` | +| `//renderer:mozc_renderer` | `/usr/lib/mozc/mozc_renderer` | +| `//unix/ibus/ibus_mozc` | `/usr/lib/ibus-mozc/ibus-engine-mozc` | +| `//unix/ibus:gen_mozc_xml` | `/usr/share/ibus/component/mozc.xml` | +| `//unix:icons` | `/usr/share/ibus-mozc/...` | +| `//unix:icons` | `/usr/share/icons/mozc/...` | +| `//unix/emacs:mozc.el` | `/usr/share/emacs/site-lisp/emacs-mozc/mozc.el` | +| `//unix/emacs:mozc_emacs_helper` | `/usr/bin/mozc_emacs_helper` | + +To customize above installation locations, modify +[`src/config.bzl`](../src/config.bzl). + +💡 The following command makes the specified file untracked by Git. +``` +git update-index --assume-unchanged src/config.bzl +``` +💡 This command reverts the above change. +``` +git update-index --no-assume-unchanged src/config.bzl +``` + +## Unit tests + +### Run all tests + +``` +bazelisk test ... --config oss_linux --build_tests_only -c dbg +``` + +* `...` means all targets under the current and subdirectories. + + +### Run tests under the specific directories + +``` +bazelisk test base/... composer/... --config oss_linux --build_tests_only -c dbg +``` + +* `/...` means all targets under the `/` directory. + + +### Run tests without the specific directories + +``` +bazelisk test ... --config oss_linux --build_tests_only -c dbg -- -base/... +``` + +* `--` means the end of the flags which start from `-`. +* `-/...` means exclusion of all targets under the `dir`. + + +### Run the specific test + +``` +bazelisk test base:util_test --config oss_linux -c dbg +``` + +* `util_test` is defined in `base/BUILD.bazel`. + +### Output logs to stderr + +``` +bazelisk test base:util_test --config oss_linux --test_arg=--stderrthreshold=0 --test_output=all +``` + +* The `--test_arg=--stderrthreshold=0 --test_output=all` flags shows the + output of unitests to stderr. + +----- + +## Build Mozc for Linux Desktop with GYP (deprecated): + +⚠️ The GYP build is deprecated and no longer supported. + +Please check the previous version for more information. +https://github.com/google/mozc/blob/2.29.5374.102/docs/build_mozc_in_docker.md#build-mozc-for-linux-desktop-with-gyp-maintenance-mode diff --git a/docs/build_mozc_in_docker.md b/docs/build_mozc_in_docker.md index 9e3adc9a6..e542db03a 100644 --- a/docs/build_mozc_in_docker.md +++ b/docs/build_mozc_in_docker.md @@ -1,190 +1,9 @@ # How to build Mozc in Docker -[![Linux](https://github.com/google/mozc/actions/workflows/linux.yaml/badge.svg)](https://github.com/google/mozc/actions/workflows/linux.yaml) -[![Android lib](https://github.com/google/mozc/actions/workflows/android.yaml/badge.svg)](https://github.com/google/mozc/actions/workflows/android.yaml) +⚠️ `Dockerfile` provided under [`docker/`](../docker/) are deprecated. See the following documents on how to build Mozc for Linux desktop or Android. -## Summary - -If you are not sure what the following commands do, please check the descriptions below -and make sure the operations before running them. - -``` -curl -O https://raw.githubusercontent.com/google/mozc/master/docker/ubuntu24.04/Dockerfile -docker build --rm --tag mozc_ubuntu24.04 . -docker create --interactive --tty --name mozc_build mozc_ubuntu24.04 - -docker start mozc_build -docker exec mozc_build bazelisk build package --config oss_linux --config release_build -docker cp mozc_build:/home/mozc_builder/work/mozc/src/bazel-bin/unix/mozc.zip . -``` - -## Introduction -Docker containers are available to build Mozc binaries for Linux desktop. - -## System Requirements -Currently, only Ubuntu 24.04 is tested to host the Docker container to build Mozc. - -* [Dockerfile](https://github.com/google/mozc/blob/master/docker/ubuntu24.04/Dockerfile) for Ubuntu 24.04 - -## Build in Docker - -### Set up Ubuntu 24.04 Docker container - -``` -curl -O https://raw.githubusercontent.com/google/mozc/master/docker/ubuntu24.04/Dockerfile -docker build --rm --tag mozc_ubuntu24.04 . -docker create --interactive --tty --name mozc_build mozc_ubuntu24.04 -``` - -You may need to execute `docker` with `sudo` (e.g. `sudo docker build ...`). - -Notes -* `mozc_ubuntu24.04` is a Docker image name (customizable). -* `mozc_build` is a Docker container name (customizable). -* Don't forget to rebuild Docker container when Dockerfile is updated. - - -### Build Mozc in Docker container - -``` -docker start mozc_build -docker exec mozc_build bazelisk build package --config oss_linux --config release_build -docker cp mozc_build:/home/mozc_builder/work/mozc/src/bazel-bin/unix/mozc.zip . -``` - -`mozc.zip` contains built files. - -Notes -* You might want to execute `docker stop` after build. -* `mozc_build` is the Docker container name created in the above section. - ------ - -## Build Mozc for Linux Desktop - -``` -bazelisk build package --config oss_linux --config release_build -``` - -Note: You might want to execute `docker start --interactive mozc_build` -to enter the docker container before the above command. - -`package` builds Mozc binaries and locates them into `mozc.zip` as follows. - -| build rule | install path | -| ------------------------------ | ------------ | -| //server:mozc_server | /usr/lib/mozc/mozc_server | -| //gui/tool:mozc_tool | /usr/lib/mozc/mozc_tool | -| //renderer:mozc_renderer | /usr/lib/mozc/mozc_renderer | -| //unix/ibus/ibus_mozc | /usr/lib/ibus-mozc/ibus-engine-mozc | -| //unix/ibus:gen_mozc_xml | /usr/share/ibus/component/mozc.xml | -| //unix:icons | /usr/share/ibus-mozc/... | -| //unix:icons | /usr/share/icons/mozc/... | -| //unix/emacs:mozc.el | /usr/share/emacs/site-lisp/emacs-mozc/mozc.el | -| //unix/emacs:mozc_emacs_helper | /usr/bin/mozc_emacs_helper | - -Install paths are configurable by modifying -[src/config.bzl](https://github.com/google/mozc/blob/master/src/config.bzl). - - -### Unit tests - -#### Run all tests - -``` -bazelisk test ... --config oss_linux --build_tests_only -c dbg -``` - -* `...` means all targets under the current and subdirectories. - - -### Run tests under the specific directories - -``` -bazelisk test base/... composer/... --config oss_linux --build_tests_only -c dbg -``` - -* `/...` means all targets under the `/` directory. - - -### Run tests without the specific directories - -``` -bazelisk test ... --config oss_linux --build_tests_only -c dbg -- -base/... -``` - -* `--` means the end of the flags which start from `-`. -* `-/...` means exclusion of all targets under the `dir`. - - -### Run the specific test - -``` -bazelisk test base:util_test --config oss_linux -c dbg -``` - -* `util_test` is defined in `base/BUILD.bazel`. - -### Output logs to stderr - -``` -bazelisk test base:util_test --config oss_linux --test_arg=--stderrthreshold=0 --test_output=all -``` - -* The `--test_arg=--stderrthreshold=0 --test_output=all` flags shows the - output of unitests to stderr. - -## Build Mozc on other Linux environment - -Note: This section is not about our officially supported build process. - -### Software requirements - -* Python: 3.7 or later -* Ibus: 1.5.4 or later - * libglib -* Qt6: 6.2.5 or later, or Qt 6.2.x with working around [QTBUG-86080](https://bugreports.qt.io/browse/QTBUG-86080) by yourself - * libgl - -You may also need other libraries. -See the configurations of -[Dockerfile](https://github.com/google/mozc/blob/master/docker/ubuntu24.04/Dockerfile) -and -[GitHub Actions](https://github.com/google/mozc/blob/master/.github/workflows/linux.yaml). - -### Build configurations - -To build Mozc on other Linux environment rather than the supported Docker -environment, you might need to modify the following files. - -* src/config.bzl - configuration of install paths, etc. -* src/.bazelrc - compiler flags, etc. -* src/MODULE.bazel - build dependencies. - -Tips: the following command makes the specified file untracked by Git. -``` -git update-index --assume-unchanged src/config.bzl -``` - -This command reverts the above change. -``` -git update-index --no-assume-unchanged src/config.bzl -``` - -### Forcing reconfigure external dependencies - -You may have some build errors when you update build environment or configurations. -In that case, try the following command to [refetch external repositories](https://bazel.build/external/repo#forcing_refetch_of_external_repos). - -``` -bazelisk sync --configure -``` - -If the issue persists, also try the following command to [clean Bazel's build cache](https://bazel.build/docs/user-manual#clean) - -``` -bazelisk clean --expunge -``` +* [How to build Mozc for Android](./build_mozc_for_android.md): for Android library (`libmozc.so`) +* [How to build Mozc for Linux](./build_mozc_for_linux.md): for Linux desktop -----