@@ -58,6 +58,52 @@ def ParseOption():
58
58
return opts
59
59
60
60
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
+
61
107
def main ():
62
108
opt = ParseOption ()
63
109
@@ -73,44 +119,13 @@ def main():
73
119
qtdir = os .path .abspath (opt .qtdir )
74
120
target = os .path .abspath (opt .target )
75
121
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 )
95
124
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' ])
114
129
115
130
116
131
if __name__ == '__main__' :
0 commit comments