Skip to content

Commit 5d6f96c

Browse files
authoredMar 6, 2025··
Extract out Linux build instructions (#1199)
As the final step towards removing the dependency on Docker from build instructions, this commit introduces 'build_mozc_for_linux.md' as the successor of long-lived 'build_mozc_in_docker.md'. This commit also declares that our Dockerfile is now deprecated. Closes #1181. PiperOrigin-RevId: 733683917
1 parent e0ff7b3 commit 5d6f96c

File tree

9 files changed

+247
-190
lines changed

9 files changed

+247
-190
lines changed
 

‎.github/workflows/linux.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: CI for Linux
2-
# https://github.com/google/mozc/blob/master/docs/build_mozc_in_docker.md
2+
# https://github.com/google/mozc/blob/master/docs/build_mozc_for_linux.md
33

44
# Run on push.
55
on: push

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Build Instructions
3535
------------------
3636

3737
* [How to build Mozc for Android](docs/build_mozc_for_android.md): for Android library (`libmozc.so`)
38-
* [How to build Mozc for Linux](docs/build_mozc_in_docker.md): for Linux desktop
38+
* [How to build Mozc for Linux](docs/build_mozc_for_linux.md): for Linux desktop
3939
* [How to build Mozc for macOS](docs/build_mozc_in_osx.md): for macOS build
4040
* [How to build Mozc for Windows](docs/build_mozc_in_windows.md): for Windows
4141

‎docker/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# docker/ (Deprecated)
2+
3+
* [`ubuntu22.04/Dockerfile`](./ubuntu22.04/Dockerfile)
4+
* [`ubuntu24.04/Dockerfile`](./ubuntu24.04/Dockerfile)
5+
6+
⚠️ `Dockerfile` provided in this directory are deprecated. See the following documents on how to build Mozc for Linux desktop or Android.
7+
8+
* [How to build Mozc for Android](../docs/build_mozc_for_android.md): for Android library (`libmozc.so`)
9+
* [How to build Mozc for Linux](../docs/build_mozc_for_linux.md): for Linux desktop

‎docker/ubuntu22.04/Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2828
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

30-
# Build instructions with this Dockerfile.
31-
# https://github.com/google/mozc/blob/master/docs/build_mozc_in_docker.md
30+
# This file is deprecated.
31+
# See the following pages for the latest build instructions.
32+
# - https://github.com/google/mozc/blob/master/docs/build_mozc_for_linux.md
33+
# - https://github.com/google/mozc/blob/master/docs/build_mozc_for_android.md
3234

3335
FROM ubuntu:22.04
3436

‎docker/ubuntu22.04/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# docker/ubuntu22.04 (Deprecated)
2+
3+
* [`Dockerfile`](./Dockerfile)
4+
5+
⚠️ `Dockerfile` provided in this directory is deprecated. See the following documents on how to build Mozc for Linux desktop or Android.
6+
7+
* [How to build Mozc for Android](../../docs/build_mozc_for_android.md): for Android library (`libmozc.so`)
8+
* [How to build Mozc for Linux](../../docs/build_mozc_for_linux.md): for Linux desktop

‎docker/ubuntu24.04/Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2828
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

30-
# Build instructions with this Dockerfile.
31-
# https://github.com/google/mozc/blob/master/docs/build_mozc_in_docker.md
30+
# This file is deprecated.
31+
# See the following pages for the latest build instructions.
32+
# - https://github.com/google/mozc/blob/master/docs/build_mozc_for_linux.md
33+
# - https://github.com/google/mozc/blob/master/docs/build_mozc_for_android.md
3234

3335
FROM ubuntu:24.04
3436

‎docker/ubuntu24.04/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# docker/ubuntu24.04 (Deprecated)
2+
3+
* [`Dockerfile`](./Dockerfile)
4+
5+
⚠️ `Dockerfile` provided in this directory is deprecated. See the following documents on how to build Mozc for Linux desktop or Android.
6+
7+
* [How to build Mozc for Android](../../docs/build_mozc_for_android.md): for Android library (`libmozc.so`)
8+
* [How to build Mozc for Linux](../../docs/build_mozc_for_linux.md): for Linux desktop

‎docs/build_mozc_for_linux.md

+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# How to build Mozc for Linux desktop
2+
3+
[![Linux](https://github.com/google/mozc/actions/workflows/linux.yaml/badge.svg)](https://github.com/google/mozc/actions/workflows/linux.yaml)
4+
5+
## Summary
6+
7+
If you are not sure what the following commands do, please check the
8+
descriptions below and make sure the operations before running them.
9+
10+
```
11+
git clone https://github.com/google/mozc.git --recursive
12+
cd mozc/src
13+
14+
bazelisk build package --config oss_linux --config release_build
15+
```
16+
17+
`bazel-bin/unix/mozc.zip` contains built files.
18+
19+
## System Requirements
20+
21+
Due to the diverse nature of Linux desktop ecosystem, continuous builds on
22+
GitHub Actions are the best example on how Mozc executables for Linux desktop
23+
can be built and tested against existing test cases.
24+
25+
* [`.github/workflows/linux.yaml`](../.github/workflows/linux.yaml)
26+
* [CI for Linux](https://github.com/google/mozc/actions/workflows/linux.yaml)
27+
28+
The following sections describe relevant software components that are necessary
29+
to build Mozc for Linux desktop.
30+
31+
### Bazelisk
32+
33+
[Bazelisk](https://github.com/bazelbuild/bazelisk) is a wrapper of
34+
[Bazel](https://bazel.build) to use the specific version of Bazel.
35+
36+
The Bazel version specified in [`src/.bazeliskrc`](../src/.bazeliskrc) is what
37+
continuous builds are testing against.
38+
39+
See the following document for detail on how Bazelisk determines the Bazel
40+
version.
41+
42+
* [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)
43+
44+
⚠️ Bazel version mismatch is a major source of build failures. If you manually
45+
install Bazel then use it instead of Bazelisk, pay extra attention to which
46+
version of Bazel you are using.
47+
48+
### C++ toolchain
49+
50+
GCC or Clang is needed to build Mozc.
51+
52+
While Linux continuous builds currently use GCC, Mozc's C++ code is designed to be compatible with Clang (for macOS, Windows, Android, and Google internal use) and Visual C++ 2022 (for Windows GYP build, which is going to be deprecated) as well.
53+
54+
💡 See [`.github/workflows/linux.yaml`](../.github/workflows/linux.yaml) on which version of GCC is tested against.
55+
56+
💡 Like many other Bazel-based C++ projects, Mozc relies on [`rules_cc`](https://github.com/bazelbuild/rules_cc/) specified in [`MODULE.bazel`](../src/MODULE.bazel) to automatically detect C++ toolchains in the host environment.
57+
58+
### Packages
59+
60+
Development packages referenced in `pkg_config_repository` at
61+
[`src/MODULE.bazel`](../src/MODULE.bazel) need to be installed beforehand.
62+
63+
```
64+
# iBus
65+
pkg_config_repository(
66+
name = "ibus",
67+
packages = [
68+
"glib-2.0",
69+
"gobject-2.0",
70+
"ibus-1.0",
71+
],
72+
)
73+
```
74+
```
75+
# Qt for Linux
76+
pkg_config_repository(
77+
name = "qt_linux",
78+
packages = [
79+
"Qt6Core",
80+
"Qt6Gui",
81+
"Qt6Widgets",
82+
],
83+
)
84+
```
85+
86+
💡 `pkg_config_repository` is not a bazel standard functionality. It is a custom macro defined in [`src/bazel/pkg_config_repository.bzl`](../src/bazel/pkg_config_repository.bzl).
87+
88+
## Build instructions
89+
90+
### Get the Code
91+
92+
You can download Mozc source code as follows.
93+
94+
```
95+
git clone https://github.com/google/mozc.git --recursive
96+
cd mozc/src
97+
```
98+
99+
Hereafter you can do all the operations without changing directory.
100+
101+
### Build Mozc
102+
103+
You should be able to build Mozc for Linux desktop as follows, assuming
104+
`bazelisk` is in your `$PATH`.
105+
106+
```
107+
bazelisk build package --config oss_linux --config release_build
108+
```
109+
110+
`package` is an alias to build Mozc executables and archive them into `mozc.zip`.
111+
112+
### Clean Bazel's build cache
113+
114+
💡 You may have some build errors when you update the build environment or
115+
configurations. Try the following command to
116+
[clean Bazel's build cache](https://bazel.build/docs/user-manual#clean).
117+
118+
```
119+
bazelisk clean --expunge
120+
```
121+
122+
### How to customize installation locations
123+
124+
Here is a table of contents in `mozc.zip` and their actual build target names.
125+
126+
| build target | installation location |
127+
| -------------------------------- | --------------------- |
128+
| `//server:mozc_server` | `/usr/lib/mozc/mozc_server` |
129+
| `//gui/tool:mozc_tool` | `/usr/lib/mozc/mozc_tool` |
130+
| `//renderer:mozc_renderer` | `/usr/lib/mozc/mozc_renderer` |
131+
| `//unix/ibus/ibus_mozc` | `/usr/lib/ibus-mozc/ibus-engine-mozc` |
132+
| `//unix/ibus:gen_mozc_xml` | `/usr/share/ibus/component/mozc.xml` |
133+
| `//unix:icons` | `/usr/share/ibus-mozc/...` |
134+
| `//unix:icons` | `/usr/share/icons/mozc/...` |
135+
| `//unix/emacs:mozc.el` | `/usr/share/emacs/site-lisp/emacs-mozc/mozc.el` |
136+
| `//unix/emacs:mozc_emacs_helper` | `/usr/bin/mozc_emacs_helper` |
137+
138+
To customize above installation locations, modify
139+
[`src/config.bzl`](../src/config.bzl).
140+
141+
💡 The following command makes the specified file untracked by Git.
142+
```
143+
git update-index --assume-unchanged src/config.bzl
144+
```
145+
💡 This command reverts the above change.
146+
```
147+
git update-index --no-assume-unchanged src/config.bzl
148+
```
149+
150+
## Bazel command examples
151+
152+
### Bazel User Guide
153+
* [Build programs with Bazel](https://bazel.build/run/build)
154+
* [Commands and Options](https://bazel.build/docs/user-manual)
155+
* [Write bazelrc configuration files](https://bazel.build/run/bazelrc)
156+
157+
### Run all tests
158+
159+
```
160+
bazelisk test ... --config oss_linux --build_tests_only -c dbg
161+
```
162+
163+
* `...` means all targets under the current and subdirectories.
164+
165+
166+
### Run tests under the specific directories
167+
168+
```
169+
bazelisk test base/... composer/... --config oss_linux --build_tests_only -c dbg
170+
```
171+
172+
* `<dir>/...` means all targets under the `<dir>/` directory.
173+
174+
175+
### Run tests without the specific directories
176+
177+
```
178+
bazelisk test ... --config oss_linux --build_tests_only -c dbg -- -base/...
179+
```
180+
181+
* `--` means the end of the flags which start from `-`.
182+
* `-<dir>/...` means exclusion of all targets under the `dir`.
183+
184+
185+
### Run the specific test
186+
187+
```
188+
bazelisk test base:util_test --config oss_linux -c dbg
189+
```
190+
191+
* `util_test` is defined in `base/BUILD.bazel`.
192+
193+
### Output logs to stderr
194+
195+
```
196+
bazelisk test base:util_test --config oss_linux --test_arg=--stderrthreshold=0 --test_output=all
197+
```
198+
199+
* The `--test_arg=--stderrthreshold=0 --test_output=all` flags shows the
200+
output of unitests to stderr.
201+
202+
-----
203+
204+
## Build Mozc for Linux Desktop with GYP (deprecated):
205+
206+
⚠️ The GYP build is deprecated and no longer supported.
207+
208+
Please check the previous version for more information.
209+
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

0 commit comments

Comments
 (0)
Please sign in to comment.