From 63b52b0766bed1016884c86c236d86cd3ed98035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sat, 27 Apr 2024 19:00:12 +0800 Subject: [PATCH] debug build Update build.py 1 --- .github/workflows/build.yml | 10 ++- .../LunaTranslator/LunaTranslator.py | 20 ++--- LunaTranslator/LunaTranslator/keeprefs.py | 5 ++ LunaTranslator/build32.bat | 2 +- LunaTranslator/build64.bat | 2 +- LunaTranslator/pack.py | 11 +++ build.py | 83 ++++++++++--------- 7 files changed, 78 insertions(+), 55 deletions(-) create mode 100644 LunaTranslator/LunaTranslator/keeprefs.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1cff0a7e..7e2726da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,8 +15,16 @@ jobs: include: - architecture: x86 fname: LunaTranslator_x86 + debug: 0 - architecture: x64 fname: LunaTranslator + debug: 0 + - architecture: x86 + fname: LunaTranslator_x86_debug + debug: 1 + - architecture: x64 + fname: LunaTranslator_debug + debug: 1 steps: - name: Checkout code uses: actions/checkout@v4 @@ -38,7 +46,7 @@ jobs: run: pip install cmake pefile requests - name: Run build script run: | - python build.py ${{ matrix.architecture }} + python build.py ${{ matrix.architecture }} ${{ matrix.debug }} - uses: actions/upload-artifact@v4 with: name: ${{ matrix.fname }} diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index 746ec4fd..2c7e026d 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -1,15 +1,12 @@ import time -import re -import os, threading, codecs +import keeprefs +import os, threading from traceback import print_exc from myutils.config import ( globalconfig, savehook_new_list, savehook_new_data, - noundictconfig, - transerrorfixdictconfig, setlanguage, - _TR, static_data, ) import zipfile @@ -22,12 +19,11 @@ from myutils.utils import ( getpostfile, stringfyerror, ) -import os, hashlib from PyQt5.QtWidgets import QApplication -from PyQt5.QtCore import Qt, QSize, QObject, QEvent -from myutils.wrapper import threader, tryprint +from PyQt5.QtCore import Qt, QObject, QEvent +from myutils.wrapper import threader from gui.showword import searchwordW -from myutils.hwnd import getpidexe, testprivilege, ListProcess +from myutils.hwnd import getpidexe, ListProcess from textsource.copyboard import copyboard from textsource.texthook import texthook from textsource.ocrtext import ocrtext @@ -42,14 +38,12 @@ from functools import partial from gui.settin import Settin from gui.showocrimage import showocrimage from gui.attachprocessdialog import AttachProcessDialog -import hmac, pytz, uuid -import xml.etree.ElementTree as ET import windows -import re, gobject +import gobject import winsharedutils from winsharedutils import pid_running from myutils.post import POSTSOLVE -from gui.usefulwidget import Prompt, getQMessageBox +from gui.usefulwidget import Prompt class _autolock: diff --git a/LunaTranslator/LunaTranslator/keeprefs.py b/LunaTranslator/LunaTranslator/keeprefs.py new file mode 100644 index 00000000..a4b78c0d --- /dev/null +++ b/LunaTranslator/LunaTranslator/keeprefs.py @@ -0,0 +1,5 @@ +import hmac +import pytz +import uuid +import xml.etree.ElementTree as ET +import hashlib diff --git a/LunaTranslator/build32.bat b/LunaTranslator/build32.bat index 6497817c..2fd024d7 100644 --- a/LunaTranslator/build32.bat +++ b/LunaTranslator/build32.bat @@ -1 +1 @@ -%LOCALAPPDATA%\Programs\Python\Python37-32\python.exe -m nuitka --standalone --windows-disable-console --plugin-enable=pyqt5 --output-dir=..\build\x86 LunaTranslator\LunaTranslator_main.py --windows-icon-from-ico=..\plugins\exec\luna.ico \ No newline at end of file +%LOCALAPPDATA%\Programs\Python\Python37-32\python.exe -m nuitka --standalone --disable-console --plugin-enable=pyqt5 --output-dir=..\build\x86 LunaTranslator\LunaTranslator_main.py --windows-icon-from-ico=..\plugins\exec\luna.ico \ No newline at end of file diff --git a/LunaTranslator/build64.bat b/LunaTranslator/build64.bat index 76f27364..352679c4 100644 --- a/LunaTranslator/build64.bat +++ b/LunaTranslator/build64.bat @@ -1 +1 @@ -%LOCALAPPDATA%\Programs\Python\Python37\python.exe -m nuitka --standalone --windows-disable-console --plugin-enable=pyqt5 --output-dir=..\build\x64 LunaTranslator\LunaTranslator_main.py --windows-icon-from-ico=..\plugins\exec\luna.ico \ No newline at end of file +%LOCALAPPDATA%\Programs\Python\Python37\python.exe -m nuitka --standalone --disable-console --plugin-enable=pyqt5 --output-dir=..\build\x64 LunaTranslator\LunaTranslator_main.py --windows-icon-from-ico=..\plugins\exec\luna.ico \ No newline at end of file diff --git a/LunaTranslator/pack.py b/LunaTranslator/pack.py index 80fb3eda..891c749f 100644 --- a/LunaTranslator/pack.py +++ b/LunaTranslator/pack.py @@ -2,6 +2,7 @@ import pefile import os,shutil,sys print(sys.argv) x86=int(sys.argv[1]) +isdebug=len(sys.argv)>2 and int(sys.argv[2]) if x86: nuitkadist=r'..\build\x86\LunaTranslator_main.dist' targetdir=r'..\build\LunaTranslator_x86' @@ -16,6 +17,16 @@ else: nuitkadist=r'..\build\x64\LunaTranslator_main.dist' targetdir=r'..\build\LunaTranslator' downlevel=r'C:\Windows\system32\downlevel' +if isdebug: + targetdir+=r'_debug' + if x86: + nuitkadist=r'..\build\x86_debug\LunaTranslator_main.dist' + target='LunaTranslator_x86_debug.zip' + else: + nuitkadist=r'..\build\x64_debug\LunaTranslator_main.dist' + target='LunaTranslator_debug.zip' + + targetdir_in=rf'{targetdir}\LunaTranslator' def get_import_table(file_path): pe = pefile.PE(file_path) diff --git a/build.py b/build.py index d018e7ca..df39def9 100644 --- a/build.py +++ b/build.py @@ -3,9 +3,6 @@ import shutil import subprocess import requests -msbuildPath = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\Bin\\MSBuild.exe" -vcvars32Path = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvars32.bat" -vcvars64Path = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat" pluginDirs = ["DLL32", "DLL64", "Locale_Remulator", "LunaHook", "Magpie", "NTLEAS"] @@ -213,52 +210,60 @@ def buildPlugins(): if __name__ == "__main__": arch = sys.argv[1] + isdebug=len(sys.argv)>2 and int(sys.argv[2]) os.chdir(rootDir) os.makedirs("temp", exist_ok=True) createPluginDirs() - def __1(): - downloadBrotli() - downloadLocaleEmulator() - downloadNtlea() - downloadCurl() - downloadOCRModel("ja") - downloadcommon() - buildLunaHook() - def __2(): - installVCLTL() - buildPlugins() + downloadBrotli() + downloadLocaleEmulator() + downloadNtlea() + downloadCurl() + downloadOCRModel("ja") + downloadcommon() + buildLunaHook() - def __3(): - os.chdir(rootDir) - - py37Path32 = "C:\\hostedtoolcache\\windows\\Python\\3.7.9\\x86\\python.exe" - py37Path64 = "C:\\hostedtoolcache\\windows\\Python\\3.7.9\\x64\\python.exe" - if arch == "x86": - subprocess.run(f"{py37Path32} -m pip install --upgrade pip") - else: - subprocess.run(f"{py37Path64} -m pip install --upgrade pip") + installVCLTL() + buildPlugins() - os.chdir(rootDir + "\\LunaTranslator") - if arch == "x86": - subprocess.run(f"{py37Path32} -m pip install -r requirements.txt") - subprocess.run( - f"{py37Path32} -m nuitka --standalone --assume-yes-for-downloads --windows-disable-console --plugin-enable=pyqt5 --output-dir=..\\build\\x86 LunaTranslator\\LunaTranslator_main.py --windows-icon-from-ico=..\\plugins\\exec\\luna.ico" - ) - else: - subprocess.run(f"{py37Path64} -m pip install -r requirements.txt") - subprocess.run( - f"{py37Path64} -m nuitka --standalone --assume-yes-for-downloads --windows-disable-console --plugin-enable=pyqt5 --output-dir=..\\build\\x64 LunaTranslator\\LunaTranslator_main.py --windows-icon-from-ico=..\\plugins\\exec\\luna.ico" - ) + os.chdir(rootDir) + - __1() - __2() - __3() if arch == "x86": - subprocess.run(f"cmd /c pack32.cmd") + py37Path = "C:\\hostedtoolcache\\windows\\Python\\3.7.9\\x86\\python.exe" else: - subprocess.run(f"cmd /c pack64.cmd") + py37Path = "C:\\hostedtoolcache\\windows\\Python\\3.7.9\\x64\\python.exe" + + os.chdir(rootDir + "\\LunaTranslator") + + cmdline=py37Path + cmdline+=' -m nuitka --standalone --assume-yes-for-downloads ' + if not isdebug: + cmdline+=' --disable-console ' + cmdline+=' --plugin-enable=pyqt5 ' + + if arch == "x86": + if isdebug: + cmdline+='--output-dir=..\\build\\x86_debug' + else: + cmdline+='--output-dir=..\\build\\x86' + else: + if isdebug: + cmdline+='--output-dir=..\\build\\x64_debug' + else: + cmdline+='--output-dir=..\\build\\x64' + cmdline+=' LunaTranslator\\LunaTranslator_main.py --windows-icon-from-ico=..\\plugins\\exec\\luna.ico ' + + subprocess.run(f"{py37Path} -m pip install --upgrade pip") + subprocess.run(f"{py37Path} -m pip install -r requirements.txt") + subprocess.run(cmdline) + + + if arch == "x86": + subprocess.run(f"cmd /c pack32.cmd {isdebug}") + else: + subprocess.run(f"cmd /c pack64.cmd {isdebug}")