16
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
#
18
18
19
- import plistlib
20
- import sys , re , os , shutil , stat , os .path
19
+ import sys , re , os , platform , shutil , stat , subprocess , os .path
21
20
from argparse import ArgumentParser
22
21
from ds_store import DSStore
23
22
from mac_alias import Alias
@@ -53,7 +52,7 @@ class FrameworkInfo(object):
53
52
return False
54
53
55
54
def __str__ (self ):
56
- return f""" Framework name: { frameworkName }
55
+ return f""" Framework name: { self . frameworkName }
57
56
Framework directory: { self .frameworkDirectory }
58
57
Framework path: { self .frameworkPath }
59
58
Binary name: { self .binaryName }
@@ -85,8 +84,8 @@ class FrameworkInfo(object):
85
84
if line == "" :
86
85
return None
87
86
88
- # Don't deploy system libraries (exception for libQtuitools and libQtlucene).
89
- if line .startswith ("/System/Library/" ) or line .startswith ("@executable_path" ) or ( line .startswith ("/usr/lib/" ) and "libQt" not in line ):
87
+ # Don't deploy system libraries
88
+ if line .startswith ("/System/Library/" ) or line .startswith ("@executable_path" ) or line .startswith ("/usr/lib/" ):
90
89
return None
91
90
92
91
m = cls .reOLine .match (line )
@@ -246,56 +245,46 @@ def copyFramework(framework: FrameworkInfo, path: str, verbose: int) -> Optional
246
245
toDir = os .path .join (path , framework .destinationDirectory )
247
246
toPath = os .path .join (toDir , framework .binaryName )
248
247
249
- if not os .path .exists (fromPath ):
250
- raise RuntimeError (f"No file at { fromPath } " )
248
+ if framework .isDylib ():
249
+ if not os .path .exists (fromPath ):
250
+ raise RuntimeError (f"No file at { fromPath } " )
251
251
252
- if os .path .exists (toPath ):
253
- return None # Already there
252
+ if os .path .exists (toPath ):
253
+ return None # Already there
254
254
255
- if not os .path .exists (toDir ):
256
- os .makedirs (toDir )
255
+ if not os .path .exists (toDir ):
256
+ os .makedirs (toDir )
257
257
258
- shutil .copy2 (fromPath , toPath )
259
- if verbose :
260
- print ("Copied:" , fromPath )
261
- print (" to:" , toPath )
258
+ shutil .copy2 (fromPath , toPath )
259
+ if verbose :
260
+ print ("Copied:" , fromPath )
261
+ print (" to:" , toPath )
262
+ else :
263
+ to_dir = os .path .join (path , "Contents" , "Frameworks" , framework .frameworkName )
264
+ if os .path .exists (to_dir ):
265
+ return None # Already there
266
+
267
+ from_dir = framework .frameworkPath
268
+ if not os .path .exists (from_dir ):
269
+ raise RuntimeError (f"No directory at { from_dir } " )
270
+
271
+ shutil .copytree (from_dir , to_dir , symlinks = True )
272
+ if verbose :
273
+ print ("Copied:" , from_dir )
274
+ print (" to:" , to_dir )
275
+
276
+ headers_link = os .path .join (to_dir , "Headers" )
277
+ if os .path .exists (headers_link ):
278
+ os .unlink (headers_link )
279
+
280
+ headers_dir = os .path .join (to_dir , framework .binaryDirectory , "Headers" )
281
+ if os .path .exists (headers_dir ):
282
+ shutil .rmtree (headers_dir )
262
283
263
284
permissions = os .stat (toPath )
264
285
if not permissions .st_mode & stat .S_IWRITE :
265
286
os .chmod (toPath , permissions .st_mode | stat .S_IWRITE )
266
287
267
- if not framework .isDylib (): # Copy resources for real frameworks
268
-
269
- linkfrom = os .path .join (path , "Contents" ,"Frameworks" , framework .frameworkName , "Versions" , "Current" )
270
- linkto = framework .version
271
- if not os .path .exists (linkfrom ):
272
- os .symlink (linkto , linkfrom )
273
- print ("Linked:" , linkfrom , "->" , linkto )
274
- fromResourcesDir = framework .sourceResourcesDirectory
275
- if os .path .exists (fromResourcesDir ):
276
- toResourcesDir = os .path .join (path , framework .destinationResourcesDirectory )
277
- shutil .copytree (fromResourcesDir , toResourcesDir , symlinks = True )
278
- if verbose :
279
- print ("Copied resources:" , fromResourcesDir )
280
- print (" to:" , toResourcesDir )
281
- fromContentsDir = framework .sourceVersionContentsDirectory
282
- if not os .path .exists (fromContentsDir ):
283
- fromContentsDir = framework .sourceContentsDirectory
284
- if os .path .exists (fromContentsDir ):
285
- toContentsDir = os .path .join (path , framework .destinationVersionContentsDirectory )
286
- shutil .copytree (fromContentsDir , toContentsDir , symlinks = True )
287
- if verbose :
288
- print ("Copied Contents:" , fromContentsDir )
289
- print (" to:" , toContentsDir )
290
- elif framework .frameworkName .startswith ("libQtGui" ): # Copy qt_menu.nib (applies to non-framework layout)
291
- qtMenuNibSourcePath = os .path .join (framework .frameworkDirectory , "Resources" , "qt_menu.nib" )
292
- qtMenuNibDestinationPath = os .path .join (path , "Contents" , "Resources" , "qt_menu.nib" )
293
- if os .path .exists (qtMenuNibSourcePath ) and not os .path .exists (qtMenuNibDestinationPath ):
294
- shutil .copytree (qtMenuNibSourcePath , qtMenuNibDestinationPath , symlinks = True )
295
- if verbose :
296
- print ("Copied for libQtGui:" , qtMenuNibSourcePath )
297
- print (" to:" , qtMenuNibDestinationPath )
298
-
299
288
return toPath
300
289
301
290
def deployFrameworks (frameworks : List [FrameworkInfo ], bundlePath : str , binaryPath : str , strip : bool , verbose : int , deploymentInfo : Optional [DeploymentInfo ] = None ) -> DeploymentInfo :
@@ -351,115 +340,20 @@ def deployFrameworksForAppBundle(applicationBundle: ApplicationBundleInfo, strip
351
340
return deployFrameworks (frameworks , applicationBundle .path , applicationBundle .binaryPath , strip , verbose )
352
341
353
342
def deployPlugins (appBundleInfo : ApplicationBundleInfo , deploymentInfo : DeploymentInfo , strip : bool , verbose : int ):
354
- # Lookup available plugins, exclude unneeded
355
343
plugins = []
356
344
if deploymentInfo .pluginPath is None :
357
345
return
358
346
for dirpath , dirnames , filenames in os .walk (deploymentInfo .pluginPath ):
359
347
pluginDirectory = os .path .relpath (dirpath , deploymentInfo .pluginPath )
360
- if pluginDirectory == "designer" :
361
- # Skip designer plugins
362
- continue
363
- elif pluginDirectory == "printsupport" :
364
- # Skip printsupport plugins
365
- continue
366
- elif pluginDirectory == "imageformats" :
367
- # Skip imageformats plugins
348
+
349
+ if pluginDirectory not in ['styles' , 'platforms' ]:
368
350
continue
369
- elif pluginDirectory == "sqldrivers" :
370
- # Deploy the sql plugins only if QtSql is in use
371
- if not deploymentInfo .usesFramework ("QtSql" ):
372
- continue
373
- elif pluginDirectory == "script" :
374
- # Deploy the script plugins only if QtScript is in use
375
- if not deploymentInfo .usesFramework ("QtScript" ):
376
- continue
377
- elif pluginDirectory == "qmltooling" or pluginDirectory == "qml1tooling" :
378
- # Deploy the qml plugins only if QtDeclarative is in use
379
- if not deploymentInfo .usesFramework ("QtDeclarative" ):
380
- continue
381
- elif pluginDirectory == "bearer" :
382
- # Deploy the bearer plugins only if QtNetwork is in use
383
- if not deploymentInfo .usesFramework ("QtNetwork" ):
384
- continue
385
- elif pluginDirectory == "position" :
386
- # Deploy the position plugins only if QtPositioning is in use
387
- if not deploymentInfo .usesFramework ("QtPositioning" ):
388
- continue
389
- elif pluginDirectory == "sensors" or pluginDirectory == "sensorgestures" :
390
- # Deploy the sensor plugins only if QtSensors is in use
391
- if not deploymentInfo .usesFramework ("QtSensors" ):
392
- continue
393
- elif pluginDirectory == "audio" or pluginDirectory == "playlistformats" :
394
- # Deploy the audio plugins only if QtMultimedia is in use
395
- if not deploymentInfo .usesFramework ("QtMultimedia" ):
396
- continue
397
- elif pluginDirectory == "mediaservice" :
398
- # Deploy the mediaservice plugins only if QtMultimediaWidgets is in use
399
- if not deploymentInfo .usesFramework ("QtMultimediaWidgets" ):
400
- continue
401
- elif pluginDirectory == "canbus" :
402
- # Deploy the canbus plugins only if QtSerialBus is in use
403
- if not deploymentInfo .usesFramework ("QtSerialBus" ):
404
- continue
405
- elif pluginDirectory == "webview" :
406
- # Deploy the webview plugins only if QtWebView is in use
407
- if not deploymentInfo .usesFramework ("QtWebView" ):
408
- continue
409
- elif pluginDirectory == "gamepads" :
410
- # Deploy the webview plugins only if QtGamepad is in use
411
- if not deploymentInfo .usesFramework ("QtGamepad" ):
412
- continue
413
- elif pluginDirectory == "geoservices" :
414
- # Deploy the webview plugins only if QtLocation is in use
415
- if not deploymentInfo .usesFramework ("QtLocation" ):
416
- continue
417
- elif pluginDirectory == "texttospeech" :
418
- # Deploy the texttospeech plugins only if QtTextToSpeech is in use
419
- if not deploymentInfo .usesFramework ("QtTextToSpeech" ):
420
- continue
421
- elif pluginDirectory == "virtualkeyboard" :
422
- # Deploy the virtualkeyboard plugins only if QtVirtualKeyboard is in use
423
- if not deploymentInfo .usesFramework ("QtVirtualKeyboard" ):
424
- continue
425
- elif pluginDirectory == "sceneparsers" :
426
- # Deploy the virtualkeyboard plugins only if Qt3DCore is in use
427
- if not deploymentInfo .usesFramework ("Qt3DCore" ):
428
- continue
429
- elif pluginDirectory == "renderplugins" :
430
- # Deploy the renderplugins plugins only if Qt3DCore is in use
431
- if not deploymentInfo .usesFramework ("Qt3DCore" ):
432
- continue
433
- elif pluginDirectory == "geometryloaders" :
434
- # Deploy the geometryloaders plugins only if Qt3DCore is in use
435
- if not deploymentInfo .usesFramework ("Qt3DCore" ):
436
- continue
437
351
438
352
for pluginName in filenames :
439
353
pluginPath = os .path .join (pluginDirectory , pluginName )
440
- if pluginName . endswith ( "_debug.dylib" ):
441
- # Skip debug plugins
354
+
355
+ if pluginName . split ( '.' )[ 0 ] not in [ 'libqminimal' , 'libqcocoa' , 'libqmacstyle' ]:
442
356
continue
443
- elif pluginPath == "imageformats/libqsvg.dylib" or pluginPath == "iconengines/libqsvgicon.dylib" :
444
- # Deploy the svg plugins only if QtSvg is in use
445
- if not deploymentInfo .usesFramework ("QtSvg" ):
446
- continue
447
- elif pluginPath == "accessible/libqtaccessiblecompatwidgets.dylib" :
448
- # Deploy accessibility for Qt3Support only if the Qt3Support is in use
449
- if not deploymentInfo .usesFramework ("Qt3Support" ):
450
- continue
451
- elif pluginPath == "graphicssystems/libqglgraphicssystem.dylib" :
452
- # Deploy the opengl graphicssystem plugin only if QtOpenGL is in use
453
- if not deploymentInfo .usesFramework ("QtOpenGL" ):
454
- continue
455
- elif pluginPath == "accessible/libqtaccessiblequick.dylib" :
456
- # Deploy the accessible qtquick plugin only if QtQuick is in use
457
- if not deploymentInfo .usesFramework ("QtQuick" ):
458
- continue
459
- elif pluginPath == "platforminputcontexts/libqtvirtualkeyboardplugin.dylib" :
460
- # Deploy the virtualkeyboardplugin plugin only if QtVirtualKeyboard is in use
461
- if not deploymentInfo .usesFramework ("QtVirtualKeyboard" ):
462
- continue
463
357
464
358
plugins .append ((pluginDirectory , pluginName ))
465
359
@@ -527,6 +421,9 @@ if os.path.exists(appname + ".dmg"):
527
421
print ("+ Removing existing DMG +" )
528
422
os .unlink (appname + ".dmg" )
529
423
424
+ if os .path .exists (appname + ".temp.dmg" ):
425
+ os .unlink (appname + ".temp.dmg" )
426
+
530
427
# ------------------------------------------------
531
428
532
429
target = os .path .join ("dist" , "Dash-Qt.app" )
@@ -644,6 +541,25 @@ ds.close()
644
541
645
542
# ------------------------------------------------
646
543
544
+ if platform .system () == "Darwin" :
545
+ subprocess .check_call (f"codesign --deep --force --sign - { target } " , shell = True )
546
+
547
+ print ("+ Installing background.tiff +" )
548
+
549
+ bg_path = os .path .join ('dist' , '.background' , 'background.tiff' )
550
+ os .mkdir (os .path .dirname (bg_path ))
551
+
552
+ tiff_path = os .path .join ('contrib' , 'macdeploy' , 'background.tiff' )
553
+ shutil .copy2 (tiff_path , bg_path )
554
+
555
+ # ------------------------------------------------
556
+
557
+ print ("+ Generating symlink for /Applications +" )
558
+
559
+ os .symlink ("/Applications" , os .path .join ('dist' , "Applications" ))
560
+
561
+ # ------------------------------------------------
562
+
647
563
if config .dmg is not None :
648
564
649
565
print ("+ Preparing .dmg disk image +" )
@@ -667,19 +583,6 @@ if config.dmg is not None:
667
583
print ("Attaching temp image..." )
668
584
output = run (["hdiutil" , "attach" , tempname , "-readwrite" ], check = True , universal_newlines = True , stdout = PIPE ).stdout
669
585
670
- m = re .search (r"/Volumes/(.+$)" , output )
671
- disk_root = m .group (0 )
672
-
673
- print ("+ Applying fancy settings +" )
674
-
675
- bg_path = os .path .join (disk_root , ".background" , os .path .basename ('background.tiff' ))
676
- os .mkdir (os .path .dirname (bg_path ))
677
- if verbose :
678
- print ('background.tiff' , "->" , bg_path )
679
- shutil .copy2 ('contrib/macdeploy/background.tiff' , bg_path )
680
-
681
- os .symlink ("/Applications" , os .path .join (disk_root , "Applications" ))
682
-
683
586
print ("+ Finalizing .dmg disk image +" )
684
587
685
588
run (["hdiutil" , "detach" , f"/Volumes/{ appname } " ], universal_newlines = True )
0 commit comments