Compare commits

...

5 Commits

Author SHA1 Message Date
b8cbf8a439
构建参数喜加一 2023-09-17 23:00:01 +08:00
404fd63c03
理论可行,实践开始! 2023-09-17 22:21:45 +08:00
225882dcf8
水commit啦 2023-09-17 22:21:27 +08:00
5155c05d74
先更新一下依赖版本 2023-09-17 22:12:11 +08:00
a57e67b2a1
刷点commit也不错 2023-09-17 21:18:20 +08:00
6 changed files with 61 additions and 37 deletions

View File

@ -11,7 +11,7 @@ from pathlib import Path
from Difficult_Rocket.api.types import Options, Version from Difficult_Rocket.api.types import Options, Version
sdk_version = Version("0.8.7.0") # SDK 版本 sdk_version = Version("0.8.7.0") # SDK 版本
build_version = Version("2.1.3.0") # 编译文件版本(与游戏本体无关) build_version = Version("2.2.0.0") # 编译文件版本(与游戏本体无关)
Api_version = Version("0.1.1.0") # API 版本 Api_version = Version("0.1.1.0") # API 版本
__version__ = sdk_version __version__ = sdk_version

View File

@ -2,7 +2,23 @@
# DR 构建 更新日志 # DR 构建 更新日志
- 最新构建版本号 - 最新构建版本号
- build_version: 2.1.3.0 - build_version: 2.2.0.0
## 20230917 build 2.2.0.0
### 修改
- 删掉了蹩脚的 `_add_cmd`
- 可读性更好的写法
- 反正建议自己去看源码修改
- 现在应该可以直接运行输出的脚本了
- 不需要手动给带空格的参数添加引号了
- 给 `--disable-plugin` 添加了
- `pyqt5`
- `tk-inter`
- 防止因为 `pyperclicp` 把他俩打包进来
- 添加了几行 `# noqa`
- 向 linker 低头
## 20230715 build 2.1.3.0 ## 20230715 build 2.1.3.0

View File

@ -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]

View File

@ -26,6 +26,7 @@ if __name__ == '__main__':
compiler.python_cmd = sys.executable compiler.python_cmd = sys.executable
compiler.xml_path = Path(f"./build/compile_data-{time.time()}.xml") compiler.xml_path = Path(f"./build/compile_data-{time.time()}.xml")
compiler.report_path = Path(f"./build/compile_report-{time.time()}.xml")
# 检测 --github 参数 # 检测 --github 参数
is_github = False is_github = False
@ -43,6 +44,10 @@ if __name__ == '__main__':
compiler.save_xml = True compiler.save_xml = True
sys.argv.remove('--xml') sys.argv.remove('--xml')
if '--report' in sys.argv:
compiler.save_report = True
sys.argv.remove('--report')
# 检测 --output xx 参数 # 检测 --output xx 参数
if '--output' in sys.argv: if '--output' in sys.argv:
# 输入的是输出目录 # 输入的是输出目录

View File

@ -18,7 +18,7 @@ defusedxml >= 0.7.1
objprint >= 0.2.2 objprint >= 0.2.2
# for compile # for compile
nuitka >= 1.7.5 nuitka >= 1.8.1
ordered-set >= 4.1.0 ordered-set >= 4.1.0
imageio >= 2.31.0; (platform_python_implementation == "PyPy" and python_version < "3.10") or platform_python_implementation == "CPython" imageio >= 2.31.0; (platform_python_implementation == "PyPy" and python_version < "3.10") or platform_python_implementation == "CPython"
wheel >= 0.40.0 wheel >= 0.40.0

View File

@ -21,7 +21,7 @@ viztracer >= 0.15.6; platform_python_implementation != "PyPy"
vizplugins >= 0.1.3; platform_python_implementation != "PyPy" vizplugins >= 0.1.3; platform_python_implementation != "PyPy"
# for compile # for compile
nuitka >= 1.7.5 nuitka >= 1.8.1
ordered-set >= 4.1.0 ordered-set >= 4.1.0
imageio >= 2.31.0; (platform_python_implementation == "PyPy" and python_version < "3.10") or platform_python_implementation == "CPython" imageio >= 2.31.0; (platform_python_implementation == "PyPy" and python_version < "3.10") or platform_python_implementation == "CPython"
wheel >= 0.40.0 wheel >= 0.40.0