1313
1414from colorama import Fore , Style
1515
16+
1617def run_command_interactive (command ):
1718 """
1819 Run a command interactively, printing its stdout in real-time.
@@ -21,8 +22,8 @@ def run_command_interactive(command):
2122 :return: The return code of the command
2223 """
2324 process = subprocess .Popen (
24- command ,
25- stdout = subprocess .PIPE ,
25+ command ,
26+ stdout = subprocess .PIPE ,
2627 stderr = subprocess .STDOUT , # Capture both stdout and stderr
2728 text = True # Ensure the output is in text mode
2829 )
@@ -32,15 +33,16 @@ def run_command_interactive(command):
3233 if output == "" and process .poll () is not None :
3334 break
3435 if output :
35- print (Fore .GREEN + output .strip () + Style .RESET_ALL )
36+ print (Fore .GREEN + output .strip () + Style .RESET_ALL )
3637
3738 return_code = process .wait ()
3839 return return_code
3940
41+
4042def main ():
4143 parser = argparse .ArgumentParser (
4244 prog = "mkdeb.py" , description = "A deb installer maker for WingHexExplorer2" )
43-
45+
4446 parser .add_argument (
4547 "folder" , help = "A folder that has contained the binary build" , type = str
4648 )
@@ -57,7 +59,7 @@ def main():
5759 "--no-build" , dest = "build" , action = "store_false" , help = "Skip building the installer"
5860 )
5961 parser .set_defaults (build = True )
60-
62+
6163 args = parser .parse_args ()
6264
6365 # checking build toolkits
@@ -81,15 +83,15 @@ def main():
8183 print (
8284 Fore .RED + "[Error] This is not a CMake build directory!" + Style .RESET_ALL )
8385 exit (- 1 )
84-
86+
8587 deploy_exec = ""
86-
88+
8789 with open (cmake_cache , 'r' ) as cmake_config :
88- while (True ):
90+ while (True ):
8991 line = cmake_config .readline ()
9092 if not line :
9193 break
92- if (line .startswith ("WINDEPLOYQT_EXECUTABLE:FILEPATH" )):
94+ if (line .startswith ("WINDEPLOYQT_EXECUTABLE:FILEPATH" )):
9395 set = line .split ('=' , 1 )
9496 deploy_exec = set [1 ].strip ('\n ' )
9597 pass
@@ -124,20 +126,24 @@ def main():
124126
125127 # check
126128 exemain_src = ""
127- exesym_src = ""
128-
129- if (os .path .exists (os .path .join (projectdeb , "WingHexExplorer2.sln" ))):
130- exemain_src = os .path .join (projectdeb , "RelWithDebInfo" , exe_name )
129+ exesym_src = ""
130+ exeplg_src = ""
131+
132+ if (os .path .exists (os .path .join (projectdeb , "WingHexExplorer2.sln" ))):
133+ exemain_src = os .path .join (projectdeb , "RelWithDebInfo" , exe_name )
131134 exesym_src = os .path .join (projectdeb , "RelWithDebInfo" , sym_name )
135+ exeplg_src = os .path .join (
136+ projectdeb , "WingPlugin" , "RelWithDebInfo" , "WingPlugin.dll" )
132137 else :
133138 exemain_src = os .path .join (projectdeb , exe_name )
134139 exesym_src = os .path .join (projectdeb , sym_name )
135-
140+ exeplg_src = os .path .join (projectdeb , "WingPlugin" , "WingPlugin.dll" )
141+
136142 if (os .path .exists (exemain_src ) == False ):
137143 print (
138144 Fore .RED + "[Error] WingHexExplorer2.exe is not found!" + Style .RESET_ALL )
139145 exit (- 3 )
140-
146+
141147 # calculate the md5 checksum
142148 with open (exemain_src , 'rb' ) as file_to_check :
143149 data = file_to_check .read ()
@@ -155,6 +161,8 @@ def main():
155161
156162 shutil .copy2 (exemain_src , os .path .join (exeDebPath , exe_name ))
157163 shutil .copy2 (exesym_src , os .path .join (exeDebPath , sym_name ))
164+ shutil .copy2 (exeplg_src ,
165+ os .path .join (exeDebPath , "WingPlugin.dll" ))
158166
159167 shutil .copytree (os .path .join (buildinstaller , "share" ),
160168 os .path .join (exeDebPath , "share" ))
@@ -173,23 +181,24 @@ def main():
173181
174182 shutil .copyfile (os .path .join (projectbase , "images" , "author.jpg" ),
175183 os .path .join (exeDebPath , "author.jpg" ))
176-
177- # deploy the software
184+
185+ # deploy the software
178186
179187 print (Fore .GREEN + ">> Copying finished, deploying the software..." + Style .RESET_ALL )
180188
181189 try :
182- subprocess .run ([deploy_exec , os .path .join (exeDebPath , exe_name ) ], check = True ,
183- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
190+ subprocess .run ([deploy_exec , os .path .join (exeDebPath , exe_name )], check = True ,
191+ stdout = subprocess .PIPE , stderr = subprocess .PIPE )
184192 except subprocess .CalledProcessError as e :
185- print (Fore .RED + f"[Error] deploy package error: \n { e .stderr .decode ('utf-8' )} " + Style .RESET_ALL )
193+ print (
194+ Fore .RED + f"[Error] deploy package error: \n { e .stderr .decode ('utf-8' )} " + Style .RESET_ALL )
186195 exit (- 4 )
187196 except FileNotFoundError :
188- exit (- 4 )
197+ exit (- 4 )
189198
190199 # generate iss file
191200 print (Fore .GREEN + ">> Copying finished, generate ISCC script..." + Style .RESET_ALL )
192-
201+
193202 iss_content = fr"""
194203; Script generated by the mkinnopak.py by wingsummer.
195204
@@ -243,8 +252,10 @@ def main():
243252; NOTE: Don't use "Flags: ignoreversion" on any shared system files
244253
245254"""
246- iss_content += fr'Source: "{ exeDebPath } \*"; ' + r'DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "*.iss,{#MyOutputBaseFilename}.exe,README.md"' + '\n '
247- iss_content += fr'Source: "{ exeDebPath } \README.md"; ' + r'DestDir: "{app}"; Flags: isreadme'
255+ iss_content += fr'Source: "{ exeDebPath } \*"; ' + \
256+ r'DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "*.iss,{#MyOutputBaseFilename}.exe,README.md"' + '\n '
257+ iss_content += fr'Source: "{ exeDebPath } \README.md"; ' + \
258+ r'DestDir: "{app}"; Flags: isreadme'
248259
249260 iss_content += """
250261[Registry]
@@ -271,21 +282,21 @@ def main():
271282"""
272283
273284 script_src = os .path .join (exeDebPath , "mkiss.iss" )
274- with codecs .open (script_src ,'w' , "utf-8-sig" ) as iss :
285+ with codecs .open (script_src , 'w' , "utf-8-sig" ) as iss :
275286 iss .write (iss_content )
276287
277288 if args .build == False :
278289 exit (0 )
279-
290+
280291 print (Fore .GREEN + ">> Copying finished, running ISCC building..." + Style .RESET_ALL )
281-
292+
282293 pak_out = ""
283294 if args .output is None :
284- pak_out = os .path .join (exeDebPath ,".." )
295+ pak_out = os .path .join (exeDebPath , ".." )
285296 else :
286297 pak_out = args .output
287-
288- ret = run_command_interactive ([args .cc , f'/O{ pak_out } ' , script_src ])
298+
299+ ret = run_command_interactive ([args .cc , f'/O{ pak_out } ' , script_src ])
289300 exit (ret )
290301
291302
0 commit comments