From 09d06b3a360674eb1fb4a386440de9dfed746ea3 Mon Sep 17 00:00:00 2001 From: Ayase Date: Fri, 26 Apr 2024 16:45:45 +0800 Subject: [PATCH] actions: fix, add 32xp support --- .github/workflows/release.yml | 105 +++++++++++++++++++++++++++++++++- build.py | 38 ++++++------ scripts/build32xp.bat | 8 +-- scripts/pack.py | 44 ++++++++++---- 4 files changed, 162 insertions(+), 33 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59c727d..3e86460 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,45 @@ on: env: QT_VERSION: 5.15.2 jobs: + build_xp: + runs-on: windows-2019 + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup Windows 10 SDK + uses: GuillaumeFalourd/setup-windows10-sdk-action@v2 + with: + sdk-version: 22621 + - name: Install Qt32 + uses: jurplel/install-qt-action@v3.3.0 + with: + version: ${{ env.QT_VERSION }} + host: windows + target: desktop + arch: win32_msvc2019 + dir: ${{ runner.temp }} + setup-python: true + - name: Run build script 32xp + run: python build.py 32xp + + - name: Pack + run: python build.py pack_xp + # - name: Upload plugin32_xp artifact + # uses: actions/upload-artifact@v4 + # with: + # name: plugin32_xp + # path: builds/plugin32_xp.zip + - name: Upload English xp artifact + uses: actions/upload-artifact@v4 + with: + name: Release_English_xp + path: builds/Release_English_xp.zip + - name: Upload Chinese xp artifact + uses: actions/upload-artifact@v4 + with: + name: Release_Chinese_xp + path: builds/Release_Chinese_xp.zip + build: runs-on: windows-latest steps: @@ -44,9 +83,71 @@ jobs: setup-python: true - name: Run build script run: python build.py 64 + - name: Pack - run: python build.py 0 - - name: Release LunaTranslator + run: python build.py pack + - name: Upload plugin32 artifact + uses: actions/upload-artifact@v4 + with: + name: plugin32 + path: builds/plugin32.zip + - name: Upload plugin64 artifact + uses: actions/upload-artifact@v4 + with: + name: plugin64 + path: builds/plugin64.zip + - name: Upload English artifact + uses: actions/upload-artifact@v4 + with: + name: Release_English + path: builds/Release_English.zip + - name: Upload Chinese artifact + uses: actions/upload-artifact@v4 + with: + name: Release_Chinese + path: builds/Release_Chinese.zip + release: + needs: [build, build_xp] + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Download plugin32 artifact + uses: actions/download-artifact@v4 + with: + name: plugin32 + path: builds + - name: Download plugin64 artifact + uses: actions/download-artifact@v4 + with: + name: plugin64 + path: builds + - name: Download English artifact + uses: actions/download-artifact@v4 + with: + name: Release_English + path: builds + - name: Download Chinese artifact + uses: actions/download-artifact@v4 + with: + name: Release_Chinese + path: builds + # - name: Download plugin32_xp artifact + # uses: actions/download-artifact@v4 + # with: + # name: plugin32_xp + # path: builds + - name: Download English xp artifact + uses: actions/download-artifact@v4 + with: + name: Release_English_xp + path: builds + - name: Download Chinese xp artifact + uses: actions/download-artifact@v4 + with: + name: Release_Chinese_xp + path: builds + - name: Release LunaHook uses: softprops/action-gh-release@v2 with: tag_name: ${{ github.event.inputs.create_release }} diff --git a/build.py b/build.py index dbf9e05..cf1355e 100644 --- a/build.py +++ b/build.py @@ -1,25 +1,31 @@ - -import os,sys -import shutil +import os, sys import subprocess rootDir = os.path.dirname(__file__) vcltlFile = "https://github.com/Chuyu-Team/VC-LTL5/releases/download/v5.0.9/VC-LTL-5.0.9-Binary.7z" vcltlFileName = "VC-LTL-5.0.9-Binary.7z" +availableTargets = ["32xp", "32", "64"] + + def installVCLTL(): - os.makedirs(rootDir + "\\temp",exist_ok=True) - os.chdir(rootDir + "\\temp") - subprocess.run(f"curl -LO {vcltlFile}") - subprocess.run(f"7z x {vcltlFileName} -oVC-LTL5") - os.chdir("VC-LTL5") - subprocess.run("cmd /c Install.cmd") -os.chdir(os.path.join(rootDir,'scripts')) -if int(sys.argv[1])==32: + os.chdir(rootDir) + if os.path.exists("temp"): + return # already installed + os.makedirs(rootDir + "\\temp", exist_ok=True) + subprocess.run(f"curl -Lo temp\\{vcltlFileName} {vcltlFile}") + subprocess.run(f"7z x temp\\{vcltlFileName} -otemp\\VC-LTL5") + subprocess.run("cmd /c temp\\VC-LTL5\\Install.cmd") + + +target = sys.argv[1] +os.chdir(os.path.join(rootDir, "scripts")) +if target in availableTargets: installVCLTL() - os.system('cmd /c build32.bat') -elif int(sys.argv[1])==64: - installVCLTL() - os.system('cmd /c build64.bat') + os.chdir(os.path.join(rootDir, "scripts")) + os.system(f"cmd /c build{target}.bat") else: - os.system('cmd /c pack.bat') \ No newline at end of file + if target == "pack": + os.system(f"python pack.py pack") + else: + os.system(f"python pack.py pack_xp") diff --git a/scripts/build32xp.bat b/scripts/build32xp.bat index 4010d80..b4c3deb 100644 --- a/scripts/build32xp.bat +++ b/scripts/build32xp.bat @@ -1,8 +1,8 @@ -@REM cmake ../CMakeLists.txt -G "Visual Studio 15 2017" -A win32 -T v141_xp -B ../build/xp -@REM cmake --build ../build/xp --config Release --target ALL_BUILD -j 14 +cmake ../CMakeLists.txt -G "Visual Studio 16 2019" -A win32 -T v141_xp -B ../build/x86_xp +cmake --build ../build/x86_xp --config Release --target ALL_BUILD -j 14 -cmake -DWINXP=1 ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/x86_xp -cmake -DWINXP=1 -DLANGUAGE=Chinese ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/x86_zh_xp +cmake -DLANGUAGE=Chinese ../CMakeLists.txt -G "Visual Studio 16 2019" -A win32 -T v141_xp -B ../build/x86_zh_xp +cmake --build ../build/x86_zh_xp --config Release --target ALL_BUILD -j 14 python edit_target.py @echo off diff --git a/scripts/pack.py b/scripts/pack.py index 9e81863..15caa7f 100644 --- a/scripts/pack.py +++ b/scripts/pack.py @@ -1,14 +1,36 @@ -import os, shutil -for f in os.listdir('../builds'): - if os.path.isdir('../builds/'+f)==False:continue - - for dirname,_,fs in os.walk('../builds/'+f): - if dirname.endswith('translations') or dirname.endswith('translations') or dirname.endswith('imageformats') or dirname.endswith('iconengines') or dirname.endswith('bearer'): +import os, shutil, sys + + +isXp = "" +if sys.argv[1] == "pack_xp": + isXp = "_xp" +else: + pass + +for f in os.listdir("../builds"): + if os.path.isdir("../builds/" + f) == False: + continue + + for dirname, _, fs in os.walk("../builds/" + f): + if ( + dirname.endswith("translations") + or dirname.endswith("translations") + or dirname.endswith("imageformats") + or dirname.endswith("iconengines") + or dirname.endswith("bearer") + ): shutil.rmtree(dirname) continue for ff in fs: - path=os.path.join(dirname,ff) - if ff in ['Qt5Svg.dll','libEGL.dll','libGLESv2.dll','opengl32sw.dll','D3Dcompiler_47.dll']:os.remove(path) - targetdir='../builds/'+f - target='../builds/'+f+'.zip' - os.system(rf'"C:\Program Files\7-Zip\7z.exe" a -m0=LZMA -mx9 {target} {targetdir}') \ No newline at end of file + path = os.path.join(dirname, ff) + if ff in [ + "Qt5Svg.dll", + "libEGL.dll", + "libGLESv2.dll", + "opengl32sw.dll", + "D3Dcompiler_47.dll", + ]: + os.remove(path) + targetdir = "../builds/" + f + target = "../builds/" + f + isXp + ".zip" + os.system(rf'"C:\Program Files\7-Zip\7z.exe" a -m0=LZMA -mx9 {target} {targetdir}')