Skip to content

Commit 588f6aa

Browse files
Add functions for duplicated routines
This is a preparation to make Qt5 migration process easier. This CL Adds GetFrameworkPath, CopyQt and ChangeReferences. BUG=#327 TEST= REF_BUG= REF_CL=113140366 REF_TIME=2016-01-27T18:57:47+09:00 REF_TIME_RAW=1453888667 +0900
1 parent 26241b0 commit 588f6aa

File tree

2 files changed

+53
-38
lines changed

2 files changed

+53
-38
lines changed

src/build_tools/copy_qt_frameworks_mac.py

+52-37
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,52 @@ def ParseOption():
5858
return opts
5959

6060

61+
def GetFrameworkPath(name, version):
62+
"""Return path to the library in the framework."""
63+
return '%s.framework/Versions/%s/%s' % (name, version, name)
64+
65+
66+
def CopyQt(qtdir, qtlib, version, target, copy_resources=False):
67+
"""Copy a Qt framework from qtdir to target."""
68+
framework_path = GetFrameworkPath(qtlib, version)
69+
CopyFiles(['%s/lib/%s' % (qtdir, framework_path)],
70+
'%s/%s' % (target, framework_path))
71+
72+
if copy_resources:
73+
# Copies Resources of QtGui
74+
CopyFiles(['%s/lib/%s.framework/Versions/%s/Resources' %
75+
(qtdir, qtlib, version)],
76+
'%s/%s.framework/Resources' % (target, qtlib),
77+
recursive=True)
78+
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))
82+
83+
84+
def ChangeReferences(qtdir, qtlib, version, target, ref_to, references=None):
85+
"""Change the references of frameworks, by using install_name_tool."""
86+
framework_path = GetFrameworkPath(qtlib, version)
87+
88+
# Change id
89+
cmd = ['install_name_tool',
90+
'-id', '%s/%s' % (ref_to, framework_path),
91+
'%s/%s' % (target, framework_path)]
92+
RunOrDie(cmd)
93+
94+
if not references:
95+
return
96+
97+
# Change references
98+
for ref in references:
99+
ref_framework_path = GetFrameworkPath(ref, version)
100+
change_cmd = ['install_name_tool', '-change',
101+
'%s/lib/%s' % (qtdir, ref_framework_path),
102+
'%s/%s' % (ref_to, ref_framework_path),
103+
'%s/%s' % (target, framework_path)]
104+
RunOrDie(change_cmd)
105+
106+
61107
def main():
62108
opt = ParseOption()
63109

@@ -73,44 +119,13 @@ def main():
73119
qtdir = os.path.abspath(opt.qtdir)
74120
target = os.path.abspath(opt.target)
75121

76-
# Copies QtCore. For codesign, Info.plist should be copied to Resources/.
77-
CopyFiles(['%s/lib/QtCore.framework/Versions/4/QtCore' % qtdir],
78-
'%s/QtCore.framework/Versions/4/QtCore' % target)
79-
CopyFiles(['%s/lib/QtCore.framework/Contents/Info.plist' % qtdir],
80-
'%s/QtCore.framework/Resources/Info.plist' % target)
81-
82-
# Copies QtGui.
83-
CopyFiles(['%s/lib/QtGui.framework/Versions/4/QtGui' % qtdir],
84-
'%s/QtGui.framework/Versions/4/QtGui' % target)
85-
# Copies Resources of QtGui
86-
CopyFiles(['%s/lib/QtGui.framework/Versions/4/Resources' % qtdir],
87-
'%s/QtGui.framework/Resources' % target,
88-
recursive=True)
89-
# For codesign, Info.plist should be copied to Resources/.
90-
CopyFiles(['%s/lib/QtGui.framework/Contents/Info.plist' % qtdir],
91-
'%s/QtGui.framework/Resources/Info.plist' % target)
92-
93-
base_dir = ('@executable_path/../../../%sTool.app/Contents/Frameworks' %
94-
opt.branding)
122+
CopyQt(qtdir, 'QtCore', '4', target)
123+
CopyQt(qtdir, 'QtGui', '4', target, copy_resources=True)
95124

96-
# Changes QtGui id
97-
cmd = ['install_name_tool', '-id',
98-
'%s/QtGui.framework/Versions/4/QtGui' % base_dir,
99-
'%s/QtGui.framework/Versions/4/QtGui' % target]
100-
RunOrDie(cmd)
101-
102-
# Changes QtCore id
103-
cmd = ['install_name_tool', '-id',
104-
'%s/QtCore.framework/Versions/4/QtCore' % base_dir,
105-
'%s/QtCore.framework/Versions/4/QtCore' % target]
106-
RunOrDie(cmd)
107-
108-
# Changes the reference to QtCore framework from QtGui
109-
cmd = ['install_name_tool', '-change',
110-
'%s/lib/QtCore.framework/Versions/4/QtCore' % qtdir,
111-
'%s/QtCore.framework/Versions/4/QtCore' % base_dir,
112-
'%s/QtGui.framework/Versions/4/QtGui' % target]
113-
RunOrDie(cmd)
125+
ref_to = ('@executable_path/../../../%sTool.app/Contents/Frameworks' %
126+
opt.branding)
127+
ChangeReferences(qtdir, 'QtCore', '4', target, ref_to)
128+
ChangeReferences(qtdir, 'QtGui', '4', target, ref_to, references=['QtCore'])
114129

115130

116131
if __name__ == '__main__':

src/mozc_version_template.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MAJOR=2
22
MINOR=17
3-
BUILD=2423
3+
BUILD=2424
44
REVISION=102
55
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
66
# downloaded by NaCl Mozc.

0 commit comments

Comments
 (0)