diff --git a/tools/legacy/build_plugin_zstd_vs2026.py b/tools/legacy/build_plugin_zstd_vs2026.py index 1707e11..20794d5 100644 --- a/tools/legacy/build_plugin_zstd_vs2026.py +++ b/tools/legacy/build_plugin_zstd_vs2026.py @@ -5,7 +5,7 @@ Supports multiple build configurations with flexible parameters. Uses PlatformToolset v145 (Visual Studio 2026 Build Tools). The 7-Zip ZS source is pulled from the git submodule at versions/7-zip-zstd/. -The NSIS plugin wrapper (nsis7z.cpp, vcxproj, …) lives in versions/zstd/. +The NSIS plugin wrapper (nsis7z.cpp, vcxproj, …) lives in versions/zstd-bundle/. NOTE: VS2026 Build Tools use v145 toolset (version 18.x) """ @@ -201,7 +201,7 @@ def find_msbuild(vs_version: str = 'auto') -> 'Optional[Tuple[Path, str, str]]': def get_project_paths(toolset: str = 'v145') -> Tuple[Path, Path, Path]: """Get project directory, project file, and plugins directory""" script_dir = Path(__file__).parent.absolute() - project_dir = script_dir.parent.parent / 'versions' / 'zstd' + project_dir = script_dir.parent.parent / 'versions' / 'zstd-bundle' vcxproj = 'Nsis7z_vs2026.vcxproj' project_file = project_dir / 'CPP' / '7zip' / 'Bundles' / 'Nsis7z' / vcxproj plugins_dir = script_dir.parent.parent / 'plugins' diff --git a/tools/linux/build_plugin_linux.py b/tools/linux/build_plugin_linux.py index fffa665..6426b38 100644 --- a/tools/linux/build_plugin_linux.py +++ b/tools/linux/build_plugin_linux.py @@ -29,7 +29,7 @@ SUPPORTED = {"25.01", "26.00", "26.01", "zstd"} # project-owned sources (NSIS UI, wrapper cpp files, vcxproj). # # For zstd the 7-zip C++ sources live in the 7-zip-zstd submodule while our -# NSIS wrapper sits in versions/zstd/. make is run with -C pointing to the +# NSIS wrapper sits in versions/zstd-bundle/. make is run with -C pointing to the # wrapper dir and VENDOR_7ZIP overridden to the submodule tree so that # include/source rules resolve correctly without touching the submodule. VERSION_LAYOUT = { @@ -48,10 +48,19 @@ VERSION_LAYOUT = { # zstd: make runs in our wrapper dir; vendor_7zip points to submodule tree. "zstd": { "vendor_7zip": ROOT / "versions" / "7-zip-zstd" / "CPP" / "7zip", - "bundle_dir": ROOT / "versions" / "zstd" / "CPP" / "7zip" / "Bundles" / "Nsis7z", + "bundle_dir": ROOT / "versions" / "zstd-bundle" / "CPP" / "7zip" / "Bundles" / "Nsis7z", }, } +# Per-version extra flags for GCC/MinGW cross-compilation that apply to both +# C and C++ compilations. Passed via LOCAL_FLAGS_EXTRA → merged into CFLAGS +# and CXXFLAGS alike. +VERSION_EXTRA_FLAGS: dict[str, str] = { + # fast-lzma2 (part of the 7-zip-zstd vendor) triggers -Wsign-compare and + # -Wcast-function-type on C code that was never compiled with GCC -Werror. + "zstd": "-Wno-sign-compare -Wno-cast-function-type", +} + # Per-version C++-only extra flags for GCC/MinGW cross-compilation. # These compensate for vendor code written exclusively for MSVC. # Passed via LOCAL_CXXFLAGS_EXTRA → appended to CXXFLAGS only (not CFLAGS). @@ -67,6 +76,10 @@ VERSION_EXTRA_CXXFLAGS: dict[str, str] = { # in the specific makefile rule for NsisExtractCallbackConsole.o. # - Several unused parameters and sign-compare on UInt64 vs. literal -1. "25.01": "-Wno-sign-compare -Wno-unused-parameter", + # 7-zip-zstd NSIS UI code has the same unused-parameter issues as 25.01. + # sign-compare is in C code (fast-lzma2) and already in VERSION_EXTRA_FLAGS; + # unused-parameter warnings are C++-only (NSIS wrapper and nsis7z.cpp). + "zstd": "-Wno-unused-parameter", } CONFIGS = { @@ -144,7 +157,7 @@ def _build_one( bundle_dir = layout["bundle_dir"] # Symlinks are not committed to git; recreate them on Linux if missing. - if zip_version in VERSION_LAYOUT and zip_version != "zstd": + if zip_version in VERSION_LAYOUT: _ensure_bundle_symlinks(zip_version, bundle_dir, vendor_7zip) cfg = CONFIGS[cfg_name] @@ -166,7 +179,8 @@ def _build_one( # Version-specific workarounds for vendor code that was MSVC-only. # Flags that are C++-only (e.g. -fpermissive) must go into LOCAL_CXXFLAGS_EXTRA # which the makefile appends only to CXXFLAGS, not to CFLAGS. - extra_cxx = VERSION_EXTRA_CXXFLAGS.get(zip_version, "") + extra_flags = VERSION_EXTRA_FLAGS.get(zip_version, "") + extra_cxx = VERSION_EXTRA_CXXFLAGS.get(zip_version, "") # CXX_INCLUDE_FLAGS: # 1. overlay/include – case-sensitivity shims (Windows.h → windows.h, …) @@ -179,6 +193,11 @@ def _build_one( # our bundle dir, not in the vendor tree. Override NSIS_DIR accordingly. bundle_nsis = bundle_dir.parent.parent / "UI" / "NSIS" + # The 7-zip-zstd vendor calls LocalFileTimeToFileTime2() which is defined + # in MyWindows.cpp. That TU is normally excluded from SYS_OBJS when + # IS_MINGW=1, so we must inject it back via EXTRA_SYS_OBJS. + extra_sys_objs = f"{out_dir}/MyWindows.o" if zip_version == "zstd" else "" + base_cmd = [ "make", "-C", str(bundle_dir), @@ -194,8 +213,9 @@ def _build_one( f"CC={triplet}-gcc", f"CXX={triplet}-g++", f"RC={triplet}-windres", - f"LOCAL_FLAGS_EXTRA={local_flags} -Wno-unknown-pragmas", + f"LOCAL_FLAGS_EXTRA={local_flags} -Wno-unknown-pragmas {extra_flags}".rstrip(), f"LOCAL_CXXFLAGS_EXTRA={extra_cxx}", + *([ f"EXTRA_SYS_OBJS={extra_sys_objs}" ] if extra_sys_objs else []), # Linux ld is case-sensitive; vendor makefile uses mixed-case lib names # (lUser32, lOle32, …) that don't exist on disk. Override LIB2 with # fully-expanded lowercase equivalents. diff --git a/tools/linux/overlay/makefile.gcc b/tools/linux/overlay/makefile.gcc index f713ebe..e4cdf78 100644 --- a/tools/linux/overlay/makefile.gcc +++ b/tools/linux/overlay/makefile.gcc @@ -73,9 +73,15 @@ CURRENT_OBJS = \ $O/pluginapi.o \ $O/nsis7z.o \ +# Optional extra system objects – pass from the command line when the vendor +# requires additional translation units that are normally excluded for mingw +# (e.g. MyWindows.o for the 7-zip-zstd variant). +EXTRA_SYS_OBJS ?= + OBJS = \ $(ARC_OBJS) \ $(SYS_OBJS) \ + $(EXTRA_SYS_OBJS) \ $(NSIS_UI_OBJS) \ $(CURRENT_OBJS) \ diff --git a/tools/linux/setup_bundle_symlinks.py b/tools/linux/setup_bundle_symlinks.py index 86869ae..667f094 100644 --- a/tools/linux/setup_bundle_symlinks.py +++ b/tools/linux/setup_bundle_symlinks.py @@ -8,6 +8,7 @@ Example: python3 setup_bundle_symlinks.py 25.01 python3 setup_bundle_symlinks.py 26.00 python3 setup_bundle_symlinks.py 26.01 + python3 setup_bundle_symlinks.py zstd """ import os import sys @@ -19,9 +20,14 @@ if len(sys.argv) != 2: version = sys.argv[1] +# For versions where the vendor directory name differs from the bundle version key. +VENDOR_DIR = { + "zstd": "7-zip-zstd", +} + ROOT = Path(__file__).resolve().parents[2] bundle_root = ROOT / f"versions/{version}-bundle" -vendor_root = ROOT / f"versions/{version}" +vendor_root = ROOT / "versions" / VENDOR_DIR.get(version, version) if not vendor_root.exists(): print(f"Error: vendor directory not found: {vendor_root}", file=sys.stderr) diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/Nsis7z_vs2026.vcxproj b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/Nsis7z_vs2026.vcxproj similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/Nsis7z_vs2026.vcxproj rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/Nsis7z_vs2026.vcxproj diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/StdAfx.h b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/StdAfx.h similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/StdAfx.h rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/StdAfx.h diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/StdAfx2.cpp b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/StdAfx2.cpp similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/StdAfx2.cpp rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/StdAfx2.cpp diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/afxres.h b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/afxres.h similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/afxres.h rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/afxres.h diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/api.h b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/api.h similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/api.h rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/api.h diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/nsis7z.cpp b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/nsis7z.cpp similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/nsis7z.cpp rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/nsis7z.cpp diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/nsis_tchar.h b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/nsis_tchar.h similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/nsis_tchar.h rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/nsis_tchar.h diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/pluginapi.cpp b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/pluginapi.cpp similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/pluginapi.cpp rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/pluginapi.cpp diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/pluginapi.h b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/pluginapi.h similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/pluginapi.h rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/pluginapi.h diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/resource.h b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/resource.h similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/resource.h rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/resource.h diff --git a/versions/zstd/CPP/7zip/Bundles/Nsis7z/resource.rc b/versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/resource.rc similarity index 100% rename from versions/zstd/CPP/7zip/Bundles/Nsis7z/resource.rc rename to versions/zstd-bundle/CPP/7zip/Bundles/Nsis7z/resource.rc diff --git a/versions/zstd/CPP/7zip/UI/NSIS/ExtractCallbackConsole.cpp b/versions/zstd-bundle/CPP/7zip/UI/NSIS/ExtractCallbackConsole.cpp similarity index 100% rename from versions/zstd/CPP/7zip/UI/NSIS/ExtractCallbackConsole.cpp rename to versions/zstd-bundle/CPP/7zip/UI/NSIS/ExtractCallbackConsole.cpp diff --git a/versions/zstd/CPP/7zip/UI/NSIS/ExtractCallbackConsole.h b/versions/zstd-bundle/CPP/7zip/UI/NSIS/ExtractCallbackConsole.h similarity index 100% rename from versions/zstd/CPP/7zip/UI/NSIS/ExtractCallbackConsole.h rename to versions/zstd-bundle/CPP/7zip/UI/NSIS/ExtractCallbackConsole.h diff --git a/versions/zstd/CPP/7zip/UI/NSIS/Main.cpp b/versions/zstd-bundle/CPP/7zip/UI/NSIS/Main.cpp similarity index 100% rename from versions/zstd/CPP/7zip/UI/NSIS/Main.cpp rename to versions/zstd-bundle/CPP/7zip/UI/NSIS/Main.cpp diff --git a/versions/zstd/CPP/7zip/UI/NSIS/MainAr.cpp b/versions/zstd-bundle/CPP/7zip/UI/NSIS/MainAr.cpp similarity index 100% rename from versions/zstd/CPP/7zip/UI/NSIS/MainAr.cpp rename to versions/zstd-bundle/CPP/7zip/UI/NSIS/MainAr.cpp diff --git a/versions/zstd/CPP/7zip/UI/NSIS/NSISBreak.cpp b/versions/zstd-bundle/CPP/7zip/UI/NSIS/NSISBreak.cpp similarity index 100% rename from versions/zstd/CPP/7zip/UI/NSIS/NSISBreak.cpp rename to versions/zstd-bundle/CPP/7zip/UI/NSIS/NSISBreak.cpp diff --git a/versions/zstd/CPP/7zip/UI/NSIS/NSISBreak.h b/versions/zstd-bundle/CPP/7zip/UI/NSIS/NSISBreak.h similarity index 100% rename from versions/zstd/CPP/7zip/UI/NSIS/NSISBreak.h rename to versions/zstd-bundle/CPP/7zip/UI/NSIS/NSISBreak.h diff --git a/versions/zstd-bundle/CPP/7zip/UI/NSIS/StdAfx.h b/versions/zstd-bundle/CPP/7zip/UI/NSIS/StdAfx.h new file mode 100644 index 0000000..9f06ac9 --- /dev/null +++ b/versions/zstd-bundle/CPP/7zip/UI/NSIS/StdAfx.h @@ -0,0 +1,15 @@ +// StdAfx.h + +#ifndef __STDAFX_H +#define __STDAFX_H + +#ifdef _WIN32 + #if defined(__MINGW32__) || defined(__MINGW64__) + #include + #else + #include + #endif +#endif +#include "../../Bundles/Nsis7z/pluginapi.h" + +#endif diff --git a/versions/zstd/CPP/7zip/UI/NSIS/UserInputUtils2.cpp b/versions/zstd-bundle/CPP/7zip/UI/NSIS/UserInputUtils2.cpp similarity index 100% rename from versions/zstd/CPP/7zip/UI/NSIS/UserInputUtils2.cpp rename to versions/zstd-bundle/CPP/7zip/UI/NSIS/UserInputUtils2.cpp diff --git a/versions/zstd/CPP/7zip/UI/NSIS/UserInputUtils2.h b/versions/zstd-bundle/CPP/7zip/UI/NSIS/UserInputUtils2.h similarity index 100% rename from versions/zstd/CPP/7zip/UI/NSIS/UserInputUtils2.h rename to versions/zstd-bundle/CPP/7zip/UI/NSIS/UserInputUtils2.h diff --git a/versions/zstd/CPP/7zip/UI/NSIS/StdAfx.h b/versions/zstd/CPP/7zip/UI/NSIS/StdAfx.h deleted file mode 100644 index c8c5279..0000000 --- a/versions/zstd/CPP/7zip/UI/NSIS/StdAfx.h +++ /dev/null @@ -1,9 +0,0 @@ -// StdAfx.h - -#ifndef __STDAFX_H -#define __STDAFX_H - -#include -#include "7zip/Bundles/Nsis7z/pluginapi.h" - -#endif