33# should probably be consolidated.
44
55import os
6+ import shutil
67
78paths_to_delete = [
89 "custom_vc14_64.bat" ,
1213 "env.bat" ,
1314 "draw.bat" ,
1415 "RELEASE.txt" ,
16+ "samples" ,
1517]
1618
1719
1820def delete_extraneous_files (base_path : str ) -> None :
1921 """Delete each of the files listed above from the path specified in base_path. Failure to delete a file does not
2022 constitute a fatal error."""
23+ print ("Removing extraneous files" )
2124 if not os .path .exists (base_path ):
2225 raise RuntimeError (f"{ base_path } does not exist" )
2326 if not os .path .isdir (base_path ):
@@ -35,6 +38,7 @@ def remove_local_path_from_cmake_files(base_path: str) -> None:
3538 a) OpenCASCADE codes in the local path to FreeType, which then fails when the LibPack is distributed, and b) for
3639 good measure cMake files shouldn't refer to non-existent paths on a foreign system. So this method looks for
3740 cmake config files and cleans the ones it finds."""
41+ print ("Removing local paths from cMake files" )
3842 for root , dirs , files in os .walk (base_path ):
3943 for file in files :
4044 if file .lower ().endswith (".cmake" ):
@@ -108,27 +112,77 @@ def delete_qtwebengine(base_path: str):
108112 """QtWebEngine is huge and pervasive -- it's also not used by FreeCAD (anymore). Delete anything that seems to be
109113 related to it from the LibPack."""
110114
115+ print ("Removing QtWebEngine (and related code)" )
111116 for root , dirs , files in os .walk (base_path ):
117+ for dir in dirs :
118+ if (
119+ "webengine" in dir .lower ()
120+ or "webchannel" in dir .lower ()
121+ or "websockets" in dir .lower ()
122+ ):
123+ try :
124+ full_path = os .path .join (root , dir )
125+ shutil .rmtree (full_path )
126+ except OSError as e :
127+ print (f"Failed to delete file { full_path } : { e } " )
112128 for file in files :
113129 if "webengine" in file .lower () or "webchannel" in file .lower ():
114130 try :
115- os .unlink (os .path .join (base_path , file ))
131+ full_path = os .path .join (root , file )
132+ os .unlink (full_path )
116133 except OSError as e :
117- pass
134+ print (f"Failed to delete path { full_path } : { e } " )
135+
136+
137+ def delete_qtquick (base_path : str ):
138+ """QtQuick is unused in FreeCAD at this time."""
139+
140+ def is_qtquick (name : str ) -> bool :
141+ lc = name .lower ()
142+ if "qtquick" in lc or "qml" in lc :
143+ return True
144+ if lc .startswith ("q" ) and "quick" in lc :
145+ return True
146+ return False
147+
148+ print ("Removing QtQuick/QML" )
149+ for root , dirs , files in os .walk (base_path ):
118150 for dir in dirs :
119- if "webengine" in dir .lower () or "webchannel" in dir .lower ():
151+ if is_qtquick (dir ):
152+ try :
153+ full_path = os .path .join (root , dir )
154+ shutil .rmtree (full_path )
155+ except OSError as e :
156+ print (f"Failed to delete file { full_path } : { e } " )
157+ for file in files :
158+ if is_qtquick (file ):
120159 try :
121- shutil .rmtree (os .path .join (base_path , dir ))
160+ full_path = os .path .join (root , file )
161+ os .unlink (full_path )
122162 except OSError as e :
123- pass
163+ print ( f"Failed to delete path { full_path } : { e } " )
124164
125165
126166def delete_llvm_executables (base_path : str ):
127167 """During the build of the libpack, a number of llvm executable files are created: these are not needed to compile
128168 or run FreeCAD, so remove them."""
169+ print ("Removing llvm executables" )
170+ files_in_bin = os .listdir (os .path .join (base_path , "bin" ))
171+ for file in files_in_bin :
172+ if file .startswith ("llvm" ) and file .endswith (".exe" ):
173+ try :
174+ os .unlink (os .path .join (base_path , "bin" , file ))
175+ except OSError as e :
176+ pass
177+
178+
179+ def delete_clang_executables (base_path : str ):
180+ """During the build of the libpack, a number of clang executable files are created: these are not needed to compile
181+ or run FreeCAD, so remove them."""
182+ print ("Removing clang executables" )
129183 files_in_bin = os .listdir (os .path .join (base_path , "bin" ))
130184 for file in files_in_bin :
131- if file .startswith (llvm ) and file .endswith (".exe" ):
185+ if file .startswith ("clang" ) and file .endswith (".exe" ):
132186 try :
133187 os .unlink (os .path .join (base_path , "bin" , file ))
134188 except OSError as e :
0 commit comments