feat: add Linux MinGW build path and Windows build-script fixes (v2.2.0)
This commit is contained in:
@@ -61,10 +61,17 @@ python build_plugin.py --7zip-version 25.01
|
|||||||
# Specific toolset (2022|2026|auto)
|
# Specific toolset (2022|2026|auto)
|
||||||
python build_plugin.py --toolset 2022
|
python build_plugin.py --toolset 2022
|
||||||
|
|
||||||
|
# Linux host path (cross-build with MinGW-w64, 26.00)
|
||||||
|
python build_plugin.py --host linux
|
||||||
|
|
||||||
# Print version and exit
|
# Print version and exit
|
||||||
python build_plugin.py --version
|
python build_plugin.py --version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Linux notes:
|
||||||
|
- Local Linux path currently supports `--7zip-version 26.00`.
|
||||||
|
- Requires MinGW-w64 toolchains (`x86_64-w64-mingw32-*` and `i686-w64-mingw32-*`) and `make`.
|
||||||
|
|
||||||
## Repository Structure
|
## Repository Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
+16
-3
@@ -5,7 +5,7 @@ Wraps per-version/per-toolset build scripts.
|
|||||||
Defaults: 7-Zip 26.00, VS2026 (v145 toolset)
|
Defaults: 7-Zip 26.00, VS2026 (v145 toolset)
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import argparse, subprocess, sys
|
import argparse, platform, subprocess, sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ class Colors:
|
|||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parent
|
ROOT = Path(__file__).resolve().parent
|
||||||
SCRIPTS = {
|
WINDOWS_SCRIPTS = {
|
||||||
"19.00": {"2022": "tools/legacy/build_plugin_vs2022.py",
|
"19.00": {"2022": "tools/legacy/build_plugin_vs2022.py",
|
||||||
"2026": "tools/legacy/build_plugin_vs2026.py"},
|
"2026": "tools/legacy/build_plugin_vs2026.py"},
|
||||||
"25.01": {"2022": "tools/legacy/build_plugin_2501_vs2022.py",
|
"25.01": {"2022": "tools/legacy/build_plugin_2501_vs2022.py",
|
||||||
@@ -27,6 +27,8 @@ SCRIPTS = {
|
|||||||
"2026": "tools/legacy/build_plugin_zstd_vs2026.py"},
|
"2026": "tools/legacy/build_plugin_zstd_vs2026.py"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LINUX_SCRIPT = "tools/linux/build_plugin_linux.py"
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
parser = argparse.ArgumentParser(description="Build nsis7z NSIS plugin")
|
parser = argparse.ArgumentParser(description="Build nsis7z NSIS plugin")
|
||||||
@@ -36,6 +38,8 @@ def main() -> int:
|
|||||||
"'zstd' uses mcmilk/7-Zip-zstd submodule")
|
"'zstd' uses mcmilk/7-Zip-zstd submodule")
|
||||||
parser.add_argument("--toolset", choices=["2022", "2026", "auto"], default="auto",
|
parser.add_argument("--toolset", choices=["2022", "2026", "auto"], default="auto",
|
||||||
help="Visual Studio toolset version (default: auto)")
|
help="Visual Studio toolset version (default: auto)")
|
||||||
|
parser.add_argument("--host", choices=["auto", "windows", "linux"], default="auto",
|
||||||
|
help="Build host path (default: auto detect)")
|
||||||
parser.add_argument("--version", action="store_true",
|
parser.add_argument("--version", action="store_true",
|
||||||
help="Print plugin version and exit")
|
help="Print plugin version and exit")
|
||||||
known, rest = parser.parse_known_args()
|
known, rest = parser.parse_known_args()
|
||||||
@@ -49,11 +53,20 @@ def main() -> int:
|
|||||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}=== Building ns7zip v{ver} "
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}=== Building ns7zip v{ver} "
|
||||||
f"({zip_label}) ==={Colors.RESET}")
|
f"({zip_label}) ==={Colors.RESET}")
|
||||||
|
|
||||||
|
host = known.host
|
||||||
|
if host == "auto":
|
||||||
|
host = "windows" if platform.system().lower().startswith("win") else "linux"
|
||||||
|
|
||||||
|
if host == "linux":
|
||||||
|
script = ROOT / LINUX_SCRIPT
|
||||||
|
cmd = [sys.executable, str(script), "--7zip-version", known.zip_version] + rest
|
||||||
|
return subprocess.run(cmd).returncode
|
||||||
|
|
||||||
toolset = known.toolset
|
toolset = known.toolset
|
||||||
if toolset == "auto":
|
if toolset == "auto":
|
||||||
toolset = "2026"
|
toolset = "2026"
|
||||||
|
|
||||||
script_rel = SCRIPTS[known.zip_version][toolset]
|
script_rel = WINDOWS_SCRIPTS[known.zip_version][toolset]
|
||||||
if script_rel is None:
|
if script_rel is None:
|
||||||
print(f"ERROR: no {known.zip_version} script for toolset {toolset}", file=sys.stderr)
|
print(f"ERROR: no {known.zip_version} script for toolset {toolset}", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""Add missing source files to Nsis7z_vs2026.vcxproj"""
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parent.parent
|
|
||||||
vcxproj = ROOT / 'versions/zstd/CPP/7zip/Bundles/Nsis7z/Nsis7z_vs2026.vcxproj'
|
|
||||||
|
|
||||||
# Relative paths from vcxproj dir (versions/zstd/CPP/7zip/Bundles/Nsis7z/)
|
|
||||||
# 5 levels up = versions/
|
|
||||||
MISSING = [
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\CPP\Common\MyWindows.cpp',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\hashes\xxhash.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\dict_buffer.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\fl2_common.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\fl2_compress.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\fl2_pool.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\fl2_threading.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\lzma2_enc.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\radix_bitpack.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\radix_mf.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\radix_struct.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\range_enc.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\util.c',
|
|
||||||
]
|
|
||||||
|
|
||||||
content = vcxproj.read_text(encoding='utf-8')
|
|
||||||
|
|
||||||
ANCHOR = ' <ClCompile Include="..\\..\\UI\\NSIS\\ExtractCallbackConsole.cpp" />'
|
|
||||||
if ANCHOR not in content:
|
|
||||||
print('ERROR: anchor not found in vcxproj')
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
lines = [f' <ClCompile Include="{p}" />' for p in MISSING]
|
|
||||||
block = '\n'.join(lines) + '\n '
|
|
||||||
content = content.replace(ANCHOR, block + ANCHOR.lstrip())
|
|
||||||
vcxproj.write_text(content, encoding='utf-8')
|
|
||||||
print(f'Added {len(MISSING)} source files to vcxproj')
|
|
||||||
@@ -811,9 +811,9 @@ Examples:
|
|||||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||||
|
|
||||||
# Print header
|
# Print header
|
||||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*60}{Colors.RESET}")
|
||||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Building nsis7z plugin (7-Zip 26.00, VS2026){Colors.RESET} - {Colors.BRIGHT_WHITE}{len(configs_to_build)}{Colors.RESET} configuration(s)")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Building nsis7z plugin (7-Zip 26.00, VS2026){Colors.RESET} - {Colors.BRIGHT_WHITE}{len(configs_to_build)}{Colors.RESET} configuration(s)")
|
||||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*60}{Colors.RESET}")
|
||||||
print(f"{Colors.CYAN}Visual Studio:{Colors.RESET} {Colors.BRIGHT_WHITE}{vs_version_name} (toolset {platform_toolset}){Colors.RESET}")
|
print(f"{Colors.CYAN}Visual Studio:{Colors.RESET} {Colors.BRIGHT_WHITE}{vs_version_name} (toolset {platform_toolset}){Colors.RESET}")
|
||||||
print(f"{Colors.CYAN}MSBuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{msbuild_path}{Colors.RESET}")
|
print(f"{Colors.CYAN}MSBuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{msbuild_path}{Colors.RESET}")
|
||||||
print(f"{Colors.CYAN}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
print(f"{Colors.CYAN}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||||
@@ -921,9 +921,9 @@ Examples:
|
|||||||
all_success = all(success for _, success, _, _, _ in build_results)
|
all_success = all(success for _, success, _, _, _ in build_results)
|
||||||
|
|
||||||
if all_success:
|
if all_success:
|
||||||
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}{"="*50}{Colors.RESET}")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}{'='*50}{Colors.RESET}")
|
||||||
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}ALL BUILDS SUCCESSFUL!{Colors.RESET}")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}ALL BUILDS SUCCESSFUL!{Colors.RESET}")
|
||||||
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}{"="*50}{Colors.RESET}")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}{'='*50}{Colors.RESET}")
|
||||||
print("\nPlugins copied to:")
|
print("\nPlugins copied to:")
|
||||||
for config, _, build_time, file_size, dest_path in build_results:
|
for config, _, build_time, file_size, dest_path in build_results:
|
||||||
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
||||||
@@ -934,9 +934,9 @@ Examples:
|
|||||||
print()
|
print()
|
||||||
clean_build_artifacts(project_dir, configs_to_build)
|
clean_build_artifacts(project_dir, configs_to_build)
|
||||||
else:
|
else:
|
||||||
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
print(f"{Colors.BOLD}{Colors.RED}{'='*50}{Colors.RESET}")
|
||||||
print(f"{Colors.BOLD}{Colors.RED}SOME BUILDS FAILED!{Colors.RESET}")
|
print(f"{Colors.BOLD}{Colors.RED}SOME BUILDS FAILED!{Colors.RESET}")
|
||||||
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
print(f"{Colors.BOLD}{Colors.RED}{'='*50}{Colors.RESET}")
|
||||||
print("\nFailed configurations:")
|
print("\nFailed configurations:")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
if not success:
|
if not success:
|
||||||
|
|||||||
@@ -0,0 +1,222 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Linux build path for nsis7z plugin.
|
||||||
|
|
||||||
|
Builds Windows DLL artifacts from Linux using MinGW-w64 cross compilers.
|
||||||
|
Current support: 7-Zip 26.00.
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
|
||||||
|
SUPPORTED = {"26.00"}
|
||||||
|
|
||||||
|
CONFIGS = {
|
||||||
|
"x86-ansi": {
|
||||||
|
"triplet": "i686-w64-mingw32",
|
||||||
|
"is_x64": "0",
|
||||||
|
"unicode": False,
|
||||||
|
"dest": "plugins/x86-ansi/nsis7z.dll",
|
||||||
|
},
|
||||||
|
"x86-unicode": {
|
||||||
|
"triplet": "i686-w64-mingw32",
|
||||||
|
"is_x64": "0",
|
||||||
|
"unicode": True,
|
||||||
|
"dest": "plugins/x86-unicode/nsis7z.dll",
|
||||||
|
},
|
||||||
|
"x64-unicode": {
|
||||||
|
"triplet": "x86_64-w64-mingw32",
|
||||||
|
"is_x64": "1",
|
||||||
|
"unicode": True,
|
||||||
|
"dest": "plugins/amd64-unicode/nsis7z.dll",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _require_tool(name: str) -> None:
|
||||||
|
if shutil.which(name) is None:
|
||||||
|
print(f"ERROR: required tool not found: {name}", file=sys.stderr)
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_jobs(value: str) -> int:
|
||||||
|
if value == "auto":
|
||||||
|
return max(1, os.cpu_count() or 1)
|
||||||
|
|
||||||
|
jobs = int(value)
|
||||||
|
if jobs < 1:
|
||||||
|
raise ValueError("jobs must be >= 1")
|
||||||
|
return jobs
|
||||||
|
|
||||||
|
|
||||||
|
def _build_one(
|
||||||
|
zip_version: str,
|
||||||
|
cfg_name: str,
|
||||||
|
verbose: bool,
|
||||||
|
jobs: int,
|
||||||
|
clean: bool,
|
||||||
|
cleanup_artifacts: bool,
|
||||||
|
) -> int:
|
||||||
|
cfg = CONFIGS[cfg_name]
|
||||||
|
triplet = cfg["triplet"]
|
||||||
|
|
||||||
|
bundle_dir = ROOT / "versions" / zip_version / "CPP" / "7zip" / "Bundles" / "Nsis7z"
|
||||||
|
cpp_root = ROOT / "versions" / zip_version / "CPP"
|
||||||
|
makefile = bundle_dir / "makefile.gcc"
|
||||||
|
if not makefile.exists():
|
||||||
|
print(f"ERROR: Linux makefile not found: {makefile}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
out_obj = f"_o_{cfg_name.replace('-', '_')}"
|
||||||
|
local_flags = "-DNDEBUG"
|
||||||
|
if cfg["unicode"]:
|
||||||
|
local_flags += " -DUNICODE -D_UNICODE"
|
||||||
|
else:
|
||||||
|
# Precomp.h forces UNICODE=1 unconditionally; suppress it for the ansi
|
||||||
|
# build so that LPTSTR resolves to char* consistently in all TUs.
|
||||||
|
local_flags += " -DZ7_NO_UNICODE"
|
||||||
|
|
||||||
|
base_cmd = [
|
||||||
|
"make",
|
||||||
|
"-f",
|
||||||
|
"makefile.gcc",
|
||||||
|
f"O={out_obj}",
|
||||||
|
"SystemDrive=1",
|
||||||
|
"IS_MINGW=1",
|
||||||
|
"MSYSTEM=LINUX",
|
||||||
|
f"IS_X64={cfg['is_x64']}",
|
||||||
|
f"CC={triplet}-gcc",
|
||||||
|
f"CXX={triplet}-g++",
|
||||||
|
f"RC={triplet}-windres",
|
||||||
|
f"LOCAL_FLAGS_EXTRA={local_flags} -Wno-unknown-pragmas",
|
||||||
|
f"CXX_INCLUDE_FLAGS=-I{cpp_root}",
|
||||||
|
]
|
||||||
|
|
||||||
|
build_mode = "clean build" if clean else "incremental build"
|
||||||
|
print(f"[linux] Building {cfg_name} ({zip_version}, {build_mode}, -j{jobs})")
|
||||||
|
|
||||||
|
# Don't run 'clean' and 'all' in the same parallel make invocation:
|
||||||
|
# with -j, GNU make may execute them concurrently and remove objects while
|
||||||
|
# the linker is already consuming them.
|
||||||
|
if clean:
|
||||||
|
proc = subprocess.run(base_cmd + ["clean"], cwd=bundle_dir)
|
||||||
|
if proc.returncode != 0:
|
||||||
|
return proc.returncode
|
||||||
|
|
||||||
|
proc = subprocess.run(base_cmd + [f"-j{jobs}", "all"], cwd=bundle_dir)
|
||||||
|
if proc.returncode != 0:
|
||||||
|
return proc.returncode
|
||||||
|
|
||||||
|
built = bundle_dir / out_obj / "nsis7z.dll"
|
||||||
|
if not built.exists():
|
||||||
|
print(f"ERROR: expected artifact not found: {built}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
dest = ROOT / cfg["dest"]
|
||||||
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
shutil.copy2(built, dest)
|
||||||
|
|
||||||
|
if cleanup_artifacts:
|
||||||
|
shutil.rmtree(bundle_dir / out_obj, ignore_errors=True)
|
||||||
|
|
||||||
|
if verbose:
|
||||||
|
print(f"[linux] Copied -> {dest}")
|
||||||
|
if cleanup_artifacts:
|
||||||
|
print(f"[linux] Cleaned build artifacts -> {bundle_dir / out_obj}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
parser = argparse.ArgumentParser(description="Linux build path for nsis7z")
|
||||||
|
parser.add_argument(
|
||||||
|
"--7zip-version",
|
||||||
|
dest="zip_version",
|
||||||
|
choices=["19.00", "25.01", "26.00", "zstd"],
|
||||||
|
default="26.00",
|
||||||
|
help="7-Zip version to build",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--configs",
|
||||||
|
nargs="+",
|
||||||
|
choices=list(CONFIGS.keys()) + ["all"],
|
||||||
|
default=["all"],
|
||||||
|
help="Build configuration(s): x86-ansi, x86-unicode, x64-unicode, or all",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--jobs",
|
||||||
|
default="auto",
|
||||||
|
help="Parallel make jobs. Use an integer or 'auto' (default: auto)",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--clean",
|
||||||
|
action="store_true",
|
||||||
|
default=True,
|
||||||
|
help="Run 'make clean' before building (default: True)",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--no-clean",
|
||||||
|
action="store_false",
|
||||||
|
dest="clean",
|
||||||
|
help="Skip 'make clean' to enable incremental rebuilds",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--cleanup-artifacts",
|
||||||
|
action="store_true",
|
||||||
|
default=True,
|
||||||
|
help="Remove per-config build artifact directories after successful copy (default: True)",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--no-cleanup-artifacts",
|
||||||
|
action="store_false",
|
||||||
|
dest="cleanup_artifacts",
|
||||||
|
help="Keep per-config build artifact directories (_o_*)",
|
||||||
|
)
|
||||||
|
parser.add_argument("--verbose", action="store_true", help="Verbose output")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.zip_version not in SUPPORTED:
|
||||||
|
print(
|
||||||
|
"ERROR: Linux local build is currently supported only for 26.00. "
|
||||||
|
f"Requested: {args.zip_version}",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
return 2
|
||||||
|
|
||||||
|
_require_tool("make")
|
||||||
|
for cfg in CONFIGS.values():
|
||||||
|
_require_tool(f"{cfg['triplet']}-gcc")
|
||||||
|
_require_tool(f"{cfg['triplet']}-g++")
|
||||||
|
_require_tool(f"{cfg['triplet']}-windres")
|
||||||
|
|
||||||
|
try:
|
||||||
|
jobs = _resolve_jobs(args.jobs)
|
||||||
|
except ValueError as exc:
|
||||||
|
print(f"ERROR: invalid --jobs value: {exc}", file=sys.stderr)
|
||||||
|
return 2
|
||||||
|
|
||||||
|
wanted = list(CONFIGS.keys()) if "all" in args.configs else args.configs
|
||||||
|
|
||||||
|
for cfg_name in wanted:
|
||||||
|
code = _build_one(
|
||||||
|
args.zip_version,
|
||||||
|
cfg_name,
|
||||||
|
args.verbose,
|
||||||
|
jobs,
|
||||||
|
args.clean,
|
||||||
|
args.cleanup_artifacts,
|
||||||
|
)
|
||||||
|
if code != 0:
|
||||||
|
return code
|
||||||
|
|
||||||
|
print("[linux] Build completed")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
LIBRARY nsis7z
|
||||||
|
EXPORTS
|
||||||
|
Extract
|
||||||
|
ExtractWithDetails
|
||||||
|
ExtractWithCallback
|
||||||
|
ExtractWithFileCallback
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
PROG = nsis7z
|
||||||
|
DEF_FILE = Nsis7z.def
|
||||||
|
|
||||||
|
include ../Format7zF/Arc_gcc.mak
|
||||||
|
|
||||||
|
ifdef IS_MINGW
|
||||||
|
LOCAL_FLAGS_SYS = -DZ7_DEVICE_FILE
|
||||||
|
SYS_OBJS = \
|
||||||
|
$O/DLL.o \
|
||||||
|
$O/DllSecur.o \
|
||||||
|
$O/resource.o \
|
||||||
|
|
||||||
|
else
|
||||||
|
SYS_OBJS = \
|
||||||
|
$O/MyWindows.o \
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_FLAGS += \
|
||||||
|
$(LOCAL_FLAGS_SYS) \
|
||||||
|
$(LOCAL_FLAGS_EXTRA) \
|
||||||
|
|
||||||
|
NSIS_UI_OBJS = \
|
||||||
|
$O/NsisMain.o \
|
||||||
|
$O/NsisMainAr.o \
|
||||||
|
$O/NsisBreak.o \
|
||||||
|
$O/NsisExtractCallbackConsole.o \
|
||||||
|
$O/NsisUserInputUtils2.o \
|
||||||
|
$O/ConsoleOpenCallbackConsole.o \
|
||||||
|
$O/ConsolePercentPrinter.o \
|
||||||
|
$O/ConsoleClose.o \
|
||||||
|
$O/ConsoleUserInputUtils.o \
|
||||||
|
$O/Extract.o \
|
||||||
|
$O/HashCalc.o \
|
||||||
|
$O/OpenArchive.o \
|
||||||
|
$O/ArchiveExtractCallback.o \
|
||||||
|
$O/ArchiveOpenCallback.o \
|
||||||
|
$O/DefaultName.o \
|
||||||
|
$O/EnumDirItems.o \
|
||||||
|
$O/ExtractingFilePath.o \
|
||||||
|
$O/LoadCodecs.o \
|
||||||
|
$O/SetProperties.o \
|
||||||
|
$O/FileStreams.o \
|
||||||
|
$O/FileSystem.o \
|
||||||
|
$O/ErrorMsg.o \
|
||||||
|
$O/FileLink.o \
|
||||||
|
$O/FilePathAutoRename.o \
|
||||||
|
$O/SortUtils.o \
|
||||||
|
$O/PropIDUtils.o \
|
||||||
|
|
||||||
|
CURRENT_OBJS = \
|
||||||
|
$O/StdInStream.o \
|
||||||
|
$O/StdOutStream.o \
|
||||||
|
$O/StdAfx2.o \
|
||||||
|
$O/pluginapi.o \
|
||||||
|
$O/nsis7z.o \
|
||||||
|
|
||||||
|
OBJS = \
|
||||||
|
$(ARC_OBJS) \
|
||||||
|
$(SYS_OBJS) \
|
||||||
|
$(NSIS_UI_OBJS) \
|
||||||
|
$(CURRENT_OBJS) \
|
||||||
|
|
||||||
|
include ../../7zip_gcc.mak
|
||||||
|
|
||||||
|
$O/NsisMain.o: ../../UI/NSIS/Main.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/NsisMainAr.o: ../../UI/NSIS/MainAr.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/NsisBreak.o: ../../UI/NSIS/NSISBreak.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/NsisExtractCallbackConsole.o: ../../UI/NSIS/ExtractCallbackConsole.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/NsisUserInputUtils2.o: ../../UI/NSIS/UserInputUtils2.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/ConsoleOpenCallbackConsole.o: ../../UI/Console/OpenCallbackConsole.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/ConsolePercentPrinter.o: ../../UI/Console/PercentPrinter.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/ConsoleUserInputUtils.o: ../../UI/Console/UserInputUtils.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/StdAfx2.o: StdAfx2.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/pluginapi.o: pluginapi.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/nsis7z.o: nsis7z.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
@@ -181,6 +181,7 @@ EXTRACTFUNCEND
|
|||||||
|
|
||||||
extern "C" BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
extern "C" BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
|
(void)lpReserved;
|
||||||
g_hInstance2=(HINSTANCE)hInst;
|
g_hInstance2=(HINSTANCE)hInst;
|
||||||
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,12 +27,14 @@ using namespace NDir;
|
|||||||
|
|
||||||
extern HWND g_hwndProgress;
|
extern HWND g_hwndProgress;
|
||||||
|
|
||||||
|
static const UInt64 k_SizeUnknown = (UInt64)(Int64)-1;
|
||||||
|
|
||||||
void CExtractCallbackConsole::UpdateProgress()
|
void CExtractCallbackConsole::UpdateProgress()
|
||||||
{
|
{
|
||||||
// Prima controlla se c'è il callback con filename (nuova funzione)
|
// Prima controlla se c'è il callback con filename (nuova funzione)
|
||||||
if (ProgressWithFileHandler != NULL)
|
if (ProgressWithFileHandler != NULL)
|
||||||
{
|
{
|
||||||
if (completedSize != -1 || totalSize > 0)
|
if (completedSize != k_SizeUnknown || totalSize > 0)
|
||||||
ProgressWithFileHandler(completedSize, totalSize, CurrentFileName.Ptr());
|
ProgressWithFileHandler(completedSize, totalSize, CurrentFileName.Ptr());
|
||||||
else
|
else
|
||||||
ProgressWithFileHandler(0, 0, CurrentFileName.Ptr());
|
ProgressWithFileHandler(0, 0, CurrentFileName.Ptr());
|
||||||
@@ -40,14 +42,14 @@ void CExtractCallbackConsole::UpdateProgress()
|
|||||||
// Altrimenti usa il callback originale (per compatibilità)
|
// Altrimenti usa il callback originale (per compatibilità)
|
||||||
else if (ProgressHandler != NULL)
|
else if (ProgressHandler != NULL)
|
||||||
{
|
{
|
||||||
if (completedSize != -1 || totalSize > 0)
|
if (completedSize != k_SizeUnknown || totalSize > 0)
|
||||||
ProgressHandler(completedSize, totalSize);
|
ProgressHandler(completedSize, totalSize);
|
||||||
else
|
else
|
||||||
ProgressHandler(0, 0);
|
ProgressHandler(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64 val)
|
Z7_COM7F_IMF(CExtractCallbackConsole::SetTotal(UInt64 val))
|
||||||
{
|
{
|
||||||
totalSize = val;
|
totalSize = val;
|
||||||
UpdateProgress();
|
UpdateProgress();
|
||||||
@@ -56,7 +58,7 @@ STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64 val)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *val)
|
Z7_COM7F_IMF(CExtractCallbackConsole::SetCompleted(const UInt64 *val))
|
||||||
{
|
{
|
||||||
completedSize = *val;
|
completedSize = *val;
|
||||||
UpdateProgress();
|
UpdateProgress();
|
||||||
@@ -65,31 +67,35 @@ STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *val)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
|
Z7_COM7F_IMF(CExtractCallbackConsole::AskOverwrite(
|
||||||
const wchar_t *existName, const FILETIME *, const UInt64 *,
|
const wchar_t *existName, const FILETIME *, const UInt64 *,
|
||||||
const wchar_t *newName, const FILETIME *, const UInt64 *,
|
const wchar_t *newName, const FILETIME *, const UInt64 *,
|
||||||
Int32 *answer)
|
Int32 *answer))
|
||||||
{
|
{
|
||||||
*answer = NOverwriteAnswer::kYesToAll;
|
(void)existName; (void)newName;
|
||||||
|
*answer = NOverwriteAnswer::kYesToAll;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 *position)
|
Z7_COM7F_IMF(CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 *position))
|
||||||
{
|
{
|
||||||
|
(void)isFolder; (void)askExtractMode; (void)position;
|
||||||
// Memorizza il nome del file corrente per passarlo al callback
|
// Memorizza il nome del file corrente per passarlo al callback
|
||||||
CurrentFileName = name;
|
CurrentFileName = name;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
|
Z7_COM7F_IMF(CExtractCallbackConsole::MessageError(const wchar_t *message))
|
||||||
{
|
{
|
||||||
|
(void)message;
|
||||||
NumFileErrorsInCurrentArchive++;
|
NumFileErrorsInCurrentArchive++;
|
||||||
NumFileErrors++;
|
NumFileErrors++;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encrypted)
|
Z7_COM7F_IMF(CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encrypted))
|
||||||
{
|
{
|
||||||
|
(void)encrypted;
|
||||||
switch(opRes)
|
switch(opRes)
|
||||||
{
|
{
|
||||||
case NArchive::NExtract::NOperationResult::kOK:
|
case NArchive::NExtract::NOperationResult::kOK:
|
||||||
@@ -113,7 +119,7 @@ HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
|
Z7_COM7F_IMF(CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password))
|
||||||
{
|
{
|
||||||
if (!PasswordIsDefined)
|
if (!PasswordIsDefined)
|
||||||
{
|
{
|
||||||
@@ -127,6 +133,7 @@ STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
|
|||||||
|
|
||||||
HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
|
HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
|
||||||
{
|
{
|
||||||
|
(void)name; (void)testMode;
|
||||||
NumArchives++;
|
NumArchives++;
|
||||||
NumFileErrorsInCurrentArchive = 0;
|
NumFileErrorsInCurrentArchive = 0;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@@ -134,6 +141,7 @@ HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
|
|||||||
|
|
||||||
HRESULT CExtractCallbackConsole::OpenResult(const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result)
|
HRESULT CExtractCallbackConsole::OpenResult(const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result)
|
||||||
{
|
{
|
||||||
|
(void)codecs; (void)arcLink; (void)name;
|
||||||
if (result != S_OK)
|
if (result != S_OK)
|
||||||
{
|
{
|
||||||
NumArchiveErrors++;
|
NumArchiveErrors++;
|
||||||
|
|||||||
@@ -3,7 +3,13 @@
|
|||||||
#ifndef __STDAFX_H
|
#ifndef __STDAFX_H
|
||||||
#define __STDAFX_H
|
#define __STDAFX_H
|
||||||
|
|
||||||
#include <Windows.h>
|
#ifdef _WIN32
|
||||||
#include "7zip/Bundles/Nsis7z/pluginapi.h"
|
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#include "../../Bundles/Nsis7z/pluginapi.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user