@@ -56,6 +56,8 @@ def main():
5656 dist_path = base_dir / task ['distpath' ]
5757 requirements = task .get ('install-requirements' , [])
5858 use_upx = task .get ('upx' , False )
59+ enable_plugins = task .get ('enable-plugins' , [])
60+
5961 # onefile = task.get('onefile', 0)
6062 icon = task .get ('icon' )
6163 windows_disable_console = task .get ('windows-disable-console' , False )
@@ -66,7 +68,7 @@ def main():
6668 if arrch == "AMD64" :
6769 arrch = "x64"
6870 output_name = output_name_template .replace ('{{name}}' , name ).replace ('{{version}}' , version ).replace ('{{arch}}' , arrch ).replace ('{{os}}' , Machine )
69-
71+ custom_command = task . get ( 'custom-command' )
7072 # 检查操作系统和架构
7173 # if Machine not in task.get('os', []):
7274 # print(f"警告: 任务 [{i}/{len(config)} {task['name']}] 不支持当前操作系统 {Machine}")
@@ -113,20 +115,42 @@ def main():
113115 print (f"警告: 图标文件不存在 { icon_path } " )
114116
115117
116- if arrch == "ARM64" :
117- print ("UPX不支持当前架构" )
118- else :
119- if use_upx :
118+ # if arrch == "ARM64":
119+ # print("UPX不支持当前架构")
120+ # else:
121+ # if use_upx:
122+ # if upx_dir.exists():
123+ # cmd.append('--plugin-enable=upx')
124+ # cmd.append(f'--upx-binary={str(upx_dir)}')
125+ # print(f"使用UPX压缩: {upx_dir}")
126+ # else:
127+ # print(f"警告: UPX目录不存在 {upx_dir}")
128+ # else:
129+ # print("不使用UPX压缩")
130+
131+ if enable_plugins :
132+ plugin_list = ''
133+ if len (enable_plugins ) == 1 :
134+ plugin_list = enable_plugins [0 ]
135+ else :
136+ plugin_list = ',' .join (enable_plugins )
137+ cmd .append (f'--plugin-enable={ plugin_list } ' )
138+ if 'upx' in enable_plugins :
120139 if upx_dir .exists ():
121- cmd .append ('--plugin-enable=upx' )
122140 cmd .append (f'--upx-binary={ str (upx_dir )} ' )
123141 print (f"使用UPX压缩: { upx_dir } " )
124142 else :
125143 print (f"警告: UPX目录不存在 { upx_dir } " )
126- else :
127- print ("不使用UPX压缩" )
128144
129- # 添加主Python文件
145+ if custom_command :
146+ # custom_command 为 str
147+ if isinstance (custom_command , str ):
148+ cmd .extend (custom_command .split ())
149+ # custom_command 为 list
150+ elif isinstance (custom_command , list ):
151+ cmd .extend (custom_command )
152+
153+ # 避免中文等特殊字符导致编译报错
130154 t_file = str (uuid .uuid4 ()) + ".py"
131155 t_file_path = base_dir / t_file
132156 shutil .copy (str (python_file ), t_file_path )
0 commit comments