|
|
@ -9,7 +9,7 @@ import platform
|
|
|
|
import warnings
|
|
|
|
import warnings
|
|
|
|
import traceback
|
|
|
|
import traceback
|
|
|
|
from pathlib import Path
|
|
|
|
from pathlib import Path
|
|
|
|
from typing import List, Tuple, Optional, Union
|
|
|
|
from typing import List, Tuple, Optional, Union, Any
|
|
|
|
|
|
|
|
|
|
|
|
from Difficult_Rocket.api.types import Options, Version, VersionRequirement
|
|
|
|
from Difficult_Rocket.api.types import Options, Version, VersionRequirement
|
|
|
|
|
|
|
|
|
|
|
@ -20,14 +20,14 @@ def ensure_cmd_readable(cmd: str) -> str:
|
|
|
|
:param cmd: 要格式化的命令行参数
|
|
|
|
:param cmd: 要格式化的命令行参数
|
|
|
|
:return: 格式化后的命令行参数
|
|
|
|
:return: 格式化后的命令行参数
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
if ' ' in cmd:
|
|
|
|
if ' ' in str(cmd):
|
|
|
|
return f'"{cmd}"'
|
|
|
|
return f'"{cmd}"'
|
|
|
|
return cmd
|
|
|
|
return cmd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_cmd(arg_name: Optional[str] = None,
|
|
|
|
def format_cmd(arg_name: Optional[str] = None,
|
|
|
|
arg_value: Optional[Union[str, List[str]]] = None,
|
|
|
|
arg_value: Optional[Union[str, List[str]]] = None,
|
|
|
|
write: Optional[bool] = True) -> List[str]:
|
|
|
|
write: Optional[Any] = True) -> List[str]:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
用来格式化输出命令行参数
|
|
|
|
用来格式化输出命令行参数
|
|
|
|
:param arg_name: 类似 --show-memory 之类的主项
|
|
|
|
:param arg_name: 类似 --show-memory 之类的主项
|
|
|
@ -66,7 +66,7 @@ class CompilerHelper(Options):
|
|
|
|
src_file: Path = Path('DR.py')
|
|
|
|
src_file: Path = Path('DR.py')
|
|
|
|
|
|
|
|
|
|
|
|
python_cmd: str = 'python'
|
|
|
|
python_cmd: str = 'python'
|
|
|
|
compat_nuitka_version: VersionRequirement = VersionRequirement("~1.7.1") # STATIC VERSION
|
|
|
|
compat_nuitka_version: VersionRequirement = VersionRequirement("~1.8.1") # STATIC VERSION
|
|
|
|
|
|
|
|
|
|
|
|
# 以下为 nuitka 的参数
|
|
|
|
# 以下为 nuitka 的参数
|
|
|
|
use_lto: bool = False # --lto=yes (no is faster)
|
|
|
|
use_lto: bool = False # --lto=yes (no is faster)
|
|
|
@ -82,6 +82,8 @@ class CompilerHelper(Options):
|
|
|
|
remove_output: bool = True # --remove-output
|
|
|
|
remove_output: bool = True # --remove-output
|
|
|
|
save_xml: bool = False # --xml
|
|
|
|
save_xml: bool = False # --xml
|
|
|
|
xml_path: Path = Path('build/compile_data.xml')
|
|
|
|
xml_path: Path = Path('build/compile_data.xml')
|
|
|
|
|
|
|
|
save_report: bool = False # --report
|
|
|
|
|
|
|
|
report_path: Path = Path('build/compile_report.xml')
|
|
|
|
|
|
|
|
|
|
|
|
download_confirm: bool = True # --assume-yes-for-download
|
|
|
|
download_confirm: bool = True # --assume-yes-for-download
|
|
|
|
run_after_build: bool = False # --run
|
|
|
|
run_after_build: bool = False # --run
|
|
|
@ -105,7 +107,7 @@ class CompilerHelper(Options):
|
|
|
|
include_packages: List[str] = ['Difficult_Rocket.api']
|
|
|
|
include_packages: List[str] = ['Difficult_Rocket.api']
|
|
|
|
|
|
|
|
|
|
|
|
enable_plugin: List[str] = [] # --enable-plugin=xxx,xxx
|
|
|
|
enable_plugin: List[str] = [] # --enable-plugin=xxx,xxx
|
|
|
|
disable_plugin: List[str] = [] # --disable-plugin=xxx,xxx
|
|
|
|
disable_plugin: List[str] = ['pyqt5', 'tk-inter'] # --disable-plugin=xxx,xxx
|
|
|
|
|
|
|
|
|
|
|
|
def init(self, **kwargs) -> None:
|
|
|
|
def init(self, **kwargs) -> None:
|
|
|
|
if (compat_version := kwargs.get('compat_nuitka_version')) is not None:
|
|
|
|
if (compat_version := kwargs.get('compat_nuitka_version')) is not None:
|
|
|
@ -166,40 +168,41 @@ class CompilerHelper(Options):
|
|
|
|
cmd_list = [self.python_cmd, '-m', 'nuitka']
|
|
|
|
cmd_list = [self.python_cmd, '-m', 'nuitka']
|
|
|
|
# macos 和 非 macos icon 参数不同
|
|
|
|
# macos 和 非 macos icon 参数不同
|
|
|
|
if platform.system() == 'Darwin':
|
|
|
|
if platform.system() == 'Darwin':
|
|
|
|
cmd_list.append(f"--macos-app-version={self.product_version}")
|
|
|
|
cmd_list += format_cmd('--macos-app-version=', self.product_version, self.product_version) # noqa
|
|
|
|
_add_cmd(cmd_list, f'--macos-app-icon={self.icon_path.absolute()}' if self.icon_path else None)
|
|
|
|
cmd_list += format_cmd('--macos-app-icon=', self.icon_path.absolute(), self.icon_path) # noqa
|
|
|
|
elif platform.system() == 'Windows':
|
|
|
|
elif platform.system() == 'Windows':
|
|
|
|
_add_cmd(cmd_list, f'--windows-icon-from-ico={self.icon_path.absolute()}' if self.icon_path else None)
|
|
|
|
cmd_list += format_cmd('--windows-icon-from-ico=', self.icon_path.absolute(), self.icon_path) # noqa
|
|
|
|
elif platform.system() == 'Linux':
|
|
|
|
elif platform.system() == 'Linux':
|
|
|
|
_add_cmd(cmd_list, f'--linux-icon={self.icon_path.absolute()}' if self.icon_path else None)
|
|
|
|
cmd_list += format_cmd('--linux-icon=', self.icon_path.absolute(), self.icon_path) # noqa
|
|
|
|
|
|
|
|
|
|
|
|
_add_cmd(cmd_list, '--lto=yes' if self.use_lto else '--lto=no')
|
|
|
|
cmd_list += format_cmd('--lto=', 'yes' if self.use_lto else 'no')
|
|
|
|
_add_cmd(cmd_list, '--clang' if self.use_clang else None)
|
|
|
|
cmd_list += format_cmd('--clang' if self.use_clang else None)
|
|
|
|
_add_cmd(cmd_list, '--msvc=latest' if self.use_msvc else None)
|
|
|
|
cmd_list += format_cmd('--msvc=latest' if self.use_msvc else None)
|
|
|
|
_add_cmd(cmd_list, '--mingw64' if self.use_mingw else None)
|
|
|
|
cmd_list += format_cmd('--mingw64' if self.use_mingw else None)
|
|
|
|
_add_cmd(cmd_list, '--standalone' if self.standalone else None)
|
|
|
|
cmd_list += format_cmd('--standalone' if self.standalone else None)
|
|
|
|
|
|
|
|
|
|
|
|
_add_cmd(cmd_list, '--disable-ccache' if not self.use_ccache else None)
|
|
|
|
cmd_list += format_cmd('--disable-ccache' if not self.use_ccache else None)
|
|
|
|
_add_cmd(cmd_list, '--show-progress' if self.show_progress else None)
|
|
|
|
cmd_list += format_cmd('--show-progress' if self.show_progress else None)
|
|
|
|
_add_cmd(cmd_list, '--show-memory' if self.show_memory else None)
|
|
|
|
cmd_list += format_cmd('--show-memory' if self.show_memory else None)
|
|
|
|
_add_cmd(cmd_list, '--remove-output' if self.remove_output else None)
|
|
|
|
cmd_list += format_cmd('--remove-output' if self.remove_output else None)
|
|
|
|
_add_cmd(cmd_list, '--assume-yes-for-download' if self.download_confirm else None)
|
|
|
|
cmd_list += format_cmd('--assume-yes-for-download' if self.download_confirm else None)
|
|
|
|
_add_cmd(cmd_list, '--run' if self.run_after_build else None)
|
|
|
|
cmd_list += format_cmd('--run' if self.run_after_build else None)
|
|
|
|
_add_cmd(cmd_list, '--enable-console' if self.enable_console else '--disable-console')
|
|
|
|
cmd_list += format_cmd('--enable-console' if self.enable_console else '--disable-console')
|
|
|
|
|
|
|
|
|
|
|
|
_add_cmd(cmd_list, f'--xml={self.xml_path.absolute()}' if self.save_xml else None)
|
|
|
|
cmd_list += format_cmd('--xml=', str(self.xml_path.absolute()), self.save_xml)
|
|
|
|
_add_cmd(cmd_list, f'--output-dir={self.output_path.absolute()}' if self.output_path else None)
|
|
|
|
cmd_list += format_cmd('--report=', str(self.report_path.absolute()), self.save_report)
|
|
|
|
_add_cmd(cmd_list, f'--company-name={self.company_name}' if self.company_name else None)
|
|
|
|
cmd_list += format_cmd('--output-dir=', str(self.output_path.absolute()), self.output_path)
|
|
|
|
_add_cmd(cmd_list, f'--product-name={self.product_name}' if self.product_name else None)
|
|
|
|
cmd_list += format_cmd('--company-name=', self.company_name, self.company_name)
|
|
|
|
_add_cmd(cmd_list, f'--file-version={self.file_version}' if self.file_version else None)
|
|
|
|
cmd_list += format_cmd('--product-name=', self.product_name, self.product_name)
|
|
|
|
_add_cmd(cmd_list, f'--product-version={self.product_version}' if self.product_version else None)
|
|
|
|
cmd_list += format_cmd('--file-version=', str(self.file_version), self.file_version)
|
|
|
|
_add_cmd(cmd_list, f'--file-description={self.file_description}' if self.file_description else None)
|
|
|
|
cmd_list += format_cmd('--product-version=', str(self.product_version), self.product_version)
|
|
|
|
_add_cmd(cmd_list, f'--copyright={self.copy_right}' if self.copy_right else None)
|
|
|
|
cmd_list += format_cmd('--file-description=', self.file_description, self.file_description)
|
|
|
|
|
|
|
|
cmd_list += format_cmd('--copyright=', self.copy_right, self.copy_right)
|
|
|
|
|
|
|
|
|
|
|
|
_add_cmd(cmd_list, f'--follow-import-to={",".join(self.follow_import)}' if self.follow_import else None)
|
|
|
|
cmd_list += format_cmd('--follow-import-to=', self.follow_import, self.follow_import)
|
|
|
|
_add_cmd(cmd_list, f'--nofollow-import-to={",".join(self.no_follow_import)}' if self.no_follow_import else None)
|
|
|
|
cmd_list += format_cmd('--nofollow-import-to=', self.no_follow_import, self.no_follow_import)
|
|
|
|
_add_cmd(cmd_list, f'--enable-plugin={",".join(self.enable_plugin)}' if self.enable_plugin else None)
|
|
|
|
cmd_list += format_cmd('--enable-plugin=', self.enable_plugin, self.enable_plugin)
|
|
|
|
_add_cmd(cmd_list, f'--disable-plugin={",".join(self.disable_plugin)}' if self.disable_plugin else None)
|
|
|
|
cmd_list += format_cmd('--disable-plugin=', self.disable_plugin, self.disable_plugin)
|
|
|
|
|
|
|
|
|
|
|
|
if self.include_data_dir:
|
|
|
|
if self.include_data_dir:
|
|
|
|
cmd_list += [f"--include-data-dir={src}={dst}" for src, dst in self.include_data_dir]
|
|
|
|
cmd_list += [f"--include-data-dir={src}={dst}" for src, dst in self.include_data_dir]
|
|
|
|