1- #!/usr/bin/env python3
2- # Packages a full release build of the client that can be loaded by the launcher.
3- # Native libraries are not included.
4-
51import os
62import shutil
3+ import stat
74import subprocess
85import sys
96import zipfile
1815 init ()
1916
2017except ImportError :
21- # Just give an empty string for everything, no colored logging.
2218 class ColorDummy (object ):
2319 def __getattr__ (self , name ):
2420 return ""
@@ -62,58 +58,8 @@ class TargetOS(StrEnum):
6258 ".directory" ,
6359 ".DS_Store"
6460}
65-
66- IGNORED_FILES_WINDOWS = {
67- "libGLESv2.dll" ,
68- "openal32.dll" ,
69- "e_sqlite3.dll" ,
70- "libsndfile-1.dll" ,
71- "libglib-2.0-0.dll" ,
72- "freetype6.dll" ,
73- "libinstpatch-2.dll" ,
74- "fluidsynth.dll" ,
75- "libgobject-2.0-0.dll" ,
76- "libintl-8.dll" ,
77- "Robust.Client.exe" ,
78- "glfw3.dll" ,
79- "libgthread-2.0-0.dll" ,
80- "libEGL.dll" ,
81- "swnfd.dll" ,
82- "zstd.dll" ,
83- "zstd.pdb" ,
84- "libsodium.dll" ,
85- "zlib1.dll" ,
86- "SDL3.dll" ,
87- "OpenAL32.dll" ,
88- "libfluidsynth-3.dll"
89- }
90-
91- IGNORED_FILES_MACOS = {
92- "libe_sqlite3.dylib" ,
93- "libfreetype.6.dylib" ,
94- "libglfw.3.dylib" ,
95- "Robust.Client" ,
96- "libswnfd.dylib" ,
97- "zstd.dylib" ,
98- "libsodium.dylib" ,
99- "libopenal.1.dylib" ,
100- "libSDL3.0.dylib" ,
101- "libfluidsynth.3.dylib" ,
102- "libzstd.1.dylib"
103- }
104-
105- IGNORED_FILES_LINUX = {
106- "libe_sqlite3.so" ,
107- "libopenal.so" ,
108- "libglfw.so.3" ,
109- "Robust.Client" ,
110- "libswnfd.so" ,
111- "zstd.so" ,
112- "libsodium.so" ,
113- "libopenal.so.1" ,
114- "libSDL3.so.0" ,
115- "libfluidsynth.so.3" ,
116- "libzstd.so.1"
61+ IGNORED_FILES_CLIENT = {
62+ "Robust.Client" , "Robust.Client.exe" ,
11763}
11864
11965def main () -> None :
@@ -136,8 +82,6 @@ def main() -> None:
13682
13783 if not platforms :
13884 platforms = DEFAULT_RIDS
139-
140- # Validate that nobody put invalid platform names in.
14185 for rid in platforms :
14286 if rid not in ALL_RIDS :
14387 print (Fore .RED + f"Invalid platform specified: '{ rid } '" + Style .RESET_ALL )
@@ -176,7 +120,18 @@ def wipe_bin():
176120 "Clearing old build artifacts (if any)..." + Style .RESET_ALL )
177121
178122 if os .path .exists ("bin" ):
179- shutil .rmtree ("bin" )
123+ def _on_rm_error (func , path , exc_info ):
124+ try :
125+ os .chmod (path , stat .S_IWRITE )
126+ func (path )
127+ except Exception :
128+ raise
129+
130+ try :
131+ shutil .rmtree ("bin" , onerror = _on_rm_error )
132+ except PermissionError as e :
133+ print (Fore .YELLOW + f"Watning: failed to delete 'bin' due to permissions: { e } " + Style .RESET_ALL )
134+ print (Fore .YELLOW + "Continuing without wiwing 'bim' (you may want to closr processes locking files)." + Style .RESET_ALL )
180135
181136
182137def build_windows (rid : str , skip_build : bool ) -> None :
@@ -191,23 +146,21 @@ def build_windows(rid: str, skip_build: bool) -> None:
191146 p ("release" , f"Robust.Client_{ rid } .zip" ), "w" ,
192147 compression = zipfile .ZIP_DEFLATED )
193148
194- copy_dir_into_zip (p ("bin" , "Client" , rid , "publish" ), "" , client_zip , IGNORED_FILES_WINDOWS )
149+ copy_dir_into_zip (p ("bin" , "Client" , rid , "publish" ), "" , client_zip , IGNORED_FILES_CLIENT )
195150 copy_resources ("Resources" , client_zip )
196- # Cool we're done.
197151 client_zip .close ()
198152
199153def build_macos (rid : str , skip_build : bool ) -> None :
200154 if not skip_build :
201155 publish_client (rid , TargetOS .MacOS )
202156
203157 print (Fore .GREEN + f"Packaging { rid } client..." + Style .RESET_ALL )
204- # Client has to go in an app bundle.
205158 client_zip = zipfile .ZipFile (p ("release" , f"Robust.Client_{ rid } .zip" ), "a" ,
206159 compression = zipfile .ZIP_DEFLATED )
207160
208161 contents = p ("Space Station 14.app" , "Contents" , "Resources" )
209162 copy_dir_into_zip (p ("BuildFiles" , "Mac" , "Space Station 14.app" ), "Space Station 14.app" , client_zip )
210- copy_dir_into_zip (p ("bin" , "Client" , rid , "publish" ), contents , client_zip , IGNORED_FILES_MACOS )
163+ copy_dir_into_zip (p ("bin" , "Client" , rid , "publish" ), contents , client_zip , IGNORED_FILES_CLIENT )
211164 copy_resources (p (contents , "Resources" ), client_zip )
212165 client_zip .close ()
213166
@@ -222,9 +175,8 @@ def build_linux_like(rid: str, target_os: TargetOS, skip_build: bool) -> None:
222175 p ("release" , "Robust.Client_%s.zip" % rid ), "w" ,
223176 compression = zipfile .ZIP_DEFLATED , strict_timestamps = False )
224177
225- copy_dir_into_zip (p ("bin" , "Client" , rid , "publish" ), "" , client_zip , IGNORED_FILES_LINUX )
178+ copy_dir_into_zip (p ("bin" , "Client" , rid , "publish" ), "" , client_zip , IGNORED_FILES_CLIENT )
226179 copy_resources ("Resources" , client_zip )
227- # Cool we're done.
228180 client_zip .close ()
229181
230182
@@ -262,7 +214,6 @@ def do_resource_copy(target, source, zipf, ignore_set):
262214
263215def zip_entry_exists (zipf , name ):
264216 try :
265- # Trick ZipInfo into sanitizing the name for us so this awful module stops spewing warnings.
266217 zinfo = zipfile .ZipInfo .from_file ("Resources" , name )
267218 zipf .getinfo (zinfo .filename )
268219 except KeyError :
0 commit comments