@@ -23,13 +23,24 @@ class Qt(BaseHelper):
2323 def __init__ (self , app_dir , app_dir_files ):
2424 super ().__init__ (app_dir , app_dir_files )
2525 self .app_dir = Path (app_dir )
26+ self ._qt4_dirs = {}
2627 self ._qt5_dirs = {}
2728 self ._qt6_dirs = {}
2829
2930 def configure (self , env : Environment , preserve_files ):
31+ self ._configure_qt4 ()
3032 self ._configure_qt5 ()
3133 self ._configure_qt6 ()
3234
35+ def _configure_qt4 (self ):
36+ self ._locate_qt4_dirs ()
37+ if self ._qt4_dirs :
38+ # deploy a qt.conf file next to executable files that may start a Qt application
39+ exec_dirs = self ._find_exec_dirs ()
40+ for path in exec_dirs :
41+ qt_conf = self ._generate_conf (path , self ._qt4_dirs )
42+ self ._write_qt_conf (qt_conf , path )
43+
3344 def _configure_qt5 (self ):
3445 self ._locate_qt5_dirs ()
3546 if self ._qt5_dirs :
@@ -68,6 +79,52 @@ def _generate_conf(self, base_path, content: dict):
6879
6980 return config
7081
82+ def _locate_qt4_dirs (self ):
83+ libqt4core_path = self .finder .find_one (
84+ "*/libQtCore.so.4.*" , [Finder .is_file , Finder .is_elf_shared_lib ]
85+ )
86+ if libqt4core_path :
87+ self ._qt4_dirs ["Libraries" ] = libqt4core_path .parent
88+ else :
89+ # don't go any forward if libQtCore.so.4.... is not found
90+ return
91+
92+ paths = list (
93+ self .finder .find_dirs_containing (
94+ pattern = "qmake" ,
95+ file_checks = [Finder .is_file , Finder .is_executable ],
96+ excluded_patterns = [
97+ "*/qt5/*" ,
98+ "*/qt6/*" ,
99+ "/usr/bin" ,
100+ ],
101+ )
102+ )
103+ qmake_path = paths [0 ]
104+ if qmake_path :
105+ self ._qt4_dirs ["Binaries" ] = qmake_path .parent
106+
107+ # just to find plugin directory, lookup a lib included in libqtcore4:<arch>
108+ libqminimal_path = self .finder .find_one (
109+ "*/libqjpcodecs.so" , [Finder .is_file , Finder .is_elf ]
110+ )
111+ if libqminimal_path :
112+ self ._qt4_dirs ["Plugins" ] = libqminimal_path .parent .parent
113+
114+ # ok
115+ builtins_qmltypes_path = self .finder .find_one (
116+ "*/builtins.qmltypes" , [Finder .is_file ]
117+ )
118+ if builtins_qmltypes_path :
119+ self ._qt4_dirs ["Qml2Imports" ] = builtins_qmltypes_path .parent
120+
121+ # ok
122+ qtbase_translations_path = self .finder .find_one (
123+ "*/qt4/translations" , [Finder .is_dir ]
124+ )
125+ if qtbase_translations_path :
126+ self ._qt4_dirs ["Translations" ] = qtbase_translations_path
127+
71128 def _locate_qt5_dirs (self ):
72129 libqt5core_path = self .finder .find_one (
73130 "*/libQt5Core.so.*" , [Finder .is_file , Finder .is_elf_shared_lib ]
0 commit comments