Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Windows zlib with zlib-ng #8495

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions winbuild/build_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand All @@ -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():
Expand Down
Loading