Codebase list mozc / c5dfc23
Support Qt5 behind --qtver=5 option Now you can build Mozc with Qt5 behind a build option on OS X. To do that, add an option as follows. python build_mozc.py gyp --qtver=5 BUG=#327 TEST= REF_BUG=26887740 REF_CL=114060144 REF_TIME=2016-02-08T02:32:42+09:00 REF_TIME_RAW=1454866362 +0900 Hiroyuki Komatsu 8 years ago
12 changed file(s) with 164 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
338338 parser.add_option('--gypdir', dest='gypdir',
339339 help='Specifies the location of GYP to be used.')
340340 parser.add_option('--noqt', action='store_true', dest='noqt', default=False)
341 parser.add_option('--qtver', dest='qtver', choices=('4', '5'), default='4')
341342 parser.add_option('--version_file', dest='version_file',
342343 help='use the specified version template file',
343344 default='mozc_version_template.txt')
487488 elif target_platform == 'Mac':
488489 targets = [SRC_DIR + '/mac/mac.gyp:DiskImage']
489490 elif target_platform == 'Windows':
491 # TODO(yukawa, komatsu): Support Qt5
490492 targets = ['out_win/%s:mozc_win32_build32' % options.configuration]
491493 build_dir = os.path.abspath(os.path.join(
492494 GetBuildBaseName(options, target_platform),
672674 if options.branding:
673675 gyp_options.extend(['-D', 'branding=%s' % options.branding])
674676
677 # Qt configurations
675678 if options.noqt or target_platform in ['Android', 'NaCl']:
676679 gyp_options.extend(['-D', 'use_qt=NO'])
677680 gyp_options.extend(['-D', 'qt_dir='])
680683 gyp_options.extend(['-D', 'qt_dir='])
681684
682685 # Check if Qt libraries are installed.
683 system_qt_found = PkgExists('QtCore >= 4.0', 'QtCore < 5.0',
684 'QtGui >= 4.0', 'QtGui < 5.0')
686 if options.qtver == '5':
687 system_qt_found = PkgExists('Qt5Core', 'Qt5Gui', 'Qt5Widgets')
688 else:
689 system_qt_found = PkgExists('QtCore >= 4.0', 'QtCore < 5.0',
690 'QtGui >= 4.0', 'QtGui < 5.0')
685691 if not system_qt_found:
686 PrintErrorAndExit('Qt4 is required to build GUI Tool. '
692 PrintErrorAndExit('Qt is required to build GUI Tool. '
687693 'Specify --noqt to skip building GUI Tool.')
694
688695 else:
689696 gyp_options.extend(['-D', 'use_qt=YES'])
690697 if options.qtdir:
691698 gyp_options.extend(['-D', 'qt_dir=%s' % os.path.abspath(options.qtdir)])
692699 else:
693700 gyp_options.extend(['-D', 'qt_dir='])
701 gyp_options.extend(['-D', 'qt_ver=%s' % options.qtver])
694702
695703 if options.target_platform == 'Windows' and options.wix_dir:
696704 gyp_options.extend(['-D', 'use_wix=YES'])
4747 def ParseOption():
4848 """Parse command line options."""
4949 parser = optparse.OptionParser()
50 parser.add_option('--qtver', dest='qtver', choices=('4', '5'), default='4')
5051 parser.add_option('--qtdir', dest='qtdir')
5152 parser.add_option('--target', dest='target')
5253
7879 if not opt.target:
7980 PrintErrorAndExit('--target option is mandatory.')
8081
82 qtver = opt.qtver
8183 qtdir = os.path.abspath(opt.qtdir)
8284 target = os.path.abspath(opt.target)
8385
8486 # Changes the reference to QtCore framework from the target application
8587 # From: /path/to/qt/lib/QtCore.framework/Versions/4/QtCore
8688 # To: @executable_path/../../../MozcTool.app/Contents/Frameworks/...
87 qtcore_framework = GetFrameworkPath('QtCore', '4')
89 qtcore_framework = GetFrameworkPath('QtCore', qtver)
8890 InstallNameTool(target,
8991 '%s/lib/%s' % (qtdir, qtcore_framework),
9092 GetReferenceTo(qtcore_framework))
9193
9294 # Changes the reference to QtGui framework from the target application
93 qtgui_framework = GetFrameworkPath('QtGui', '4')
95 qtgui_framework = GetFrameworkPath('QtGui', qtver)
9496 InstallNameTool(target,
9597 '%s/lib/%s' % (qtdir, qtgui_framework),
9698 GetReferenceTo(qtgui_framework))
99
100 if qtver == '5':
101 # Changes the reference to QtWidgets framework from the target application
102 qtwidgets_framework = GetFrameworkPath('QtWidgets', '5')
103 InstallNameTool(target,
104 '%s/lib/%s' % (qtdir, qtwidgets_framework),
105 GetReferenceTo(qtwidgets_framework))
97106
98107 # Change the reference to $(branding)Tool_lib from the target application
99108 # From: @executable_path/../Frameworks/MozcTool_lib.framework/...
4848 def ParseOption():
4949 """Parse command line options."""
5050 parser = optparse.OptionParser()
51 parser.add_option('--qtver', dest='qtver', choices=('4', '5'), default='4')
5152 parser.add_option('--qtdir', dest='qtdir')
5253 parser.add_option('--target', dest='target')
5354
7475 '%s/%s.framework/Resources' % (target, qtlib),
7576 recursive=True)
7677
77 # For codesign, Info.plist should be copied to Resources/.
78 CopyFiles(['%s/lib/%s.framework/Contents/Info.plist' % (qtdir, qtlib)],
79 '%s/%s.framework/Resources/Info.plist' % (target, qtlib))
78 if version == '4':
79 # For codesign, Info.plist should be copied to Resources/.
80 CopyFiles(['%s/lib/%s.framework/Contents/Info.plist' % (qtdir, qtlib)],
81 '%s/%s.framework/Resources/Info.plist' % (target, qtlib))
8082
8183
82 def ChangeReferences(qtdir, qtlib, version, target, ref_to, references=None):
84 def ChangeReferences(qtdir, path, version, target, ref_to, references=None):
8385 """Change the references of frameworks, by using install_name_tool."""
84 framework_path = GetFrameworkPath(qtlib, version)
8586
8687 # Change id
8788 cmd = ['install_name_tool',
88 '-id', '%s/%s' % (ref_to, framework_path),
89 '%s/%s' % (target, framework_path)]
89 '-id', '%s/%s' % (ref_to, path),
90 '%s/%s' % (target, path)]
9091 RunOrDie(cmd)
9192
9293 if not references:
9899 change_cmd = ['install_name_tool', '-change',
99100 '%s/lib/%s' % (qtdir, ref_framework_path),
100101 '%s/%s' % (ref_to, ref_framework_path),
101 '%s/%s' % (target, framework_path)]
102 '%s/%s' % (target, path)]
102103 RunOrDie(change_cmd)
103104
104105
111112 if not opt.target:
112113 PrintErrorAndExit('--target option is mandatory.')
113114
115 qtver = opt.qtver
114116 qtdir = os.path.abspath(opt.qtdir)
115117 target = os.path.abspath(opt.target)
116118
117 CopyQt(qtdir, 'QtCore', '4', target)
118 CopyQt(qtdir, 'QtGui', '4', target, copy_resources=True)
119 ref_to = '@executable_path/../../../GuiTool.app/Contents/Frameworks'
120 if qtver == '5':
121 CopyQt(qtdir, 'QtCore', '5', target, copy_resources=True)
122 CopyQt(qtdir, 'QtGui', '5', target, copy_resources=True)
123 CopyQt(qtdir, 'QtWidgets', '5', target, copy_resources=True)
124 CopyQt(qtdir, 'QtPrintSupport', '5', target, copy_resources=True)
119125
120 ref_to = '@executable_path/../../../GuiTool.app/Contents/Frameworks'
121 ChangeReferences(qtdir, 'QtCore', '4', target, ref_to)
122 ChangeReferences(qtdir, 'QtGui', '4', target, ref_to, references=['QtCore'])
126 ChangeReferences(qtdir, GetFrameworkPath('QtCore', '5'),
127 '5', target, ref_to)
128 ChangeReferences(qtdir, GetFrameworkPath('QtGui', '5'),
129 '5', target, ref_to,
130 references=['QtCore'])
131 ChangeReferences(qtdir, GetFrameworkPath('QtWidgets', '5'),
132 '5', target, ref_to,
133 references=['QtCore', 'QtGui'])
134 ChangeReferences(qtdir, GetFrameworkPath('QtPrintSupport', '5'),
135 '5', target, ref_to,
136 references=['QtCore', 'QtGui', 'QtWidgets'])
137
138 libqcocoa = 'QtCore.framework/Resources/plugins/platforms/libqcocoa.dylib'
139 CopyFiles(['%s/plugins/platforms/libqcocoa.dylib' % qtdir],
140 '%s/%s' % (target, libqcocoa))
141 ChangeReferences(qtdir, libqcocoa, '5', target, ref_to,
142 references=['QtCore', 'QtGui',
143 'QtWidgets', 'QtPrintSupport'])
144 else:
145 CopyQt(qtdir, 'QtCore', '4', target)
146 CopyQt(qtdir, 'QtGui', '4', target, copy_resources=True)
147
148 ChangeReferences(qtdir, GetFrameworkPath('QtCore', '4'),
149 '4', target, ref_to)
150 ChangeReferences(qtdir, GetFrameworkPath('QtGui', '4'),
151 '4', target, ref_to, references=['QtCore'])
123152
124153
125154 if __name__ == '__main__':
0 [Paths]
1 Plugins = ../../GuiTool.app/Contents/Frameworks/QtCore.framework/Resources/plugins
916916 'postbuild_name': 'Change the reference to frameworks.',
917917 'action': [
918918 'python', '../build_tools/change_reference_mac.py',
919 '--qtver', '<(qt_ver)',
919920 '--qtdir', '<(qt_dir)',
920921 '--target',
921922 '${BUILT_PRODUCTS_DIR}/GuiTool_lib.framework/Versions/A/GuiTool_lib',
965966 '<(PRODUCT_DIR)/GuiTool_lib.framework',
966967 ],
967968 },
969 'conditions': [
970 ['qt_ver==5', {
971 'mac_bundle_resources': ['../data/mac/qt.conf'],
972 }],
973 ],
968974 # We include this gypi file here because the variables
969975 # in a condition cannot be refferred from the gypi file
970976 # included outside from the condition.
976982 'postbuild_name': 'Change the reference to frameworks.',
977983 'action': [
978984 'python', '../build_tools/change_reference_mac.py',
985 '--qtver', '<(qt_ver)',
979986 '--qtdir', '<(qt_dir)',
980987 '--target',
981988 '${BUILT_PRODUCTS_DIR}/<(product_name).app/Contents/MacOS/<(product_name)',
985992 'postbuild_name': 'Copy Qt frameworks to the frameworks directory.',
986993 'action': [
987994 'python', '../build_tools/copy_qt_frameworks_mac.py',
995 '--qtver', '<(qt_ver)',
988996 '--qtdir', '<(qt_dir)',
989997 '--target', '${BUILT_PRODUCTS_DIR}/<(product_name).app/Contents/Frameworks/',
990998 ],
3434 'sources': [
3535 'tool/mozc_tool_main.cc',
3636 ],
37 'conditions': [
38 ['qt_ver==5', {
39 'mac_bundle_resources': ['../data/mac/qt.conf'],
40 }],
41 ],
3742 'dependencies': [
3843 'gen_mozc_tool_info_plist',
3944 'mozc_tool_lib',
4348 'postbuild_name': 'Change the reference to frameworks',
4449 'action': [
4550 'python', '../build_tools/change_reference_mac.py',
51 '--qtver', '<(qt_ver)',
4652 '--qtdir', '<(qt_dir)',
4753 '--target',
4854 '${BUILT_PRODUCTS_DIR}/<(product_name).app/Contents/MacOS/<(product_name)',
3636 'variables': {
3737 'conditions': [
3838 ['target_platform=="Linux"', {
39 'qt_cflags': ['<!@(pkg-config --cflags QtGui QtCore)'],
40 'qt_include_dirs': [],
39 'conditions': [
40 ['qt_ver==5', {
41 'qt_cflags': ['<!@(pkg-config --cflags Qt5Widgets Qt5Gui Qt5Core)'],
42 'qt_include_dirs': [],
43 }, {
44 'qt_cflags': ['<!@(pkg-config --cflags QtGui QtCore)'],
45 'qt_include_dirs': [],
46 }],
47 ],
4148 }, 'qt_dir', {
4249 'qt_cflags': [],
4350 'qt_include_dirs': ['<(qt_dir)/include'],
6269 'AdditionalLibraryDirectories': [
6370 '<(qt_dir)/lib',
6471 ],
65 'AdditionalDependencies': [
66 'QtCored4.lib',
67 'QtGuid4.lib',
72 'conditions': [
73 ['qt_ver==5', {
74 'AdditionalDependencies': [
75 'Qt5Cored.lib',
76 'Qt5Guid.lib',
77 'Qt5Widgetsd.lib',
78 ],
79 }, {
80 'AdditionalDependencies': [
81 'QtCored4.lib',
82 'QtGuid4.lib',
83 ],
84 }],
6885 ],
6986 },
7087 },
7592 'AdditionalLibraryDirectories': [
7693 '<(qt_dir)/lib',
7794 ],
78 'AdditionalDependencies': [
79 'QtCore4.lib',
80 'QtGui4.lib',
95 'conditions': [
96 ['qt_ver==5', {
97 'AdditionalDependencies': [
98 'Qt5Core.lib',
99 'Qt5Gui.lib',
100 'Qt5Widgets.lib',
101 ],
102 }, {
103 'AdditionalDependencies': [
104 'QtCore4.lib',
105 'QtGui4.lib',
106 ],
107 }],
81108 ],
82109 },
83110 },
97124 'mac_framework_dirs': [
98125 '<(qt_dir)/lib',
99126 ],
100 'libraries': [
101 '<(qt_dir)/lib/QtCore.framework',
102 '<(qt_dir)/lib/QtGui.framework',
127 'conditions': [
128 ['qt_ver==5', {
129 'libraries': [
130 '<(qt_dir)/lib/QtCore.framework',
131 '<(qt_dir)/lib/QtGui.framework',
132 '<(qt_dir)/lib/QtWidgets.framework',
133 ]
134 }, {
135 'libraries': [
136 '<(qt_dir)/lib/QtCore.framework',
137 '<(qt_dir)/lib/QtGui.framework',
138 ]
139 }],
103140 ],
104141 },
105142 }],
109146 ]
110147 }],
111148 ['target_platform=="Linux"', {
112 'libraries': [
113 '<!@(pkg-config --libs QtGui QtCore)',
149 'conditions': [
150 ['qt_ver==5', {
151 'libraries': [
152 '<!@(pkg-config --libs Qt5Widgets Qt5Gui Qt5Core)',
153 ],
154 }, {
155 'libraries': [
156 '<!@(pkg-config --libs QtGui QtCore)',
157 ],
158 }],
114159 ],
115160 }],
116161 # Workarounds related with clang.
3333 'variables': {
3434 'conditions': [
3535 ['target_platform=="Linux"', {
36 'moc_path': '<!(pkg-config --variable=moc_location QtGui)',
36 'conditions': [
37 ['qt_ver==5', {
38 'moc_path': '<!(pkg-config --variable=host_bins Qt5Core)/moc',
39 }, {
40 'moc_path': '<!(pkg-config --variable=moc_location QtGui)',
41 }],
42 ],
3743 }, 'qt_dir', {
3844 'moc_path': '<(qt_dir)/bin/moc<(EXECUTABLE_SUFFIX)',
3945 }, {
3333 'variables': {
3434 'conditions': [
3535 ['target_platform=="Linux"', {
36 # seems that --variable=rcc_location is not supported
37 'rcc_path': '<!(pkg-config --variable=exec_prefix QtGui)/bin/rcc',
36 'conditions': [
37 ['qt_ver==5', {
38 'rcc_path': '<!(pkg-config --variable=host_bins Qt5Core)/rcc',
39 }, {
40 # seems that --variable=rcc_location is not supported
41 'rcc_path': '<!(pkg-config --variable=exec_prefix QtGui)/bin/rcc',
42 }],
43 ],
3844 }, 'qt_dir', {
3945 'rcc_path': '<(qt_dir)/bin/rcc<(EXECUTABLE_SUFFIX)',
4046 }, {
3333 'variables': {
3434 'conditions': [
3535 ['target_platform=="Linux"', {
36 'uic_path': '<!(pkg-config --variable=uic_location QtGui)',
36 'conditions': [
37 ['qt_ver==5', {
38 'uic_path': '<!(pkg-config --variable=host_bins Qt5Core)/uic',
39 }, {
40 'uic_path': '<!(pkg-config --variable=uic_location QtGui)',
41 }],
42 ],
3743 }, 'qt_dir', {
3844 'uic_path': '<(qt_dir)/bin/uic<(EXECUTABLE_SUFFIX)',
3945 }, {
596596 ['enable_unittest==1', {
597597 'defines': ['MOZC_ENABLE_UNITTEST'],
598598 }],
599 ['qt_ver==5', {
600 'defines': ['MOZC_USE_QT5'],
601 }],
599602 ['OS=="win"', {
600603 'variables': {
601604 'wtl_dir': '<(additional_third_party_dir)/wtl',
00 MAJOR=2
11 MINOR=17
2 BUILD=2453
2 BUILD=2454
33 REVISION=102
44 # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
55 # downloaded by NaCl Mozc.