Skip to content

Commit 907db59

Browse files
yukawahiroyuki-komatsu
authored andcommitted
Introduce 'qt_ver' GYP variable (#775)
As a preparation of Qt6 migration, this commit introduces 'qt_ver' GYP variable, which is still set to '5' by default into GYP builds. This is a mechanical cleanup, and there must be no behavior change. Also there must be no impact on Bazel builds. #codehealth PiperOrigin-RevId: 552690457
1 parent 0a946ef commit 907db59

11 files changed

+39
-27
lines changed

src/build_tools/change_reference_mac.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
3333
Typical usage:
3434
35-
% change_reference_mac.py --qtdir=/path/to/qtdir/ \
35+
% change_reference_mac.py --qtdir=/path/to/qtdir/ --qtver=5 \
3636
--target=/path/to/target.app/Contents/MacOS/target
3737
"""
3838

@@ -49,6 +49,7 @@ def ParseOption():
4949
"""Parse command line options."""
5050
parser = optparse.OptionParser()
5151
parser.add_option('--qtdir', dest='qtdir')
52+
parser.add_option('--qtver', dest='qtver')
5253
parser.add_option('--target', dest='target')
5354

5455
(opts, _) = parser.parse_args()
@@ -76,28 +77,32 @@ def main():
7677
if not opt.qtdir:
7778
PrintErrorAndExit('--qtdir option is mandatory.')
7879

80+
if not opt.qtver:
81+
PrintErrorAndExit('--qtver option is mandatory.')
82+
7983
if not opt.target:
8084
PrintErrorAndExit('--target option is mandatory.')
8185

8286
unused_qtdir = os.path.abspath(opt.qtdir) # TODO(komatsu): remove this.
8387
target = os.path.abspath(opt.target)
88+
qtver = str(opt.qtver)
8489

8590
# Changes the reference to QtCore framework from the target application
8691
# From: @rpath/QtCore.framework/Versions/5/QtCore
8792
# To: @executable_path/../../../MozcTool.app/Contents/Frameworks/...
88-
qtcore_framework = GetFrameworkPath('QtCore', '5')
93+
qtcore_framework = GetFrameworkPath('QtCore', qtver)
8994
InstallNameTool(target,
9095
'@rpath/%s' % qtcore_framework,
9196
GetReferenceTo(qtcore_framework))
9297

9398
# Changes the reference to QtGui framework from the target application
94-
qtgui_framework = GetFrameworkPath('QtGui', '5')
99+
qtgui_framework = GetFrameworkPath('QtGui', qtver)
95100
InstallNameTool(target,
96101
'@rpath/%s' % qtgui_framework,
97102
GetReferenceTo(qtgui_framework))
98103

99104
# Changes the reference to QtWidgets framework from the target application
100-
qtwidgets_framework = GetFrameworkPath('QtWidgets', '5')
105+
qtwidgets_framework = GetFrameworkPath('QtWidgets', qtver)
101106
InstallNameTool(target,
102107
'@rpath/%s' % qtwidgets_framework,
103108
GetReferenceTo(qtwidgets_framework))

src/gui/gui.gyp

+2
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@
687687
'action': [
688688
'<(python)', '../build_tools/change_reference_mac.py',
689689
'--qtdir', '<(qt_dir)',
690+
'--qtver', '<(qt_ver)',
690691
'--target',
691692
'${BUILT_PRODUCTS_DIR}/GuiTool_lib.framework/Versions/A/GuiTool_lib',
692693
],
@@ -951,6 +952,7 @@
951952
'action': [
952953
'<(python)', '../build_tools/change_reference_mac.py',
953954
'--qtdir', '<(qt_dir)',
955+
'--qtver', '<(qt_ver)',
954956
'--target',
955957
'${BUILT_PRODUCTS_DIR}/<(product_name).app/Contents/MacOS/<(product_name)',
956958
],

src/gui/mac_gui.gypi

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
'action': [
4848
'<(python)', '../build_tools/change_reference_mac.py',
4949
'--qtdir', '<(qt_dir)',
50+
'--qtver', '<(qt_ver)',
5051
'--target',
5152
'${BUILT_PRODUCTS_DIR}/<(product_name).app/Contents/MacOS/<(product_name)',
5253
],

src/gui/qt_libraries.gypi

+8-8
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
'<(qt_dir)/lib',
5454
],
5555
'AdditionalDependencies': [
56-
'Qt5Cored.lib',
57-
'Qt5Guid.lib',
58-
'Qt5Widgetsd.lib',
56+
'Qt<(qt_ver)Cored.lib',
57+
'Qt<(qt_ver)Guid.lib',
58+
'Qt<(qt_ver)Widgetsd.lib',
5959
],
6060
},
6161
},
@@ -67,9 +67,9 @@
6767
'<(qt_dir)/lib',
6868
],
6969
'AdditionalDependencies': [
70-
'Qt5Core.lib',
71-
'Qt5Gui.lib',
72-
'Qt5Widgets.lib',
70+
'Qt<(qt_ver)Core.lib',
71+
'Qt<(qt_ver)Gui.lib',
72+
'Qt<(qt_ver)Widgets.lib',
7373
],
7474
},
7575
},
@@ -109,8 +109,8 @@
109109
]
110110
}],
111111
['target_platform=="Linux"', {
112-
'cflags': ['<!@(pkg-config --cflags Qt5Widgets Qt5Gui Qt5Core)'],
113-
'libraries': ['<!@(pkg-config --libs Qt5Widgets Qt5Gui Qt5Core)'],
112+
'cflags': ['<!@(pkg-config --cflags Qt<(qt_ver)Widgets Qt<(qt_ver)Gui Qt<(qt_ver)Core)'],
113+
'libraries': ['<!@(pkg-config --libs Qt<(qt_ver)Widgets Qt<(qt_ver)Gui Qt<(qt_ver)Core)'],
114114
}],
115115
# Workarounds related with clang.
116116
['(_toolset=="target" and compiler_target=="clang") or '

src/gui/qt_moc.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'variables': {
3535
'conditions': [
3636
['target_platform=="Linux"', {
37-
'moc_path': '<!(pkg-config --variable=host_bins Qt5Core)/moc',
37+
'moc_path': '<!(pkg-config --variable=host_bins Qt<(qt_ver)Core)/moc',
3838
}, 'qt_dir', {
3939
'moc_path': '<(qt_dir)/bin/moc<(EXECUTABLE_SUFFIX)',
4040
}, {

src/gui/qt_rcc.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'variables': {
3535
'conditions': [
3636
['target_platform=="Linux"', {
37-
'rcc_path': '<!(pkg-config --variable=host_bins Qt5Core)/rcc',
37+
'rcc_path': '<!(pkg-config --variable=host_bins Qt<(qt_ver)Core)/rcc',
3838
}, 'qt_dir', {
3939
'rcc_path': '<(qt_dir)/bin/rcc<(EXECUTABLE_SUFFIX)',
4040
}, {

src/gui/qt_uic.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'variables': {
3535
'conditions': [
3636
['target_platform=="Linux"', {
37-
'uic_path': '<!(pkg-config --variable=host_bins Qt5Core)/uic',
37+
'uic_path': '<!(pkg-config --variable=host_bins Qt<(qt_ver)Core)/uic',
3838
}, 'qt_dir', {
3939
'uic_path': '<(qt_dir)/bin/uic<(EXECUTABLE_SUFFIX)',
4040
}, {

src/gyp/defines.gypi

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
# use_qt is 'YES' only if you want to use GUI binaries.
5454
'use_qt%': 'YES',
5555

56+
# Qt version to be used.
57+
'qt_ver%': '5',
58+
5659
# use_libprotobuf represents if protobuf library is used or not.
5760
# This option is only for Linux.
5861
# You should not set this flag if you want to use "dlopen" to

src/win32/installer/installer.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
'-dCustomActions64Path=<(mozc_ca64_path)',
161161
'-dDocumentsDir=<(document_dir)',
162162
'-dQtDir=<(qt_dir)',
163+
'-dQtVer=<(qt_ver)',
163164
'-o', '<@(_outputs)',
164165
# We do not use '<@(_inputs)' here because it contains some
165166
# input files just for peoper rebiuld condition.

src/win32/installer/installer_64bit.wxs

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
-->
3232

3333

34-
<?define QtCoreFilename="Qt5Core.dll" ?>
35-
<?define QtCoredFilename="Qt5Cored.dll" ?>
36-
<?define QtGuiFilename="Qt5Gui.dll" ?>
37-
<?define QtGuidFilename="Qt5Guid.dll" ?>
38-
<?define QtWidgetsFilename="Qt5Widgets.dll" ?>
39-
<?define QtWidgetsdFilename="Qt5Widgetsd.dll" ?>
34+
<?define QtCoreFilename="Qt$(var.QtVer)Core.dll" ?>
35+
<?define QtCoredFilename="Qt$(var.QtVer)Cored.dll" ?>
36+
<?define QtGuiFilename="Qt$(var.QtVer)Gui.dll" ?>
37+
<?define QtGuidFilename="Qt$(var.QtVer)Guid.dll" ?>
38+
<?define QtWidgetsFilename="Qt$(var.QtVer)Widgets.dll" ?>
39+
<?define QtWidgetsdFilename="Qt$(var.QtVer)Widgetsd.dll" ?>
4040

4141
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
4242

src/win32/installer/installer_oss_64bit.wxs

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
-->
3232

3333

34-
<?define QtCoreFilename="Qt5Core.dll" ?>
35-
<?define QtCoredFilename="Qt5Cored.dll" ?>
36-
<?define QtGuiFilename="Qt5Gui.dll" ?>
37-
<?define QtGuidFilename="Qt5Guid.dll" ?>
38-
<?define QtWidgetsFilename="Qt5Widgets.dll" ?>
39-
<?define QtWidgetsdFilename="Qt5Widgetsd.dll" ?>
34+
<?define QtCoreFilename="Qt$(var.QtVer)Core.dll" ?>
35+
<?define QtCoredFilename="Qt$(var.QtVer)Cored.dll" ?>
36+
<?define QtGuiFilename="Qt$(var.QtVer)Gui.dll" ?>
37+
<?define QtGuidFilename="Qt$(var.QtVer)Guid.dll" ?>
38+
<?define QtWidgetsFilename="Qt$(var.QtVer)Widgets.dll" ?>
39+
<?define QtWidgetsdFilename="Qt$(var.QtVer)Widgetsd.dll" ?>
4040

4141
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
4242

0 commit comments

Comments
 (0)