1How to build Mozc in Docker 2=========================== 3 4# Introduction 5Docker containers are available to build Mozc binaries for Android, NaCl, and Linux desktop. 6 7# System Requirements 8Currently, only Ubuntu 14.04 is tested to host the Docker container to build Mozc. See [official document](https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/) to set up Docker for Ubuntu 14.04. 9 10## Set up Ubuntu 14.04 Docker container 11 12``` 13mkdir ubuntu14.04 && cd ubuntu14.04 14curl -O https://raw.githubusercontent.com/google/mozc/master/docker/ubuntu14.04/Dockerfile 15sudo docker build --rm -t $USER/mozc_ubuntu14.04 . 16sudo docker run --interactive --tty --rm $USER/mozc_ubuntu14.04 17``` 18 19## Set up Fedora 23 Docker container 20Fedora 23 container is also provided just for your reference. 21 22Building Mozc for Android is not supported on Fedora 23 due to the lack of OpenJDK 1.7 support. See [Red Hat Bugzilla – Bug 1190137](https://bugzilla.redhat.com/show_bug.cgi?id=1190137) for details. 23``` 24mkdir fedora23 && cd fedora23 25curl -O https://raw.githubusercontent.com/google/mozc/master/docker/fedora23/Dockerfile 26sudo docker build --rm -t $USER/mozc_fedora23 . 27sudo docker run --interactive --tty --rm $USER/mozc_fedora23 28``` 29 30### Hint 31Don't forget to rebuild Docker container when Dockerfile is updated. 32 33# Build in the container 34Before explaining detailed build configurations and options, let's walk through the simplest cases to see how it looks like. 35 36### Build Mozc for Android: 37 38``` 39python build_mozc.py gyp --target_platform=Android 40python build_mozc.py build -c Debug android/android.gyp:apk 41``` 42 43### Build Mozc for NaCl: 44 45``` 46python build_mozc.py gyp --target_platform=NaCl --nacl_sdk_root=$NACL_SDK_ROOT 47python build_mozc.py build -c Release chrome/nacl/nacl_extension.gyp:nacl_mozc 48``` 49 50### Build Mozc for Linux Desktop: 51 52``` 53python build_mozc.py gyp --target_platform=Linux 54python build_mozc.py build -c Release unix/ibus/ibus.gyp:ibus_mozc unix/emacs/emacs.gyp:mozc_emacs_helper server/server.gyp:mozc_server gui/gui.gyp:mozc_tool renderer/renderer.gyp:mozc_renderer 55``` 56 57You can also run unittests as follows. 58 59``` 60python build_mozc.py runtests -c Debug 61``` 62 63## Build configurations 64In `python build_mozc.py gyp` step, there are two different styles to customize configurations. One is `GYP_DEFINES` environment variable and the other is commandline option. 65 66``` 67[GYP_DEFINES="..."] python build_mozc.py gyp [options] 68``` 69 70### GYP_DEFINES 71You can specify `GYP_DEFINES` environment variable to change variables in GYP files, which you can find many directories in Mozc's source tree. [common.gypi](../src/gyp/common.gypi) is an example. 72Here are examples of GYP variables that you may want to change for Linux desktop build. 73 74 * `document_dir`: Directory path where Mozc's license file is placed 75 * `ibus_mozc_path`: ibus-mozc executable path 76 * `ibus_mozc_icon_path`: ibus-mozc icon path 77 * `zinnia_model_file`: Zinnia's model data path 78 79Note that you can specify multiple GYP variables as follows. 80 81``` 82GYP_DEFINES="ibus_mozc_path=/usr/lib/ibus-mozc/ibus-engine-mozc ibus_mozc_icon_path=/usr/share/ibus-mozc/product_icon.png document_dir=/usr/share/doc/mozc zinnia_model_file=/usr/share/zinnia/model/tomoe/handwriting-ja.model" python build_mozc.py gyp 83``` 84 85### command line options 86You can find many command line options as follows. 87``` 88python build_mozc.py gyp --help 89``` 90Here we show some notable options. 91 92#### --target_platform 93You can use `--target_platform` option to specify the target OS on which Mozc will run. Following options are available. 94 95 * `Android` 96 * `NaCl` 97 * `Linux` (default) 98 99If you don't specify this option, `--target_platform=Linux` will be used implicitly. 100 101#### --noqt (Linux desktop target only) 102You can use `--noqt` option to build Mozc without depending on Qt 5 library. 103 104#### --server_dir (Linux desktop target only) 105You can use `--server_dir` option to specify the directory name where `mozc_server` will be installed. 106 107## Compile options 108In `build_mozc.py build` step, you can specify build types (`Release` or `Debug`) and one or more build targets. Please find each GYP file to see what build targets are defined. 109 110``` 111python build_mozc.py build -c {Release, Debug} [gyp_path_1.gyp:gyp_target_name1] [gyp_path_2.gyp:gyp_target_name2] 112``` 113 114## Android specific topics 115 116### Application package name 117 118**CAUTION**: Currently the application package name is fixed (org.mozc.android.inputmethod.japanese). Don't publish the built package. If you want to publish, specify `--android_application_id` to `build_mozc.py gyp` command and manually update related files. 119 120### zipalign 121 122Android version of Mozc may not run if the APK file is not aligned with [zipalign](https://developer.android.com/tools/help/zipalign.html) command. 123