diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index c8332d11c7e..7c4d93bac5b 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -103,9 +103,17 @@ def cmd_msbuild( SF_PROJECTS = "https://sourceforge.net/projects" ARCHITECTURES = { - "x86": {"vcvars_arch": "x86", "msbuild_arch": "Win32"}, - "AMD64": {"vcvars_arch": "x86_amd64", "msbuild_arch": "x64"}, - "ARM64": {"vcvars_arch": "x86_arm64", "msbuild_arch": "ARM64"}, + "x86": {"vcvars_arch": "x86", "msbuild_arch": "Win32", "zlibng_arch": "x86"}, + "AMD64": { + "vcvars_arch": "x86_amd64", + "msbuild_arch": "x64", + "zlibng_arch": "x86-64", + }, + "ARM64": { + "vcvars_arch": "x86_arm64", + "msbuild_arch": "ARM64", + "zlibng_arch": "arm64", + }, } V = { @@ -120,11 +128,10 @@ def cmd_msbuild( "OPENJPEG": "2.5.2", "TIFF": "4.6.0", "XZ": "5.6.3", - "ZLIB": "1.3.1", + "ZLIBNG": "2.2.1", } V["LIBPNG_DOTLESS"] = V["LIBPNG"].replace(".", "") V["LIBPNG_XY"] = "".join(V["LIBPNG"].split(".")[:2]) -V["ZLIB_DOTLESS"] = V["ZLIB"].replace(".", "") # dependencies, listed in order of compilation @@ -160,18 +167,17 @@ def cmd_msbuild( "bins": ["cjpeg.exe", "djpeg.exe"], }, "zlib": { - "url": "https://zlib.net/FILENAME", - "filename": f"zlib{V['ZLIB_DOTLESS']}.zip", - "dir": f"zlib-{V['ZLIB']}", - "license": "README", - "license_pattern": "Copyright notice:\n\n(.+)$", + "url": f"https://github.com/zlib-ng/zlib-ng/releases/download/{V['ZLIBNG']}/FILENAME", + "filename": "zlib-ng-win-{zlibng_arch}-compat.zip", + "dir": "", + "release": f"zlib-ng-{V['ZLIBNG']}", + "license": "LICENSE.md", "build": [ - cmd_nmake(r"win32\Makefile.msc", "clean"), - cmd_nmake(r"win32\Makefile.msc", "zlib.lib"), - cmd_copy("zlib.lib", "z.lib"), + cmd_copy(r"lib\zlibstatic.lib", r"lib\zlib.lib"), + cmd_copy(r"lib\zlibstatic.lib", r"lib\z.lib"), ], - "headers": [r"z*.h"], - "libs": [r"*.lib"], + "headers": [r"include\z*.h"], + "libs": [r"lib\*.lib"], }, "xz": { "url": f"https://github.com/tukaani-project/xz/releases/download/v{V['XZ']}/FILENAME", @@ -484,6 +490,9 @@ def extract_dep(url: str, filename: str, prefs: dict[str, str]) -> None: depends_dir = prefs["depends_dir"] sources_dir = prefs["src_dir"] + url = url.format(**prefs) + filename = filename.format(**prefs) + file = os.path.join(depends_dir, filename) if not os.path.exists(file): # First try our mirror @@ -566,6 +575,7 @@ def build_env(prefs: dict[str, str], verbose: bool) -> None: def build_dep(name: str, prefs: dict[str, str], verbose: bool) -> str: dep = DEPS[name] directory = dep["dir"] + release = dep["dir"] or dep["release"] file = f"build_dep_{name}.cmd" license_dir = prefs["license_dir"] sources_dir = prefs["src_dir"] @@ -584,8 +594,8 @@ def build_dep(name: str, prefs: dict[str, str], verbose: bool) -> str: assert match is not None license_text = "\n".join(match.groups()) assert len(license_text) > 50 - with open(os.path.join(license_dir, f"{directory}.txt"), "w") as f: - print(f"Writing license {directory}.txt") + with open(os.path.join(license_dir, f"{release}.txt"), "w") as f: + print(f"Writing license {release}.txt") f.write(license_text) for patch_file, patch_list in dep.get("patch", {}).items():