Skip to content
Permalink
Browse files

Build Zinnia from source by default.

With following commits, we can now build Zinnia from source even on
Windows and Ubuntu 14.04.
 - taku910/zinnia#2
 - taku910/zinnia#3
 - taku910/zinnia#4
Thus we don't need to conditionally disable Zinnia only on Windows
anymore.

'--use_zinnia' option in build_mozc.py can also be removed.  To simplify
the DEPS rule and improve the code/test coverage this CL also updates
gyp/common.gypi so that Zinnia will be compiled from source even on
Linux by default.  Users and packagers are still able to use
system-installed Zinnia by manually specifying following GYP_DEFINES
environment variable as follows.
  GYP_DEFINES="use_libzinnia=1".

With this CL, we no longer need subversion to check out OSS Mozc.
Closes #299.

No user-visible behavior change is intended with this CL.

BUG=#299
TEST=unittest
REF_BUG=6443612,23909405
REF_CL=102630042,103073294
  • Loading branch information...
yukawa committed Sep 19, 2015
1 parent 0f4b21b commit 03c3155de88f2a1c0c639da712a6f9bb88d5714a
@@ -47,6 +47,8 @@ install:
- git -C src/third_party/japanese_usage_dictionary checkout e5b3425575734c323e1d947009dd74709437b684
- git submodule add https://github.com/googlei18n/fonttools.git src/third_party/fontTools
- git -C src/third_party/fontTools checkout 5ba7d98a4153fad57258fca23b0bcb238717aec3
- git submodule add https://github.com/taku910/zinnia.git src/third_party/zinnia
- git -C src/third_party/zinnia checkout 44dddcf96c0970a806d666030295706f45cbd045
- git submodule add https://chromium.googlesource.com/chromium/tools/depot_tools.git src/third_party/depot_tools
- export PATH="$PATH":`pwd`/src/third_party/depot_tools

@@ -52,7 +52,8 @@ install:
- git -C src/third_party/japanese_usage_dictionary checkout e5b3425575734c323e1d947009dd74709437b684
- git submodule add https://chromium.googlesource.com/breakpad/breakpad src/third_party/breakpad
- git -C src/third_party/breakpad checkout d2904bb42181bc32c17b26ac4a0604c0e57473cc
- svn export http://svn.code.sf.net/p/zinnia/code@16 src/third_party/zinnia/v0_04
- git submodule add https://github.com/taku910/zinnia.git src/third_party/zinnia
- git -C src/third_party/zinnia checkout 44dddcf96c0970a806d666030295706f45cbd045
build_script:
- python src\build_mozc.py gyp --noqt
- ninja -C src\out_win\Release mozc_cache_service mozc_renderer mozc_ime mozc_tip32 mozc_broker32 rewriter composer
@@ -35,7 +35,7 @@ vars = {
"gyp_revision": "cdf037c1edc0ba3b5d25f8e3973661efe00980cc",
"jsoncpp_revision": "11086dd6a7eba04289944367ca82cea71299ed70",
"protobuf_revision": "172019c40bf548908ab09bfd276074c929d48415",
"zinnia_revision": "16",
"zinnia_revision": "44dddcf96c0970a806d666030295706f45cbd045",
"zlib_revision": "50893291621658f355bc5b4d450a8d06a563053d",
"japanese_usage_dictionary_revision": "e5b3425575734c323e1d947009dd74709437b684",
}
@@ -55,21 +55,15 @@ deps = {
"src/third_party/japanese_usage_dictionary":
"https://github.com/hiroyuki-komatsu/japanese-usage-dictionary.git@" +
Var("japanese_usage_dictionary_revision"),
"src/third_party/zinnia":
"https://github.com/taku910/zinnia.git@" + Var("zinnia_revision"),
}

deps_os = {
"win": {
"src/third_party/breakpad":
"https://chromium.googlesource.com/breakpad/breakpad@" +
Var("breakpad_revision"),
"src/third_party/zinnia/v0_04":
"http://svn.code.sf.net/p/zinnia/code@" +
Var("zinnia_revision"),
},
"mac": {
"src/third_party/zinnia/v0_04":
"http://svn.code.sf.net/p/zinnia/code@" +
Var("zinnia_revision"),
},
"unix": {
"src/third_party/fontTools":
@@ -469,16 +469,6 @@ def AddFeatureOption(option_parser, feature_name, macro_name,
macro_name='MOZC_ENABLE_MODE_INDICATOR',
option_name='mode_indicator')

# TODO(yukawa): Remove this option when Zinnia can be built on Windows with
# enabling Unicode.
use_zinnia_default = True
if IsWindows():
# Zinnia on Windows cannot be enabled because of compile error.
use_zinnia_default = False
parser.add_option('--use_zinnia', dest='use_zinnia',
default=use_zinnia_default,
help='Use Zinnia if specified.')

if IsWindows():
parser.add_option('--wix_dir', dest='wix_dir',
default=GetDefaultWixPath(),
@@ -879,16 +869,10 @@ def SetCommandLineForFeature(option_name, windows=False, mac=False,
else:
gyp_options.extend(['-D', 'use_dynamically_linked_qt=0'])

if options.use_zinnia and target_platform not in ['Android', 'NaCl']:
gyp_options.extend(['-D', 'use_zinnia=YES'])
else:
gyp_options.extend(['-D', 'use_zinnia=NO'])

if (options.target_platform == 'Linux' and
'%s/unix/ibus/ibus.gyp' % SRC_DIR in gyp_file_names):
gyp_options.extend(['-D', 'use_libibus=1'])


# Dictionary configuration
if target_platform == 'Android':
gyp_options.extend(['-D', 'dictionary=small'])
@@ -1869,7 +1869,7 @@ <h3>WTL is licensed as follows:</h3>
<div class="product">
<span class="title">zinnia</span>
<span class="homepage">
<a href="http://zinnia.sourceforge.net/">homepage</a></span>
<a href="https://github.com/taku910/zinnia">homepage</a></span>
<div class="licence">
<h3>zinnia is licensed as follows:</h3>
<pre>
@@ -1869,7 +1869,7 @@ <h3>WTL のライセンス:</h3>
<div class="product">
<span class="title">zinnia</span>
<span class="homepage">
<a href="http://zinnia.sourceforge.net/">ホームページ</a></span>
<a href="https://github.com/taku910/zinnia">ホームページ</a></span>
<div class="licence">
<h3>zinnia のライセンス:</h3>
<pre>
@@ -32,9 +32,9 @@ FROM fedora:21
# Package installation
RUN yum -y update
## Common packages for linux build environment
RUN yum install -y clang libstdc++-static python subversion git curl bzip2 unzip
RUN yum install -y clang libstdc++-static python git curl bzip2 unzip
## Packages for linux desktop version
RUN yum install -y ibus-devel glib2-devel qt-devel zinnia-devel zinnia-tomoe-ja gtk2-devel libxcb-devel
RUN yum install -y ibus-devel glib2-devel qt-devel zinnia-tomoe-ja gtk2-devel libxcb-devel
## Packages for Android
RUN yum install -y java-1.7.0-openjdk-devel jsr-305 ant glibc.i686 glibc-devel.i686 libstdc++.i686 ncurses-devel.i686 zlib-devel.i686 zip
## For emacsian
@@ -35,9 +35,9 @@ ENV DEBIAN_FRONTEND noninteractive
RUN dpkg --add-architecture i386
RUN apt-get update
## Common packages for linux build environment
RUN apt install -y clang python pkg-config subversion git curl bzip2 unzip make
RUN apt install -y clang python pkg-config git curl bzip2 unzip make
## Packages for linux desktop version
RUN apt install -y libibus-1.0-dev libdbus-1-dev libglib2.0-dev subversion libqt4-dev libzinnia-dev tegaki-zinnia-japanese libgtk2.0-dev libxcb-xfixes0-dev
RUN apt install -y libibus-1.0-dev libdbus-1-dev libglib2.0-dev libqt4-dev tegaki-zinnia-japanese libgtk2.0-dev libxcb-xfixes0-dev
## Packages for Android
RUN apt install -y --no-install-recommends openjdk-7-jdk openjdk-7-jre-headless libjsr305-java ant libc6:i386 libstdc++6:i386 libncurses5:i386 zlib1g:i386 zip
## Packages for NaCl
@@ -387,11 +387,6 @@
'../protocol/protocol.gyp:commands_proto',
],
}],
['use_libzinnia==1 and OS=="linux"', {
'defines': [
'USE_LIBZINNIA',
],
}],
],
},
{
@@ -877,6 +872,7 @@
'../config/config.gyp:stats_config_util',
'about_dialog_lib',
'administration_dialog_lib',
'character_pad_lib',
'config_dialog_lib',
'confirmation_dialog_lib',
'dictionary_tool_lib',
@@ -924,14 +920,6 @@
}, {
'type': 'static_library',
}],
['use_zinnia=="YES"', {
'dependencies+': [
'character_pad_lib',
],
'defines': [
'USE_ZINNIA',
],
}],
],
},
{
@@ -57,17 +57,8 @@ int RunConfigDialog(int argc, char *argv[]);
int RunDictionaryTool(int argc, char *argv[]);
int RunWordRegisterDialog(int argc, char *argv[]);
int RunErrorMessageDialog(int argc, char *argv[]);

// TODO(yukawa): Remove this macro when Zinnia becomes available on Windows.
#ifdef USE_ZINNIA
// Currently the following functions are provided from the same library
// named "character_pad_lib", which requires Zinnia to be built.
// So we need to disable both of them when Zinnia is not available.
// TODO(yukawa): Separate RunCharacterPalette so that we can use it
// even when Zinnia is not available.
int RunCharacterPalette(int argc, char *argv[]);
int RunHandWriting(int argc, char *argv[]);
#endif // USE_ZINNIA

#ifdef OS_WIN
// (SetDefault|PostInstall|RunAdministartion)Dialog are used for Windows only.
@@ -133,12 +124,10 @@ int RunMozcTool(int argc, char *argv[]) {
// "System Preferences" -> "Accounts" -> "Login items".
// So we set kProductPrefix to the binary name.
FLAGS_mode = "prelauncher";
#ifdef USE_ZINNIA
} else if (binary_name == "HandWriting") {
FLAGS_mode = "hand_writing";
} else if (binary_name == "CharacterPalette") {
FLAGS_mode = "character_palette";
#endif // USE_ZINNIA
}
#endif

@@ -170,12 +159,10 @@ int RunMozcTool(int argc, char *argv[]) {
return RunErrorMessageDialog(argc, argv);
} else if (FLAGS_mode == "about_dialog") {
return RunAboutDialog(argc, argv);
#ifdef USE_ZINNIA
} else if (FLAGS_mode == "character_palette") {
return RunCharacterPalette(argc, argv);
} else if (FLAGS_mode == "hand_writing") {
return RunHandWriting(argc, argv);
#endif // USE_ZINNIA
#ifdef OS_WIN
} else if (FLAGS_mode == "set_default_dialog") {
// set_default_dialog is used on Windows only.
@@ -225,9 +225,9 @@
# for the background information.
'use_libprotobuf%': 0,

# use_libzinnia represents if zinnia library is used or not.
# This option is only for Linux.
'use_libzinnia%': 1,
# Set '1' to use system-instaleld zinnia library. Otherwise
# zinnia will be built from source as needed.
'use_libzinnia%': 0,

# use_libxml represents if libxml library is used or not.
# This option is only for Linux.
@@ -43,12 +43,7 @@
'zinnia.gyp:zinnia',
],
'conditions': [
['target_platform=="Linux" and use_libzinnia==1', {
'defines': [
'USE_LIBZINNIA',
],
}],
['target_platform=="Linux" and use_libzinnia==1 and zinnia_model_file!=""', {
['zinnia_model_file!=""', {
'defines': [
'MOZC_ZINNIA_MODEL_FILE="<(zinnia_model_file)"',
],
@@ -28,63 +28,71 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

{
'variables': {
'zinnia_sources': [
'<(DEPTH)/third_party/zinnia/v0_04/character.cpp',
'<(DEPTH)/third_party/zinnia/v0_04/param.cpp',
'<(DEPTH)/third_party/zinnia/v0_04/svm.cpp',
'<(DEPTH)/third_party/zinnia/v0_04/feature.cpp',
'<(DEPTH)/third_party/zinnia/v0_04/recognizer.cpp',
'<(DEPTH)/third_party/zinnia/v0_04/trainer.cpp',
'<(DEPTH)/third_party/zinnia/v0_04/libzinnia.cpp',
'<(DEPTH)/third_party/zinnia/v0_04/sexp.cpp',
],
},
'targets': [
{
'target_name': 'zinnia',
'type': 'static_library',
'cflags': [
'-Wno-type-limits',
],
'conditions': [
['OS=="linux"', {
'conditions': [
['use_libzinnia==1', {
'link_settings': {
'libraries': [
'<!@(<(pkg_config_command) --libs zinnia)',
],
},
}, { # OS=="linux" and use_libzinnia==0
'sources': ['<@(zinnia_sources)'],
'defines': ['HAVE_CONFIG_H'],
}],
['use_libzinnia==1', {
'type': 'none',
'link_settings': {
'libraries': [
'<!@(<(pkg_config_command) --libs zinnia)',
],
},
}, { # use_libzinnia==0
'type': 'static_library',
'variables': {
'zinnia_src_dir': '<(third_party_dir)/zinnia/zinnia',
},
'sources': [
'<(zinnia_src_dir)/character.cpp',
'<(zinnia_src_dir)/param.cpp',
'<(zinnia_src_dir)/svm.cpp',
'<(zinnia_src_dir)/feature.cpp',
'<(zinnia_src_dir)/recognizer.cpp',
'<(zinnia_src_dir)/trainer.cpp',
'<(zinnia_src_dir)/libzinnia.cpp',
'<(zinnia_src_dir)/sexp.cpp',
],
}],
['OS=="mac"', {
'sources': ['<@(zinnia_sources)'],
'defines': ['HAVE_CONFIG_H'],
}],
['(_toolset=="target" and compiler_target=="clang") or '
'(_toolset=="host" and compiler_host=="clang")', {
'cflags': [
'-Wno-missing-field-initializers',
'-Wno-tautological-compare',
'include_dirs': [
# So that dependent file can look up <zinnia.h>
'<(zinnia_src_dir)',
],
}],
['OS=="win"', {
'sources': ['<@(zinnia_sources)'],
'defines': [
'VERSION="0.04"',
'PACKAGE="zinnia"',
'HAVE_WINDOWS_H',
'all_dependent_settings': {
'include_dirs': [
# So that dependent file can look up <zinnia.h>
'<(zinnia_src_dir)',
],
},
'cflags': [
'-Wno-type-limits',
],
'msvs_disabled_warnings': [
# destructor never returns, potential memory leak
# http://msdn.microsoft.com/en-us/library/khwfyc5d.aspx
'4722', # Zinnia contains this kind of code
],
'conditions': [
['target_platform=="Windows"', {
'defines': [
'HAVE_WINDOWS_H=1',
'PACKAGE="zinnia"',
'VERSION="0.06"',
],
}],
['target_platform=="Linux" or target_platform=="Mac"', {
'defines': [
'HAVE_CONFIG_H=1'
],
}],
['(_toolset=="target" and compiler_target=="clang") or '
'(_toolset=="host" and compiler_host=="clang")', {
'cflags': [
'-Wno-missing-field-initializers',
'-Wno-tautological-compare',
],
}],
],
}],
],
},
@@ -45,25 +45,23 @@ const uint32 kBoxSize = 200;

// static
string ZinniaHandwriting::GetModelFileName() {
#ifdef OS_MACOSX
#if defined(MOZC_ZINNIA_MODEL_FILE)
const char kModelFile[] = MOZC_ZINNIA_MODEL_FILE;
return kModelFile;
#elif defined(OS_MACOSX)
// TODO(komatsu): Fix the file name to "handwriting-ja.model" like the
// Windows implementation regardless which data file is actually
// used. See also gui.gyp:hand_writing_mac.
const char kModelFile[] = "handwriting-light-ja.model";
return FileUtil::JoinPath(MacUtil::GetResourcesDirectory(), kModelFile);
#elif defined(USE_LIBZINNIA)
// On Linux, use the model for tegaki-zinnia.
#if defined(MOZC_ZINNIA_MODEL_FILE)
const char kModelFile[] = MOZC_ZINNIA_MODEL_FILE;
#else
#elif defined(OS_LINUX)
const char kModelFile[] =
"/usr/share/tegaki/models/zinnia/handwriting-ja.model";
#endif // MOZC_ZINNIA_MODEL_FILE
return kModelFile;
#else
const char kModelFile[] = "handwriting-ja.model";
return FileUtil::JoinPath(SystemUtil::GetServerDirectory(), kModelFile);
#endif // OS_MACOSX
#endif
}

ZinniaHandwriting::ZinniaHandwriting(StringPiece model_file)
@@ -39,12 +39,7 @@
#include "base/string_piece.h"
#include "handwriting/handwriting_manager.h"

#ifdef USE_LIBZINNIA
// Use default zinnia installed in /usr/include
#include <zinnia.h>
#else // USE_LIBZINNIA
#include "third_party/zinnia/v0_04/zinnia.h"
#endif // USE_LIBZINNIA

namespace mozc {
class Mmap;

0 comments on commit 03c3155

Please sign in to comment.
You can’t perform that action at this time.