fix: msi, app icon (#7830)

* fix: msi, app icon

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* refact: check if icon.ico exists

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2024-04-25 22:35:51 +08:00 committed by GitHub
parent 92748de7d4
commit 4dfc82f684
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 0 deletions

2
res/msi/.gitignore vendored
View File

@ -9,3 +9,5 @@ packages
CustomActions/x64 CustomActions/x64
CustomActions/*.user CustomActions/*.user
CustomActions/*.filters CustomActions/*.filters
Package/Resources

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

View File

@ -9,6 +9,7 @@ import datetime
import subprocess import subprocess
import re import re
from pathlib import Path from pathlib import Path
import shutil
g_indent_unit = "\t" g_indent_unit = "\t"
g_version = "" g_version = ""
@ -391,6 +392,19 @@ def gen_content_between_tags(filename, tag_start, tag_end, func):
return True return True
def prepare_resources():
icon_src = Path(sys.argv[0]).parent.joinpath("../icon.ico")
icon_dst = Path(sys.argv[0]).parent.joinpath("Package/Resources/icon.ico")
if icon_src.exists():
icon_dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy(icon_src, icon_dst)
return True
else:
# unreachable
print(f"Error: icon.ico not found in {icon_src}")
return False
def init_global_vars(dist_dir, app_name, args): def init_global_vars(dist_dir, app_name, args):
dist_app = dist_dir.joinpath(app_name + ".exe") dist_app = dist_dir.joinpath(app_name + ".exe")
@ -446,6 +460,9 @@ if __name__ == "__main__":
app_name = args.app_name app_name = args.app_name
dist_dir = Path(sys.argv[0]).parent.joinpath(args.dist_dir).resolve() dist_dir = Path(sys.argv[0]).parent.joinpath(args.dist_dir).resolve()
if not prepare_resources():
sys.exit(-1)
if not init_global_vars(dist_dir, app_name, args): if not init_global_vars(dist_dir, app_name, args):
sys.exit(-1) sys.exit(-1)