2024-11-06 06:46:35 +08:00
|
|
|
import os, sys, re, shutil
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
rootDir = os.path.dirname(__file__)
|
|
|
|
if not rootDir:
|
|
|
|
rootDir = os.path.abspath(".")
|
2024-11-16 21:42:52 +08:00
|
|
|
rootDir = os.path.abspath(os.path.join(rootDir, "../../cpp/LunaHook"))
|
2024-11-06 06:46:35 +08:00
|
|
|
if len(sys.argv) and sys.argv[1] == "loadversion":
|
|
|
|
os.chdir(rootDir)
|
|
|
|
with open("CMakeLists.txt", "r", encoding="utf8") as ff:
|
|
|
|
pattern = r"set\(VERSION_MAJOR\s*(\d+)\s*\)\nset\(VERSION_MINOR\s*(\d+)\s*\)\nset\(VERSION_PATCH\s*(\d+)\s*\)"
|
|
|
|
match = re.findall(pattern, ff.read())[0]
|
|
|
|
version_major, version_minor, version_patch = match
|
|
|
|
versionstring = f"v{version_major}.{version_minor}.{version_patch}"
|
|
|
|
print("version=" + versionstring)
|
|
|
|
exit()
|
|
|
|
if len(sys.argv) and sys.argv[1] == "merge":
|
2024-11-06 23:45:31 +08:00
|
|
|
os.chdir(rootDir)
|
2024-11-06 06:46:35 +08:00
|
|
|
os.mkdir("../build")
|
|
|
|
os.mkdir("builds")
|
2024-12-16 01:48:39 +08:00
|
|
|
|
|
|
|
shutil.copytree(
|
|
|
|
f"build/64/Release",
|
|
|
|
f"../build/Release",
|
|
|
|
dirs_exist_ok=True,
|
|
|
|
)
|
|
|
|
shutil.copytree(
|
|
|
|
f"build/winxp/Release_winxp",
|
|
|
|
f"../build/Release",
|
|
|
|
dirs_exist_ok=True,
|
|
|
|
)
|
2024-11-06 06:46:35 +08:00
|
|
|
|
2024-12-16 01:48:39 +08:00
|
|
|
targetdir = f"../build/Release"
|
|
|
|
target = f"builds/Release.zip"
|
|
|
|
os.system(
|
|
|
|
rf'"C:\Program Files\7-Zip\7z.exe" a -m0=Deflate -mx9 {target} {targetdir}'
|
|
|
|
)
|
2024-11-06 06:46:35 +08:00
|
|
|
exit()
|
|
|
|
|
|
|
|
print(sys.version)
|
|
|
|
print(__file__)
|
|
|
|
print(rootDir)
|
|
|
|
|
|
|
|
|
2024-12-16 01:48:39 +08:00
|
|
|
def build_langx(bit, onlycore):
|
2024-11-07 22:50:54 +08:00
|
|
|
config = (
|
2024-12-16 01:48:39 +08:00
|
|
|
f"-DBUILD_PLUGIN=OFF -DWINXP=OFF -DBUILD_GUI=ON -DBUILD_CLI=ON"
|
2024-11-07 22:50:54 +08:00
|
|
|
if not onlycore
|
|
|
|
else ""
|
|
|
|
)
|
2024-11-06 06:46:35 +08:00
|
|
|
with open("do.bat", "w") as ff:
|
|
|
|
if bit == "32":
|
|
|
|
ff.write(
|
|
|
|
rf"""
|
2024-12-16 01:48:39 +08:00
|
|
|
cmake {config} ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/x86
|
|
|
|
cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14
|
2024-11-06 06:46:35 +08:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
elif bit == "64":
|
|
|
|
ff.write(
|
|
|
|
rf"""
|
2024-12-16 01:48:39 +08:00
|
|
|
cmake {config} ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/x64
|
|
|
|
cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14
|
2024-11-06 06:46:35 +08:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
os.system(f"cmd /c do.bat")
|
|
|
|
|
|
|
|
|
2024-12-16 01:48:39 +08:00
|
|
|
def build_langx_xp( core):
|
2024-11-06 23:45:31 +08:00
|
|
|
url = "https://github.com/Chuyu-Team/YY-Thunks/releases/download/v1.0.7/YY-Thunks-1.0.7-Binary.zip"
|
2024-11-15 03:04:53 +08:00
|
|
|
os.system(rf"curl -SLo YY-Thunks-1.0.7-Binary.zip " + url)
|
|
|
|
os.system(rf"7z x -y YY-Thunks-1.0.7-Binary.zip -o../../libs/YY-Thunks")
|
2024-11-07 22:50:54 +08:00
|
|
|
os.system("dir")
|
2024-11-16 21:42:52 +08:00
|
|
|
flags = "" if core else " -DBUILD_GUI=ON -DBUILD_CLI=ON "
|
2024-11-06 06:46:35 +08:00
|
|
|
with open("do.bat", "w") as ff:
|
|
|
|
ff.write(
|
|
|
|
rf"""
|
|
|
|
|
2024-12-16 01:48:39 +08:00
|
|
|
cmake -DBUILD_PLUGIN=OFF -DWINXP=ON {flags} ../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
|
2024-11-06 06:46:35 +08:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
os.system(f"cmd /c do.bat")
|
|
|
|
|
2024-11-16 21:42:52 +08:00
|
|
|
|
2024-11-06 06:46:35 +08:00
|
|
|
os.chdir(os.path.join(rootDir, "scripts"))
|
2024-11-16 21:42:52 +08:00
|
|
|
if sys.argv[1] == "plugin":
|
|
|
|
bits = sys.argv[2]
|
|
|
|
with open("buildplugin.bat", "w") as ff:
|
|
|
|
if bits == "32":
|
|
|
|
ff.write(
|
|
|
|
rf"""
|
|
|
|
cmake -DBUILD_CORE=OFF -DUSESYSQTPATH=1 -DBUILD_PLUGIN=ON ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/plugin32
|
|
|
|
cmake --build ../build/plugin32 --config Release --target ALL_BUILD -j 14
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
ff.write(
|
|
|
|
rf"""
|
|
|
|
cmake -DBUILD_CORE=OFF -DUSESYSQTPATH=1 -DBUILD_PLUGIN=ON ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/plugin64
|
|
|
|
cmake --build ../build/plugin64 --config Release --target ALL_BUILD -j 14
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
os.system(f"cmd /c buildplugin.bat")
|
2024-11-06 06:46:35 +08:00
|
|
|
elif sys.argv[1] == "build":
|
2024-12-16 01:48:39 +08:00
|
|
|
bit = sys.argv[2]
|
2024-11-06 06:46:35 +08:00
|
|
|
if bit == "winxp":
|
2024-12-16 01:48:39 +08:00
|
|
|
build_langx_xp(False)
|
2024-11-15 03:07:37 +08:00
|
|
|
elif bit == "winxp_core":
|
2024-12-16 01:48:39 +08:00
|
|
|
build_langx_xp(True)
|
2024-11-06 06:46:35 +08:00
|
|
|
else:
|
2024-11-07 22:50:54 +08:00
|
|
|
onlycore = int(sys.argv[4]) if len(sys.argv) >= 5 else False
|
2024-12-16 01:48:39 +08:00
|
|
|
build_langx(bit, onlycore)
|