Skip to content

Commit

Permalink
Drop Qt 4 support
Browse files Browse the repository at this point in the history
With this CL, --qtver configure option will be removed and Mozc no
longer supports to be built with Qt 4.

BUG=#327
TEST=
REF_BUG=26887740
REF_CL=141386550
REF_TIME=2016-12-08T11:43:38+09:00
REF_TIME_RAW=1481165018 +0900
  • Loading branch information
hiroyuki-komatsu committed Dec 8, 2016
1 parent fdfe0d7 commit 280e38f
Show file tree
Hide file tree
Showing 77 changed files with 71 additions and 614 deletions.
4 changes: 2 additions & 2 deletions docs/build_mozc_in_docker.md
Expand Up @@ -99,13 +99,13 @@ You can use `--target_platform` option to specify the target OS on which Mozc wi
If you don't specify this option, `--target_platform=Linux` will be used implicitly.

#### --noqt (Linux desktop target only)
You can use `--noqt` option to build Mozc without depending on Qt 4 library.
You can use `--noqt` option to build Mozc without depending on Qt 5 library.

#### --server_dir (Linux desktop target only)
You can use `--server_dir` option to specify the directory name where `mozc_server` will be installed.

## Compile options
In `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.
In `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.

```
python build_mozc.py build -c {Release, Debug} [gyp_path_1.gyp:gyp_target_name1] [gyp_path_2.gyp:gyp_target_name2]
Expand Down
24 changes: 3 additions & 21 deletions src/build_mozc.py
Expand Up @@ -272,7 +272,6 @@ def ParseGypOptions(args):
parser.add_option('--gypdir', dest='gypdir',
help='Specifies the location of GYP to be used.')
parser.add_option('--noqt', action='store_true', dest='noqt', default=False)
parser.add_option('--qtver', dest='qtver', choices=('4', '5'), default='5')
parser.add_option('--version_file', dest='version_file',
help='use the specified version template file',
default='data/version/mozc_version_template.bzl')
Expand Down Expand Up @@ -505,7 +504,7 @@ def GypMain(options, unused_args):
if options.noqt or options.target_platform in ['Android', 'NaCl']:
qt_version = ''
else:
qt_version = options.qtver
qt_version = '5'
GenerateVersionFile(template_path, version_path, options.target_platform,
options.android_application_id,
options.android_arch, qt_version)
Expand Down Expand Up @@ -591,12 +590,7 @@ def GypMain(options, unused_args):
gyp_options.extend(['-D', 'qt_dir='])

# Check if Qt libraries are installed.
if options.qtver == '5':
system_qt_found = PkgExists('Qt5Core', 'Qt5Gui', 'Qt5Widgets')
else:
system_qt_found = PkgExists('QtCore >= 4.0', 'QtCore < 5.0',
'QtGui >= 4.0', 'QtGui < 5.0')
if not system_qt_found:
if not PkgExists('Qt5Core', 'Qt5Gui', 'Qt5Widgets'):
PrintErrorAndExit('Qt is required to build GUI Tool. '
'Specify --noqt to skip building GUI Tool.')

Expand All @@ -606,7 +600,6 @@ def GypMain(options, unused_args):
gyp_options.extend(['-D', 'qt_dir=%s' % os.path.abspath(options.qtdir)])
else:
gyp_options.extend(['-D', 'qt_dir='])
gyp_options.extend(['-D', 'qt_ver=%s' % options.qtver])

if target_platform == 'Windows' and options.wix_dir:
gyp_options.extend(['-D', 'use_wix=YES'])
Expand Down Expand Up @@ -773,18 +766,7 @@ def SetCommandLineForFeature(option_name, windows=False, mac=False,
copy_script = os.path.join(
ABS_SCRIPT_DIR, 'build_tools', 'copy_dll_and_symbol.py')
copy_params = []
if qt_version == '4':
copy_params.append({
'basenames': 'QtCored4;QtGuid4',
'dll_paths': abs_qt_bin_dir,
'pdb_paths': abs_qt_lib_dir,
'target_dir': os.path.join(abs_out_win_dir, 'DebugDynamic')})
copy_params.append({
'basenames': 'QtCore4;QtGui4',
'dll_paths': abs_qt_bin_dir,
'pdb_paths': abs_qt_lib_dir,
'target_dir': os.path.join(abs_out_win_dir, 'ReleaseDynamic')})
elif qt_version == '5':
if qt_version == '5':
copy_params.append({
'basenames': 'Qt5Cored;Qt5Guid;Qt5Widgetsd',
'dll_paths': abs_qt_bin_dir,
Expand Down
19 changes: 8 additions & 11 deletions src/build_tools/change_reference_mac.py
Expand Up @@ -48,7 +48,6 @@
def ParseOption():
"""Parse command line options."""
parser = optparse.OptionParser()
parser.add_option('--qtver', dest='qtver', choices=('4', '5'), default='4')
parser.add_option('--qtdir', dest='qtdir')
parser.add_option('--target', dest='target')

Expand Down Expand Up @@ -80,30 +79,28 @@ def main():
if not opt.target:
PrintErrorAndExit('--target option is mandatory.')

qtver = opt.qtver
qtdir = os.path.abspath(opt.qtdir)
target = os.path.abspath(opt.target)

# Changes the reference to QtCore framework from the target application
# From: /path/to/qt/lib/QtCore.framework/Versions/4/QtCore
# From: /path/to/qt/lib/QtCore.framework/Versions/5/QtCore
# To: @executable_path/../../../MozcTool.app/Contents/Frameworks/...
qtcore_framework = GetFrameworkPath('QtCore', qtver)
qtcore_framework = GetFrameworkPath('QtCore', '5')
InstallNameTool(target,
'%s/lib/%s' % (qtdir, qtcore_framework),
GetReferenceTo(qtcore_framework))

# Changes the reference to QtGui framework from the target application
qtgui_framework = GetFrameworkPath('QtGui', qtver)
qtgui_framework = GetFrameworkPath('QtGui', '5')
InstallNameTool(target,
'%s/lib/%s' % (qtdir, qtgui_framework),
GetReferenceTo(qtgui_framework))

if qtver == '5':
# Changes the reference to QtWidgets framework from the target application
qtwidgets_framework = GetFrameworkPath('QtWidgets', '5')
InstallNameTool(target,
'%s/lib/%s' % (qtdir, qtwidgets_framework),
GetReferenceTo(qtwidgets_framework))
# Changes the reference to QtWidgets framework from the target application
qtwidgets_framework = GetFrameworkPath('QtWidgets', '5')
InstallNameTool(target,
'%s/lib/%s' % (qtdir, qtwidgets_framework),
GetReferenceTo(qtwidgets_framework))

# Change the reference to $(branding)Tool_lib from the target application
# From: @executable_path/../Frameworks/MozcTool_lib.framework/...
Expand Down
58 changes: 24 additions & 34 deletions src/build_tools/copy_qt_frameworks_mac.py
Expand Up @@ -49,7 +49,6 @@
def ParseOption():
"""Parse command line options."""
parser = optparse.OptionParser()
parser.add_option('--qtver', dest='qtver', choices=('4', '5'), default='4')
parser.add_option('--qtdir', dest='qtdir')
parser.add_option('--target', dest='target')

Expand Down Expand Up @@ -113,43 +112,34 @@ def main():
if not opt.target:
PrintErrorAndExit('--target option is mandatory.')

qtver = opt.qtver
qtdir = os.path.abspath(opt.qtdir)
target = os.path.abspath(opt.target)

ref_to = '@executable_path/../../../ConfigDialog.app/Contents/Frameworks'
if qtver == '5':
CopyQt(qtdir, 'QtCore', '5', target, copy_resources=True)
CopyQt(qtdir, 'QtGui', '5', target, copy_resources=True)
CopyQt(qtdir, 'QtWidgets', '5', target, copy_resources=True)
CopyQt(qtdir, 'QtPrintSupport', '5', target, copy_resources=True)

ChangeReferences(qtdir, GetFrameworkPath('QtCore', '5'),
'5', target, ref_to)
ChangeReferences(qtdir, GetFrameworkPath('QtGui', '5'),
'5', target, ref_to,
references=['QtCore'])
ChangeReferences(qtdir, GetFrameworkPath('QtWidgets', '5'),
'5', target, ref_to,
references=['QtCore', 'QtGui'])
ChangeReferences(qtdir, GetFrameworkPath('QtPrintSupport', '5'),
'5', target, ref_to,
references=['QtCore', 'QtGui', 'QtWidgets'])

libqcocoa = 'QtCore.framework/Resources/plugins/platforms/libqcocoa.dylib'
CopyFiles(['%s/plugins/platforms/libqcocoa.dylib' % qtdir],
'%s/%s' % (target, libqcocoa))
ChangeReferences(qtdir, libqcocoa, '5', target, ref_to,
references=['QtCore', 'QtGui',
'QtWidgets', 'QtPrintSupport'])
else:
CopyQt(qtdir, 'QtCore', '4', target)
CopyQt(qtdir, 'QtGui', '4', target, copy_resources=True)

ChangeReferences(qtdir, GetFrameworkPath('QtCore', '4'),
'4', target, ref_to)
ChangeReferences(qtdir, GetFrameworkPath('QtGui', '4'),
'4', target, ref_to, references=['QtCore'])

CopyQt(qtdir, 'QtCore', '5', target, copy_resources=True)
CopyQt(qtdir, 'QtGui', '5', target, copy_resources=True)
CopyQt(qtdir, 'QtWidgets', '5', target, copy_resources=True)
CopyQt(qtdir, 'QtPrintSupport', '5', target, copy_resources=True)

ChangeReferences(qtdir, GetFrameworkPath('QtCore', '5'),
'5', target, ref_to)
ChangeReferences(qtdir, GetFrameworkPath('QtGui', '5'),
'5', target, ref_to,
references=['QtCore'])
ChangeReferences(qtdir, GetFrameworkPath('QtWidgets', '5'),
'5', target, ref_to,
references=['QtCore', 'QtGui'])
ChangeReferences(qtdir, GetFrameworkPath('QtPrintSupport', '5'),
'5', target, ref_to,
references=['QtCore', 'QtGui', 'QtWidgets'])

libqcocoa = 'QtCore.framework/Resources/plugins/platforms/libqcocoa.dylib'
CopyFiles(['%s/plugins/platforms/libqcocoa.dylib' % qtdir],
'%s/%s' % (target, libqcocoa))
ChangeReferences(qtdir, libqcocoa, '5', target, ref_to,
references=['QtCore', 'QtGui',
'QtWidgets', 'QtPrintSupport'])


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion src/data/version/mozc_version_template.bzl
Expand Up @@ -30,7 +30,7 @@

MAJOR=2
MINOR=20
BUILD=2672
BUILD=2673
REVISION=102
# This version represents the version of Mozc IME engine (converter, predictor,
# etc.). This version info is included both in the Mozc server and in the Mozc
Expand Down
4 changes: 0 additions & 4 deletions src/gui/about_dialog/about_dialog.h
Expand Up @@ -32,11 +32,7 @@
#ifndef MOZC_GUI_ABOUT_DIALOG_ABOUT_DIALOG_H_
#define MOZC_GUI_ABOUT_DIALOG_ABOUT_DIALOG_H_

#ifdef MOZC_USE_QT5
#include <QtWidgets/QDialog>
#else
#include <QtGui/QDialog>
#endif

#include <memory>

Expand Down
4 changes: 0 additions & 4 deletions src/gui/about_dialog/about_dialog_libmain.cc
Expand Up @@ -27,11 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifdef MOZC_USE_QT5
#include <QtGui/QGuiApplication>
#else
#include <QtGui/QApplication>
#endif
#include <QtGui/QtGui>
#include "base/system_util.h"
#include "gui/about_dialog/about_dialog.h"
Expand Down
5 changes: 1 addition & 4 deletions src/gui/administration_dialog/administration_dialog.cc
Expand Up @@ -29,11 +29,8 @@

#include "gui/administration_dialog/administration_dialog.h"

#ifdef MOZC_USE_QT5
#include <QtWidgets/QMessageBox>
#else
#include <QtGui/QMessageBox>
#endif

#include "base/run_level.h"
#include "config/stats_config_util.h"
#include "server/cache_service_manager.h"
Expand Down
5 changes: 1 addition & 4 deletions src/gui/administration_dialog/administration_dialog.h
Expand Up @@ -31,11 +31,8 @@
#define MOZC_GUI_ADMINISTRATION_DIALOG_H_

#include <QtGui/QtGui>
#ifdef MOZC_USE_QT5
#include <QtWidgets/QDialog>
#else
#include <QtGui/QDialog>
#endif

#include <string>
#include "gui/administration_dialog/ui_administration_dialog.h"

Expand Down
Expand Up @@ -27,12 +27,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifdef MOZC_USE_QT5
#include <QtGui/QGuiApplication>
#else
#include <QtGui/QApplication>
#endif
#include <QtGui/QtGui>

#include "base/system_util.h"
#include "gui/administration_dialog/administration_dialog.h"
#include "gui/base/locale_util.h"
Expand Down
19 changes: 0 additions & 19 deletions src/gui/base/debug_util.cc
Expand Up @@ -36,7 +36,6 @@
namespace mozc {
namespace gui {

#ifdef MOZC_USE_QT5
void DebugUtil::MessageHandler(QtMsgType type,
const QMessageLogContext &context,
const QString &q_msg) {
Expand All @@ -57,24 +56,6 @@ void DebugUtil::MessageHandler(QtMsgType type,
break;
}
}
#else // ! MOZC_USE_QT5
void DebugUtil::MessageHandler(QtMsgType type, const char *msg) {
switch (type) {
case QtDebugMsg:
LOG(INFO) << msg;
break;
case QtWarningMsg:
LOG(WARNING) << msg;
break;
case QtCriticalMsg:
LOG(ERROR) << msg;
break;
case QtFatalMsg:
LOG(FATAL) << msg;
break;
}
}
#endif // ! MOZC_USE_QT5

} // namespace gui
} // namespace mozc
8 changes: 0 additions & 8 deletions src/gui/base/debug_util.h
Expand Up @@ -33,11 +33,7 @@
#define MOZC_GUI_BASE_DEBUG_UTIL_H_

#include <string>
#ifdef MOZC_USE_QT5
#include <QtGui/QGuiApplication>
#else
#include <QtGui/QApplication>
#endif

namespace mozc {
namespace gui {
Expand All @@ -46,13 +42,9 @@ class DebugUtil {
public:
// Callback function used as a Qt message handler which is called when Qt
// message functions (qDebug, qWarning, qCritical and qFatal) are called.
#ifdef MOZC_USE_QT5
static void MessageHandler(QtMsgType type,
const QMessageLogContext &context,
const QString &q_msg);
#else
static void MessageHandler(QtMsgType type, const char *msg);
#endif

private:
DebugUtil() {}
Expand Down
11 changes: 0 additions & 11 deletions src/gui/base/locale_util.cc
Expand Up @@ -44,12 +44,7 @@
#include <CommCtrl.h> // for CCSIZEOF_STRUCT
#endif

#ifdef MOZC_USE_QT5
#include <QtGui/QGuiApplication>
#else
#include <QtCore/QTextCodec>
#include <QtGui/QApplication>
#endif

#include <QtGui/QtGui>
#include <map>
Expand Down Expand Up @@ -114,12 +109,6 @@ TranslationDataImpl::TranslationDataImpl() {
if (loaded) {
qApp->installTranslator(&default_translator_);
}

#ifndef MOZC_USE_QT5
// Set default encoding for multi-byte string to be UTF8
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
#endif
}

void TranslationDataImpl::InstallTranslationMessageAndFont(
Expand Down
4 changes: 0 additions & 4 deletions src/gui/base/table_util.cc
Expand Up @@ -29,11 +29,7 @@

#include "gui/base/table_util.h"

#ifdef MOZC_USE_QT5
#include <QtWidgets/QTableWidget>
#else
#include <QtGui/QTableWidget>
#endif

namespace mozc {
namespace gui {
Expand Down
9 changes: 0 additions & 9 deletions src/gui/base/window_title_modifier.cc
Expand Up @@ -29,14 +29,9 @@

#include <QtCore/QObject>
#include <QtCore/QString>
#ifdef MOZC_USE_QT5
#include <QtGui/QGuiApplication>
#include <QtWidgets/QApplication>
#include <QtWidgets/QWidget>
#else
#include <QtGui/QApplication>
#include <QtGui/QWidget>
#endif

#include "base/version.h"
#include "gui/base/window_title_modifier.h"
Expand All @@ -45,11 +40,7 @@ namespace mozc {
namespace gui {
bool WindowTitleModifier::eventFilter(QObject *obj,
QEvent *event) {
#ifdef MOZC_USE_QT5
QWidget *w = QApplication::activeWindow();
#else
QWidget *w = qApp->activeWindow();
#endif
if (w != NULL && obj != NULL && w == obj &&
QEvent::WindowActivate == event->type() &&
w->windowTitle().indexOf(prefix_) == -1) {
Expand Down

0 comments on commit 280e38f

Please sign in to comment.