Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cda44e07a8 | |||
| 0faf0fb360 | |||
| 9be53c7e22 | |||
| d80b025219 | |||
| 91fe17cda2 |
@@ -12,6 +12,9 @@
|
||||
|
||||
name: Build
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
@@ -70,3 +73,58 @@ jobs:
|
||||
path: dist/**
|
||||
if-no-files-found: error
|
||||
retention-days: 30
|
||||
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config: [x86-ansi, x86-unicode, x64-unicode]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install MinGW toolchain
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
make \
|
||||
binutils-mingw-w64-i686 \
|
||||
binutils-mingw-w64-x86-64 \
|
||||
g++-mingw-w64-i686 \
|
||||
g++-mingw-w64-x86-64
|
||||
|
||||
- name: Read VERSION
|
||||
id: version_linux
|
||||
run: |
|
||||
v="$(tr -d '\r\n' < VERSION)"
|
||||
echo "version=$v" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build ${{ matrix.config }} on Linux
|
||||
run: python build_plugin.py --host linux --configs ${{ matrix.config }} --verbose
|
||||
|
||||
- name: Collect DLL
|
||||
run: |
|
||||
case "${{ matrix.config }}" in
|
||||
x86-ansi) dir="x86-ansi" ;;
|
||||
x86-unicode) dir="x86-unicode" ;;
|
||||
x64-unicode) dir="amd64-unicode" ;;
|
||||
esac
|
||||
dst="dist/${{ matrix.config }}"
|
||||
mkdir -p "$dst"
|
||||
cp "plugins/$dir/nsis7z.dll" "$dst/"
|
||||
|
||||
- name: Upload DLL
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ github.event.repository.name }}-${{ steps.version_linux.outputs.version }}-${{ matrix.config }}-linux
|
||||
path: dist/**
|
||||
if-no-files-found: error
|
||||
retention-days: 30
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
name: Release
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
@@ -68,8 +71,53 @@ jobs:
|
||||
name: pkg-${{ matrix.config }}
|
||||
path: '*.zip'
|
||||
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
config: [x86-ansi, x86-unicode, x64-unicode]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install MinGW toolchain
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
make \
|
||||
binutils-mingw-w64-i686 \
|
||||
binutils-mingw-w64-x86-64 \
|
||||
g++-mingw-w64-i686 \
|
||||
g++-mingw-w64-x86-64
|
||||
|
||||
- name: Build ${{ matrix.config }} on Linux
|
||||
run: python build_plugin.py --host linux --configs ${{ matrix.config }}
|
||||
|
||||
- name: Collect DLL
|
||||
run: |
|
||||
case "${{ matrix.config }}" in
|
||||
x86-ansi) dir="x86-ansi" ;;
|
||||
x86-unicode) dir="x86-unicode" ;;
|
||||
x64-unicode) dir="amd64-unicode" ;;
|
||||
esac
|
||||
dst="dist/${{ matrix.config }}"
|
||||
mkdir -p "$dst"
|
||||
cp "plugins/$dir/nsis7z.dll" "$dst/"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-build-${{ matrix.config }}
|
||||
path: dist/**
|
||||
if-no-files-found: error
|
||||
|
||||
publish:
|
||||
needs: build
|
||||
needs: [build, build-linux]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
+10
-1
@@ -7,6 +7,14 @@ e il progetto aderisce al [Semantic Versioning](https://semver.org/spec/v2.0.0.h
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.2.1] — 2026-05-02
|
||||
|
||||
### Added
|
||||
- Linux CI jobs for the GitHub `build` and `release` workflows using the MinGW-w64 cross-build path
|
||||
|
||||
### Changed
|
||||
- GitHub Actions workflows now opt into Node 24 for JavaScript-based actions to avoid Node 20 deprecation warnings
|
||||
|
||||
## [2.1.0] — 2026-04-30
|
||||
|
||||
### Added
|
||||
@@ -36,7 +44,8 @@ e il progetto aderisce al [Semantic Versioning](https://semver.org/spec/v2.0.0.h
|
||||
- CI/CD via GitHub Actions (mirror automatico Gitea → GitHub)
|
||||
- Documentazione completa (README, CONTRIBUTING, SECURITY)
|
||||
|
||||
[Unreleased]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/compare/v2.1.0...HEAD
|
||||
[Unreleased]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/compare/v2.2.1...HEAD
|
||||
[2.2.1]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/compare/v2.2.0...v2.2.1
|
||||
[2.1.0]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/compare/v2.0.1...v2.1.0
|
||||
[2.0.1]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/compare/v2.0.0...v2.0.1
|
||||
[2.0.0]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/releases/tag/v2.0.0
|
||||
|
||||
@@ -61,10 +61,17 @@ python build_plugin.py --7zip-version 25.01
|
||||
# Specific toolset (2022|2026|auto)
|
||||
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
|
||||
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
|
||||
|
||||
```
|
||||
|
||||
+16
-3
@@ -5,7 +5,7 @@ Wraps per-version/per-toolset build scripts.
|
||||
Defaults: 7-Zip 26.00, VS2026 (v145 toolset)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse, subprocess, sys
|
||||
import argparse, platform, subprocess, sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class Colors:
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
SCRIPTS = {
|
||||
WINDOWS_SCRIPTS = {
|
||||
"19.00": {"2022": "tools/legacy/build_plugin_vs2022.py",
|
||||
"2026": "tools/legacy/build_plugin_vs2026.py"},
|
||||
"25.01": {"2022": "tools/legacy/build_plugin_2501_vs2022.py",
|
||||
@@ -27,6 +27,8 @@ SCRIPTS = {
|
||||
"2026": "tools/legacy/build_plugin_zstd_vs2026.py"},
|
||||
}
|
||||
|
||||
LINUX_SCRIPT = "tools/linux/build_plugin_linux.py"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Build nsis7z NSIS plugin")
|
||||
@@ -36,6 +38,8 @@ def main() -> int:
|
||||
"'zstd' uses mcmilk/7-Zip-zstd submodule")
|
||||
parser.add_argument("--toolset", choices=["2022", "2026", "auto"], 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",
|
||||
help="Print plugin version and exit")
|
||||
known, rest = parser.parse_known_args()
|
||||
@@ -49,11 +53,20 @@ def main() -> int:
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}=== Building ns7zip v{ver} "
|
||||
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
|
||||
if toolset == "auto":
|
||||
toolset = "2026"
|
||||
|
||||
script_rel = SCRIPTS[known.zip_version][toolset]
|
||||
script_rel = WINDOWS_SCRIPTS[known.zip_version][toolset]
|
||||
if script_rel is None:
|
||||
print(f"ERROR: no {known.zip_version} script for toolset {toolset}", file=sys.stderr)
|
||||
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')
|
||||
@@ -28,6 +28,69 @@ import threading
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Colors & Spinner
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class Colors:
|
||||
CYAN = "\033[36m"
|
||||
GREEN = "\033[32m"
|
||||
YELLOW = "\033[33m"
|
||||
RED = "\033[31m"
|
||||
GRAY = "\033[90m"
|
||||
BLUE = "\033[34m"
|
||||
RESET = "\033[0m"
|
||||
BOLD = "\033[1m"
|
||||
BRIGHT_GREEN = "\033[92m"
|
||||
BRIGHT_CYAN = "\033[96m"
|
||||
BRIGHT_WHITE = "\033[97m"
|
||||
BRIGHT_YELLOW = "\033[93m"
|
||||
BRIGHT_RED = "\033[91m"
|
||||
|
||||
|
||||
class Spinner:
|
||||
def __init__(self, message: str = "Building...", delay: float = 0.1, total: int = 0):
|
||||
self.spinner = ['\u280b', '\u2819', '\u2839', '\u2838', '\u283c', '\u2834', '\u2826', '\u2827', '\u2807', '\u280f']
|
||||
self.delay = delay
|
||||
self.message = message
|
||||
self.running = False
|
||||
self.thread = None
|
||||
self.start_time = time.time()
|
||||
|
||||
def update(self, current=None):
|
||||
pass
|
||||
|
||||
def _spin(self):
|
||||
idx = 0
|
||||
_block = '\u28ff'
|
||||
while self.running:
|
||||
elapsed = time.time() - self.start_time
|
||||
n_blocks = int(elapsed // 2)
|
||||
time_blocks = f"{Colors.YELLOW}{_block * n_blocks}{Colors.RESET}"
|
||||
spin_char = f"{Colors.YELLOW}{self.spinner[idx % len(self.spinner)]}{Colors.RESET}"
|
||||
msg = f"{Colors.BOLD}{Colors.CYAN}{self.message}{Colors.RESET}"
|
||||
time_str = f"{Colors.GREEN}{int(elapsed)}s{Colors.RESET}"
|
||||
sys.stdout.write(f"\r{msg} {time_str} {time_blocks}{spin_char} ")
|
||||
sys.stdout.flush()
|
||||
idx += 1
|
||||
time.sleep(self.delay)
|
||||
sys.stdout.write("\r" + " " * (len(self.message) + 80) + "\r")
|
||||
sys.stdout.flush()
|
||||
|
||||
def __enter__(self):
|
||||
if sys.stdout.isatty():
|
||||
self.running = True
|
||||
self.thread = threading.Thread(target=self._spin, daemon=True)
|
||||
self.thread.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
if self.running:
|
||||
self.running = False
|
||||
if self.thread:
|
||||
self.thread.join()
|
||||
|
||||
|
||||
@dataclass
|
||||
class BuildConfig:
|
||||
"""Build configuration settings"""
|
||||
@@ -208,44 +271,42 @@ def get_memory_optimizations() -> List[str]:
|
||||
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||
"""Print CPU information for build optimization"""
|
||||
if not use_parallel:
|
||||
print("Build mode: Single-threaded")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Single-threaded{Colors.RESET}")
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||
return
|
||||
|
||||
cpu_info = get_cpu_info()
|
||||
optimal_threads = get_optimal_thread_count()
|
||||
|
||||
print("Build mode: Parallel")
|
||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||
|
||||
if cpu_info['has_hyperthreading']:
|
||||
print("Hyperthreading: ENABLED")
|
||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||
else:
|
||||
print("Hyperthreading: NOT AVAILABLE")
|
||||
print(f"Optimal threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
print(f"MSBuild threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}MSBuild threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (parallel, memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET} (parallel, memory, caching)")
|
||||
try:
|
||||
import psutil
|
||||
memory_gb = psutil.virtual_memory().total / (1024**3)
|
||||
print(f"Available memory: {memory_gb:.1f} GB")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.BRIGHT_WHITE}{memory_gb:.1f} GB{Colors.RESET}")
|
||||
except ImportError:
|
||||
print("Available memory: Unknown (install psutil for details)")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.GRAY}Unknown (install psutil for details){Colors.RESET}")
|
||||
else:
|
||||
print("Optimizations: DISABLED")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||
|
||||
if not cpu_info['has_psutil']:
|
||||
print("Note: Install 'psutil' for detailed CPU/memory info (pip install psutil)")
|
||||
print(f"{Colors.GRAY}Note: Install 'psutil' for detailed CPU/memory info (pip install psutil){Colors.RESET}")
|
||||
|
||||
print()
|
||||
|
||||
|
||||
def build_configuration(
|
||||
msbuild_path: Path,
|
||||
project_file: Path,
|
||||
@@ -296,12 +357,12 @@ def build_configuration(
|
||||
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
||||
|
||||
if not capture_output:
|
||||
print(f"\n{'='*50}")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||
if counter:
|
||||
print(f"Building {config.name} [{counter}]")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||
else:
|
||||
print(f"Building {config.name}...")
|
||||
print('='*50)
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||
|
||||
# Execute build and measure time
|
||||
start_time = time.time()
|
||||
@@ -339,7 +400,7 @@ def copy_output(
|
||||
dest_dir = plugins_dir / config.dest_dir
|
||||
|
||||
if not output_file.exists():
|
||||
print(f"ERROR: {config.name} DLL not found at {output_file}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} {config.name} DLL not found at {output_file}")
|
||||
return False, 0, None
|
||||
|
||||
# Create destination directory
|
||||
@@ -350,16 +411,16 @@ def copy_output(
|
||||
dest_path = dest_dir / 'nsis7z.dll'
|
||||
shutil.copy2(output_file, dest_path)
|
||||
file_size = output_file.stat().st_size
|
||||
print(f"SUCCESS: {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
print(f"{Colors.BRIGHT_GREEN}SUCCESS:{Colors.RESET} {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
return True, file_size, dest_path
|
||||
except Exception as e:
|
||||
print(f"ERROR: Failed to copy {config.name}: {e}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} Failed to copy {config.name}: {e}")
|
||||
return False, 0, None
|
||||
|
||||
|
||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||
"""Clean up build artifacts"""
|
||||
print("\nCleaning build artifacts...")
|
||||
print(f"\n{Colors.CYAN}Cleaning build artifacts...{Colors.RESET}")
|
||||
|
||||
build_base_dir = project_dir / 'CPP' / '7zip' / 'Bundles' / 'Nsis7z' / 'Build'
|
||||
|
||||
@@ -373,11 +434,11 @@ def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None
|
||||
if dir_path.exists():
|
||||
try:
|
||||
shutil.rmtree(dir_path)
|
||||
print(f" - Cleaned: {dir_path.name}")
|
||||
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||
except Exception as e:
|
||||
print(f" - Failed to clean {dir_path.name}: {e}")
|
||||
print(f" {Colors.RED}- Failed to clean {dir_path.name}: {e}{Colors.RESET}")
|
||||
|
||||
print("Build artifacts cleaned successfully.")
|
||||
print(f"{Colors.BRIGHT_GREEN}Build artifacts cleaned successfully.{Colors.RESET}")
|
||||
|
||||
|
||||
def format_time(seconds: float) -> str:
|
||||
@@ -512,8 +573,8 @@ def _build_configs_parallel(
|
||||
in the same order as *configs*.
|
||||
"""
|
||||
n = len(configs)
|
||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
||||
print("=" * 50)
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||
|
||||
total_start = time.time()
|
||||
results_by_idx: dict = {}
|
||||
@@ -537,22 +598,26 @@ def _build_configs_parallel(
|
||||
|
||||
with _print_lock:
|
||||
all_ok = success and copy_ok
|
||||
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||
tag = "OK" if all_ok else "FAILED"
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f"[{tag}] {config.name} ({format_time(build_time)}) {size_str}")
|
||||
sys.stdout.write("\r" + " " * 80 + "\r")
|
||||
sys.stdout.flush()
|
||||
print(f"{tag_color}[{tag}]{Colors.RESET} {config.name} ({format_time(build_time)}) {size_str}")
|
||||
if dest_path:
|
||||
print(f" -> {dest_path}")
|
||||
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||
if not all_ok:
|
||||
copy_out = copy_buf.getvalue()
|
||||
if copy_out.strip():
|
||||
print(copy_out.rstrip())
|
||||
if captured.strip():
|
||||
print("--- Build output ---")
|
||||
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||
print(captured.rstrip())
|
||||
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
||||
|
||||
with Spinner(f"Building {n} configs in parallel...") as _spinner:
|
||||
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||
for fut in as_completed(futures):
|
||||
@@ -560,12 +625,12 @@ def _build_configs_parallel(
|
||||
if exc:
|
||||
idx = futures[fut]
|
||||
with _print_lock:
|
||||
print(f"ERROR: worker for config index {idx} raised: {exc}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} worker for config index {idx} raised: {exc}")
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||
|
||||
wall_time = time.time() - total_start
|
||||
print(f"\nAll {n} configs finished in {format_time(wall_time)} (wall clock)")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}All {n} configs finished in {Colors.BRIGHT_WHITE}{format_time(wall_time)}{Colors.CYAN} (wall clock){Colors.RESET}")
|
||||
return [results_by_idx[i] for i in range(n)]
|
||||
|
||||
def main():
|
||||
@@ -724,15 +789,15 @@ Examples:
|
||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||
|
||||
# Print header
|
||||
print("=" * 60)
|
||||
print(f"Building nsis7z plugin (7-Zip 25.01) - {len(configs_to_build)} configuration(s)")
|
||||
print("=" * 60)
|
||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
||||
print(f"MSBuild: {msbuild_path}")
|
||||
print(f"Project: {project_file}")
|
||||
print(f"Plugins: {plugins_dir}")
|
||||
print(f"Rebuild: {args.rebuild}")
|
||||
print(f"Verbosity: {args.verbosity}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Building nsis7z plugin (7-Zip 25.01){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.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}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
# Print CPU and parallel build info
|
||||
@@ -826,12 +891,13 @@ Examples:
|
||||
total_time = time.time() - total_start_time
|
||||
|
||||
# Summary
|
||||
print("\n" + "=" * 50)
|
||||
print()
|
||||
all_success = all(success for _, success, _, _, _ in build_results)
|
||||
|
||||
if all_success:
|
||||
print("ALL BUILDS SUCCESSFUL!")
|
||||
print("=" * 50)
|
||||
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}{"="*50}{Colors.RESET}")
|
||||
print("\nPlugins copied to:")
|
||||
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'
|
||||
@@ -842,22 +908,24 @@ Examples:
|
||||
print()
|
||||
clean_build_artifacts(project_dir, configs_to_build)
|
||||
else:
|
||||
print("SOME BUILDS FAILED!")
|
||||
print("=" * 50)
|
||||
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}{"="*50}{Colors.RESET}")
|
||||
print("\nFailed configurations:")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
if not success:
|
||||
print(f" - {config.name}")
|
||||
|
||||
# Show timing summary
|
||||
print("\n" + "-" * 50)
|
||||
print("Build Summary:")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
status = "OK" if success else "FAIL"
|
||||
row_color = Colors.BRIGHT_GREEN if success else Colors.RED
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f" {status} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print("-" * 50)
|
||||
print(f"Total time: {format_time(total_time)}")
|
||||
print(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
# Pause if requested
|
||||
|
||||
@@ -21,6 +21,69 @@ from typing import List, Tuple, Optional
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Colors & Spinner
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class Colors:
|
||||
CYAN = "\033[36m"
|
||||
GREEN = "\033[32m"
|
||||
YELLOW = "\033[33m"
|
||||
RED = "\033[31m"
|
||||
GRAY = "\033[90m"
|
||||
BLUE = "\033[34m"
|
||||
RESET = "\033[0m"
|
||||
BOLD = "\033[1m"
|
||||
BRIGHT_GREEN = "\033[92m"
|
||||
BRIGHT_CYAN = "\033[96m"
|
||||
BRIGHT_WHITE = "\033[97m"
|
||||
BRIGHT_YELLOW = "\033[93m"
|
||||
BRIGHT_RED = "\033[91m"
|
||||
|
||||
|
||||
class Spinner:
|
||||
def __init__(self, message: str = "Building...", delay: float = 0.1, total: int = 0):
|
||||
self.spinner = ['\u280b', '\u2819', '\u2839', '\u2838', '\u283c', '\u2834', '\u2826', '\u2827', '\u2807', '\u280f']
|
||||
self.delay = delay
|
||||
self.message = message
|
||||
self.running = False
|
||||
self.thread = None
|
||||
self.start_time = time.time()
|
||||
|
||||
def update(self, current=None):
|
||||
pass
|
||||
|
||||
def _spin(self):
|
||||
idx = 0
|
||||
_block = '\u28ff'
|
||||
while self.running:
|
||||
elapsed = time.time() - self.start_time
|
||||
n_blocks = int(elapsed // 2)
|
||||
time_blocks = f"{Colors.YELLOW}{_block * n_blocks}{Colors.RESET}"
|
||||
spin_char = f"{Colors.YELLOW}{self.spinner[idx % len(self.spinner)]}{Colors.RESET}"
|
||||
msg = f"{Colors.BOLD}{Colors.CYAN}{self.message}{Colors.RESET}"
|
||||
time_str = f"{Colors.GREEN}{int(elapsed)}s{Colors.RESET}"
|
||||
sys.stdout.write(f"\r{msg} {time_str} {time_blocks}{spin_char} ")
|
||||
sys.stdout.flush()
|
||||
idx += 1
|
||||
time.sleep(self.delay)
|
||||
sys.stdout.write("\r" + " " * (len(self.message) + 80) + "\r")
|
||||
sys.stdout.flush()
|
||||
|
||||
def __enter__(self):
|
||||
if sys.stdout.isatty():
|
||||
self.running = True
|
||||
self.thread = threading.Thread(target=self._spin, daemon=True)
|
||||
self.thread.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
if self.running:
|
||||
self.running = False
|
||||
if self.thread:
|
||||
self.thread.join()
|
||||
|
||||
|
||||
class BuildConfig:
|
||||
"""Configuration for a single build target"""
|
||||
def __init__(self, name: str, config: str, platform: str, dest_dir: str):
|
||||
@@ -222,40 +285,40 @@ def get_memory_optimizations() -> List[str]:
|
||||
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||
"""Print CPU information for build optimization"""
|
||||
if not use_parallel:
|
||||
print("Build mode: Single-threaded")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Single-threaded{Colors.RESET}")
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||
return
|
||||
|
||||
cpu_info = get_cpu_info()
|
||||
optimal_threads = get_optimal_thread_count()
|
||||
|
||||
print("Build mode: Parallel")
|
||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||
|
||||
if cpu_info['has_hyperthreading']:
|
||||
print("Hyperthreading: ENABLED")
|
||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||
else:
|
||||
print("Hyperthreading: NOT AVAILABLE")
|
||||
print(f"Optimal threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
print(f"MSBuild threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}MSBuild threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (parallel, memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET} (parallel, memory, caching)")
|
||||
try:
|
||||
import psutil
|
||||
memory_gb = psutil.virtual_memory().total / (1024**3)
|
||||
print(f"Available memory: {memory_gb:.1f} GB")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.BRIGHT_WHITE}{memory_gb:.1f} GB{Colors.RESET}")
|
||||
except ImportError:
|
||||
print("Available memory: Unknown (install psutil for details)")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.GRAY}Unknown (install psutil for details){Colors.RESET}")
|
||||
else:
|
||||
print("Optimizations: DISABLED")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||
|
||||
if not cpu_info['has_psutil']:
|
||||
print("Note: Install 'psutil' for detailed CPU/memory info (pip install psutil)")
|
||||
print(f"{Colors.GRAY}Note: Install 'psutil' for detailed CPU/memory info (pip install psutil){Colors.RESET}")
|
||||
|
||||
print()
|
||||
|
||||
@@ -310,12 +373,12 @@ def build_configuration(
|
||||
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
||||
|
||||
if not capture_output:
|
||||
print(f"\n{'='*50}")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||
if counter:
|
||||
print(f"Building {config.name} [{counter}]")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||
else:
|
||||
print(f"Building {config.name}...")
|
||||
print('='*50)
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||
|
||||
# Execute build and measure time
|
||||
start_time = time.time()
|
||||
@@ -353,7 +416,7 @@ def copy_output(
|
||||
dest_dir = plugins_dir / config.dest_dir
|
||||
|
||||
if not output_file.exists():
|
||||
print(f"ERROR: {config.name} DLL not found at {output_file}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} {config.name} DLL not found at {output_file}")
|
||||
return False, 0, None
|
||||
|
||||
# Create destination directory
|
||||
@@ -364,16 +427,16 @@ def copy_output(
|
||||
dest_path = dest_dir / 'nsis7z.dll'
|
||||
shutil.copy2(output_file, dest_path)
|
||||
file_size = output_file.stat().st_size
|
||||
print(f"SUCCESS: {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
print(f"{Colors.BRIGHT_GREEN}SUCCESS:{Colors.RESET} {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
return True, file_size, dest_path
|
||||
except Exception as e:
|
||||
print(f"ERROR: Failed to copy {config.name}: {e}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} Failed to copy {config.name}: {e}")
|
||||
return False, 0, None
|
||||
|
||||
|
||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||
"""Clean up build artifacts"""
|
||||
print("\nCleaning build artifacts...")
|
||||
print(f"\n{Colors.CYAN}Cleaning build artifacts...{Colors.RESET}")
|
||||
|
||||
build_base_dir = project_dir / 'CPP' / '7zip' / 'Bundles' / 'Nsis7z' / 'Build'
|
||||
|
||||
@@ -387,11 +450,11 @@ def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None
|
||||
if dir_path.exists():
|
||||
try:
|
||||
shutil.rmtree(dir_path)
|
||||
print(f" - Cleaned: {dir_path.name}")
|
||||
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||
except Exception as e:
|
||||
print(f" - Failed to clean {dir_path.name}: {e}")
|
||||
print(f" {Colors.RED}- Failed to clean {dir_path.name}: {e}{Colors.RESET}")
|
||||
|
||||
print("Build artifacts cleaned successfully.")
|
||||
print(f"{Colors.BRIGHT_GREEN}Build artifacts cleaned successfully.{Colors.RESET}")
|
||||
|
||||
|
||||
def format_time(seconds: float) -> str:
|
||||
@@ -526,8 +589,8 @@ def _build_configs_parallel(
|
||||
in the same order as *configs*.
|
||||
"""
|
||||
n = len(configs)
|
||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
||||
print("=" * 50)
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||
|
||||
total_start = time.time()
|
||||
results_by_idx: dict = {}
|
||||
@@ -551,22 +614,26 @@ def _build_configs_parallel(
|
||||
|
||||
with _print_lock:
|
||||
all_ok = success and copy_ok
|
||||
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||
tag = "OK" if all_ok else "FAILED"
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f"[{tag}] {config.name} ({format_time(build_time)}) {size_str}")
|
||||
sys.stdout.write("\r" + " " * 80 + "\r")
|
||||
sys.stdout.flush()
|
||||
print(f"{tag_color}[{tag}]{Colors.RESET} {config.name} ({format_time(build_time)}) {size_str}")
|
||||
if dest_path:
|
||||
print(f" -> {dest_path}")
|
||||
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||
if not all_ok:
|
||||
copy_out = copy_buf.getvalue()
|
||||
if copy_out.strip():
|
||||
print(copy_out.rstrip())
|
||||
if captured.strip():
|
||||
print("--- Build output ---")
|
||||
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||
print(captured.rstrip())
|
||||
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
||||
|
||||
with Spinner(f"Building {n} configs in parallel...") as _spinner:
|
||||
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||
for fut in as_completed(futures):
|
||||
@@ -574,12 +641,12 @@ def _build_configs_parallel(
|
||||
if exc:
|
||||
idx = futures[fut]
|
||||
with _print_lock:
|
||||
print(f"ERROR: worker for config index {idx} raised: {exc}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} worker for config index {idx} raised: {exc}")
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||
|
||||
wall_time = time.time() - total_start
|
||||
print(f"\nAll {n} configs finished in {format_time(wall_time)} (wall clock)")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}All {n} configs finished in {Colors.BRIGHT_WHITE}{format_time(wall_time)}{Colors.CYAN} (wall clock){Colors.RESET}")
|
||||
return [results_by_idx[i] for i in range(n)]
|
||||
|
||||
def main():
|
||||
@@ -749,15 +816,15 @@ Examples:
|
||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||
|
||||
# Print header
|
||||
print("=" * 60)
|
||||
print(f"Building nsis7z plugin (7-Zip 25.01, VS2026) - {len(configs_to_build)} configuration(s)")
|
||||
print("=" * 60)
|
||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
||||
print(f"MSBuild: {msbuild_path}")
|
||||
print(f"Project: {project_file}")
|
||||
print(f"Plugins: {plugins_dir}")
|
||||
print(f"Rebuild: {args.rebuild}")
|
||||
print(f"Verbosity: {args.verbosity}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Building nsis7z plugin (7-Zip 25.01, 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.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}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
# Print CPU and parallel build info
|
||||
@@ -851,12 +918,13 @@ Examples:
|
||||
total_time = time.time() - total_start_time
|
||||
|
||||
# Summary
|
||||
print("\n" + "=" * 50)
|
||||
print()
|
||||
all_success = all(success for _, success, _, _, _ in build_results)
|
||||
|
||||
if all_success:
|
||||
print("ALL BUILDS SUCCESSFUL!")
|
||||
print("=" * 50)
|
||||
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}{"="*50}{Colors.RESET}")
|
||||
print("\nPlugins copied to:")
|
||||
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'
|
||||
@@ -867,22 +935,24 @@ Examples:
|
||||
print()
|
||||
clean_build_artifacts(project_dir, configs_to_build)
|
||||
else:
|
||||
print("SOME BUILDS FAILED!")
|
||||
print("=" * 50)
|
||||
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}{"="*50}{Colors.RESET}")
|
||||
print("\nFailed configurations:")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
if not success:
|
||||
print(f" - {config.name}")
|
||||
|
||||
# Show timing summary
|
||||
print("\n" + "-" * 50)
|
||||
print("Build Summary:")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
status = "OK" if success else "FAIL"
|
||||
row_color = Colors.BRIGHT_GREEN if success else Colors.RED
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f" {status} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print("-" * 50)
|
||||
print(f"Total time: {format_time(total_time)}")
|
||||
print(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
# Pause if requested
|
||||
|
||||
@@ -21,6 +21,69 @@ from typing import List, Tuple, Optional
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Colors & Spinner
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class Colors:
|
||||
CYAN = "\033[36m"
|
||||
GREEN = "\033[32m"
|
||||
YELLOW = "\033[33m"
|
||||
RED = "\033[31m"
|
||||
GRAY = "\033[90m"
|
||||
BLUE = "\033[34m"
|
||||
RESET = "\033[0m"
|
||||
BOLD = "\033[1m"
|
||||
BRIGHT_GREEN = "\033[92m"
|
||||
BRIGHT_CYAN = "\033[96m"
|
||||
BRIGHT_WHITE = "\033[97m"
|
||||
BRIGHT_YELLOW = "\033[93m"
|
||||
BRIGHT_RED = "\033[91m"
|
||||
|
||||
|
||||
class Spinner:
|
||||
def __init__(self, message: str = "Building...", delay: float = 0.1, total: int = 0):
|
||||
self.spinner = ['\u280b', '\u2819', '\u2839', '\u2838', '\u283c', '\u2834', '\u2826', '\u2827', '\u2807', '\u280f']
|
||||
self.delay = delay
|
||||
self.message = message
|
||||
self.running = False
|
||||
self.thread = None
|
||||
self.start_time = time.time()
|
||||
|
||||
def update(self, current=None):
|
||||
pass
|
||||
|
||||
def _spin(self):
|
||||
idx = 0
|
||||
_block = '\u28ff'
|
||||
while self.running:
|
||||
elapsed = time.time() - self.start_time
|
||||
n_blocks = int(elapsed // 2)
|
||||
time_blocks = f"{Colors.YELLOW}{_block * n_blocks}{Colors.RESET}"
|
||||
spin_char = f"{Colors.YELLOW}{self.spinner[idx % len(self.spinner)]}{Colors.RESET}"
|
||||
msg = f"{Colors.BOLD}{Colors.CYAN}{self.message}{Colors.RESET}"
|
||||
time_str = f"{Colors.GREEN}{int(elapsed)}s{Colors.RESET}"
|
||||
sys.stdout.write(f"\r{msg} {time_str} {time_blocks}{spin_char} ")
|
||||
sys.stdout.flush()
|
||||
idx += 1
|
||||
time.sleep(self.delay)
|
||||
sys.stdout.write("\r" + " " * (len(self.message) + 80) + "\r")
|
||||
sys.stdout.flush()
|
||||
|
||||
def __enter__(self):
|
||||
if sys.stdout.isatty():
|
||||
self.running = True
|
||||
self.thread = threading.Thread(target=self._spin, daemon=True)
|
||||
self.thread.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
if self.running:
|
||||
self.running = False
|
||||
if self.thread:
|
||||
self.thread.join()
|
||||
|
||||
|
||||
class BuildConfig:
|
||||
"""Configuration for a single build target"""
|
||||
def __init__(self, name: str, config: str, platform: str, dest_dir: str):
|
||||
@@ -223,40 +286,40 @@ def get_memory_optimizations() -> List[str]:
|
||||
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||
"""Print CPU information for build optimization"""
|
||||
if not use_parallel:
|
||||
print("Build mode: Single-threaded")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Single-threaded{Colors.RESET}")
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||
return
|
||||
|
||||
cpu_info = get_cpu_info()
|
||||
optimal_threads = get_optimal_thread_count()
|
||||
|
||||
print("Build mode: Parallel")
|
||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||
|
||||
if cpu_info['has_hyperthreading']:
|
||||
print("Hyperthreading: ENABLED")
|
||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||
else:
|
||||
print("Hyperthreading: NOT AVAILABLE")
|
||||
print(f"Optimal threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
print(f"MSBuild threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}MSBuild threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (parallel, memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET} (parallel, memory, caching)")
|
||||
try:
|
||||
import psutil
|
||||
memory_gb = psutil.virtual_memory().total / (1024**3)
|
||||
print(f"Available memory: {memory_gb:.1f} GB")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.BRIGHT_WHITE}{memory_gb:.1f} GB{Colors.RESET}")
|
||||
except ImportError:
|
||||
print("Available memory: Unknown (install psutil for details)")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.GRAY}Unknown (install psutil for details){Colors.RESET}")
|
||||
else:
|
||||
print("Optimizations: DISABLED")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||
|
||||
if not cpu_info['has_psutil']:
|
||||
print("Note: Install 'psutil' for detailed CPU/memory info (pip install psutil)")
|
||||
print(f"{Colors.GRAY}Note: Install 'psutil' for detailed CPU/memory info (pip install psutil){Colors.RESET}")
|
||||
|
||||
print()
|
||||
|
||||
@@ -312,12 +375,12 @@ def build_configuration(
|
||||
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
||||
|
||||
if not capture_output:
|
||||
print(f"\n{'='*50}")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||
if counter:
|
||||
print(f"Building {config.name} [{counter}]")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||
else:
|
||||
print(f"Building {config.name}...")
|
||||
print('='*50)
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||
|
||||
# Execute build and measure time
|
||||
start_time = time.time()
|
||||
@@ -355,7 +418,7 @@ def copy_output(
|
||||
dest_dir = plugins_dir / config.dest_dir
|
||||
|
||||
if not output_file.exists():
|
||||
print(f"ERROR: {config.name} DLL not found at {output_file}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} {config.name} DLL not found at {output_file}")
|
||||
return False, 0, None
|
||||
|
||||
# Create destination directory
|
||||
@@ -366,16 +429,16 @@ def copy_output(
|
||||
dest_path = dest_dir / 'nsis7z.dll'
|
||||
shutil.copy2(output_file, dest_path)
|
||||
file_size = output_file.stat().st_size
|
||||
print(f"SUCCESS: {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
print(f"{Colors.BRIGHT_GREEN}SUCCESS:{Colors.RESET} {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
return True, file_size, dest_path
|
||||
except Exception as e:
|
||||
print(f"ERROR: Failed to copy {config.name}: {e}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} Failed to copy {config.name}: {e}")
|
||||
return False, 0, None
|
||||
|
||||
|
||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||
"""Clean up build artifacts"""
|
||||
print("\nCleaning build artifacts...")
|
||||
print(f"\n{Colors.CYAN}Cleaning build artifacts...{Colors.RESET}")
|
||||
|
||||
build_base_dir = project_dir / 'CPP' / '7zip' / 'Bundles' / 'Nsis7z' / 'Build'
|
||||
|
||||
@@ -389,11 +452,11 @@ def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None
|
||||
if dir_path.exists():
|
||||
try:
|
||||
shutil.rmtree(dir_path)
|
||||
print(f" - Cleaned: {dir_path.name}")
|
||||
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||
except Exception as e:
|
||||
print(f" - Failed to clean {dir_path.name}: {e}")
|
||||
print(f" {Colors.RED}- Failed to clean {dir_path.name}: {e}{Colors.RESET}")
|
||||
|
||||
print("Build artifacts cleaned successfully.")
|
||||
print(f"{Colors.BRIGHT_GREEN}Build artifacts cleaned successfully.{Colors.RESET}")
|
||||
|
||||
|
||||
def format_time(seconds: float) -> str:
|
||||
@@ -529,8 +592,8 @@ def _build_configs_parallel(
|
||||
in the same order as *configs*.
|
||||
"""
|
||||
n = len(configs)
|
||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
||||
print("=" * 50)
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||
|
||||
total_start = time.time()
|
||||
results_by_idx: dict = {}
|
||||
@@ -554,22 +617,26 @@ def _build_configs_parallel(
|
||||
|
||||
with _print_lock:
|
||||
all_ok = success and copy_ok
|
||||
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||
tag = "OK" if all_ok else "FAILED"
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f"[{tag}] {config.name} ({format_time(build_time)}) {size_str}")
|
||||
sys.stdout.write("\r" + " " * 80 + "\r")
|
||||
sys.stdout.flush()
|
||||
print(f"{tag_color}[{tag}]{Colors.RESET} {config.name} ({format_time(build_time)}) {size_str}")
|
||||
if dest_path:
|
||||
print(f" -> {dest_path}")
|
||||
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||
if not all_ok:
|
||||
copy_out = copy_buf.getvalue()
|
||||
if copy_out.strip():
|
||||
print(copy_out.rstrip())
|
||||
if captured.strip():
|
||||
print("--- Build output ---")
|
||||
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||
print(captured.rstrip())
|
||||
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
||||
|
||||
with Spinner(f"Building {n} configs in parallel...") as _spinner:
|
||||
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||
for fut in as_completed(futures):
|
||||
@@ -577,12 +644,12 @@ def _build_configs_parallel(
|
||||
if exc:
|
||||
idx = futures[fut]
|
||||
with _print_lock:
|
||||
print(f"ERROR: worker for config index {idx} raised: {exc}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} worker for config index {idx} raised: {exc}")
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||
|
||||
wall_time = time.time() - total_start
|
||||
print(f"\nAll {n} configs finished in {format_time(wall_time)} (wall clock)")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}All {n} configs finished in {Colors.BRIGHT_WHITE}{format_time(wall_time)}{Colors.CYAN} (wall clock){Colors.RESET}")
|
||||
return [results_by_idx[i] for i in range(n)]
|
||||
|
||||
def main():
|
||||
@@ -744,15 +811,15 @@ Examples:
|
||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||
|
||||
# Print header
|
||||
print("=" * 60)
|
||||
print(f"Building nsis7z plugin (7-Zip 26.00, VS2026) - {len(configs_to_build)} configuration(s)")
|
||||
print("=" * 60)
|
||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
||||
print(f"MSBuild: {msbuild_path}")
|
||||
print(f"Project: {project_file}")
|
||||
print(f"Plugins: {plugins_dir}")
|
||||
print(f"Rebuild: {args.rebuild}")
|
||||
print(f"Verbosity: {args.verbosity}")
|
||||
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}{'='*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}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}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
# Print CPU and parallel build info
|
||||
@@ -850,12 +917,13 @@ Examples:
|
||||
total_time = time.time() - total_start_time
|
||||
|
||||
# Summary
|
||||
print("\n" + "=" * 50)
|
||||
print()
|
||||
all_success = all(success for _, success, _, _, _ in build_results)
|
||||
|
||||
if all_success:
|
||||
print("ALL BUILDS SUCCESSFUL!")
|
||||
print("=" * 50)
|
||||
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}{'='*50}{Colors.RESET}")
|
||||
print("\nPlugins copied to:")
|
||||
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'
|
||||
@@ -866,22 +934,24 @@ Examples:
|
||||
print()
|
||||
clean_build_artifacts(project_dir, configs_to_build)
|
||||
else:
|
||||
print("SOME BUILDS FAILED!")
|
||||
print("=" * 50)
|
||||
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}{'='*50}{Colors.RESET}")
|
||||
print("\nFailed configurations:")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
if not success:
|
||||
print(f" - {config.name}")
|
||||
|
||||
# Show timing summary
|
||||
print("\n" + "-" * 50)
|
||||
print("Build Summary:")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{'-'*50}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
status = "OK" if success else "FAIL"
|
||||
row_color = Colors.BRIGHT_GREEN if success else Colors.RED
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f" {status} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print("-" * 50)
|
||||
print(f"Total time: {format_time(total_time)}")
|
||||
print(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'-'*50}{Colors.RESET}")
|
||||
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
# Pause if requested
|
||||
|
||||
@@ -18,6 +18,69 @@ from typing import List, Tuple, Optional
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Colors & Spinner
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class Colors:
|
||||
CYAN = "\033[36m"
|
||||
GREEN = "\033[32m"
|
||||
YELLOW = "\033[33m"
|
||||
RED = "\033[31m"
|
||||
GRAY = "\033[90m"
|
||||
BLUE = "\033[34m"
|
||||
RESET = "\033[0m"
|
||||
BOLD = "\033[1m"
|
||||
BRIGHT_GREEN = "\033[92m"
|
||||
BRIGHT_CYAN = "\033[96m"
|
||||
BRIGHT_WHITE = "\033[97m"
|
||||
BRIGHT_YELLOW = "\033[93m"
|
||||
BRIGHT_RED = "\033[91m"
|
||||
|
||||
|
||||
class Spinner:
|
||||
def __init__(self, message: str = "Building...", delay: float = 0.1, total: int = 0):
|
||||
self.spinner = ['\u280b', '\u2819', '\u2839', '\u2838', '\u283c', '\u2834', '\u2826', '\u2827', '\u2807', '\u280f']
|
||||
self.delay = delay
|
||||
self.message = message
|
||||
self.running = False
|
||||
self.thread = None
|
||||
self.start_time = time.time()
|
||||
|
||||
def update(self, current=None):
|
||||
pass
|
||||
|
||||
def _spin(self):
|
||||
idx = 0
|
||||
_block = '\u28ff'
|
||||
while self.running:
|
||||
elapsed = time.time() - self.start_time
|
||||
n_blocks = int(elapsed // 2)
|
||||
time_blocks = f"{Colors.YELLOW}{_block * n_blocks}{Colors.RESET}"
|
||||
spin_char = f"{Colors.YELLOW}{self.spinner[idx % len(self.spinner)]}{Colors.RESET}"
|
||||
msg = f"{Colors.BOLD}{Colors.CYAN}{self.message}{Colors.RESET}"
|
||||
time_str = f"{Colors.GREEN}{int(elapsed)}s{Colors.RESET}"
|
||||
sys.stdout.write(f"\r{msg} {time_str} {time_blocks}{spin_char} ")
|
||||
sys.stdout.flush()
|
||||
idx += 1
|
||||
time.sleep(self.delay)
|
||||
sys.stdout.write("\r" + " " * (len(self.message) + 80) + "\r")
|
||||
sys.stdout.flush()
|
||||
|
||||
def __enter__(self):
|
||||
if sys.stdout.isatty():
|
||||
self.running = True
|
||||
self.thread = threading.Thread(target=self._spin, daemon=True)
|
||||
self.thread.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
if self.running:
|
||||
self.running = False
|
||||
if self.thread:
|
||||
self.thread.join()
|
||||
|
||||
|
||||
class BuildConfig:
|
||||
"""Configuration for a single build target"""
|
||||
def __init__(self, name: str, config: str, platform: str, dest_dir: str):
|
||||
@@ -206,40 +269,40 @@ def get_memory_optimizations() -> List[str]:
|
||||
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||
"""Print CPU information for build optimization"""
|
||||
if not use_parallel:
|
||||
print("Build mode: Single-threaded")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Single-threaded{Colors.RESET}")
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||
return
|
||||
|
||||
cpu_info = get_cpu_info()
|
||||
optimal_threads = get_optimal_thread_count()
|
||||
|
||||
print("Build mode: Parallel")
|
||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||
|
||||
if cpu_info['has_hyperthreading']:
|
||||
print("Hyperthreading: ENABLED")
|
||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||
else:
|
||||
print("Hyperthreading: NOT AVAILABLE")
|
||||
print(f"Optimal threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
print(f"MSBuild threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}MSBuild threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (parallel, memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET} (parallel, memory, caching)")
|
||||
try:
|
||||
import psutil
|
||||
memory_gb = psutil.virtual_memory().total / (1024**3)
|
||||
print(f"Available memory: {memory_gb:.1f} GB")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.BRIGHT_WHITE}{memory_gb:.1f} GB{Colors.RESET}")
|
||||
except ImportError:
|
||||
print("Available memory: Unknown (install psutil for details)")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.GRAY}Unknown (install psutil for details){Colors.RESET}")
|
||||
else:
|
||||
print("Optimizations: DISABLED")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||
|
||||
if not cpu_info['has_psutil']:
|
||||
print("Note: Install 'psutil' for detailed CPU/memory info (pip install psutil)")
|
||||
print(f"{Colors.GRAY}Note: Install 'psutil' for detailed CPU/memory info (pip install psutil){Colors.RESET}")
|
||||
|
||||
print()
|
||||
|
||||
@@ -294,12 +357,12 @@ def build_configuration(
|
||||
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
||||
|
||||
if not capture_output:
|
||||
print(f"\n{'='*50}")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||
if counter:
|
||||
print(f"Building {config.name} [{counter}]")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||
else:
|
||||
print(f"Building {config.name}...")
|
||||
print('='*50)
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||
|
||||
# Execute build and measure time
|
||||
start_time = time.time()
|
||||
@@ -337,7 +400,7 @@ def copy_output(
|
||||
dest_dir = plugins_dir / config.dest_dir
|
||||
|
||||
if not output_file.exists():
|
||||
print(f"ERROR: {config.name} DLL not found at {output_file}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} {config.name} DLL not found at {output_file}")
|
||||
return False, 0, None
|
||||
|
||||
# Create destination directory
|
||||
@@ -348,16 +411,16 @@ def copy_output(
|
||||
dest_path = dest_dir / 'nsis7z.dll'
|
||||
shutil.copy2(output_file, dest_path)
|
||||
file_size = output_file.stat().st_size
|
||||
print(f"SUCCESS: {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
print(f"{Colors.BRIGHT_GREEN}SUCCESS:{Colors.RESET} {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
return True, file_size, dest_path
|
||||
except Exception as e:
|
||||
print(f"ERROR: Failed to copy {config.name}: {e}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} Failed to copy {config.name}: {e}")
|
||||
return False, 0, None
|
||||
|
||||
|
||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||
"""Clean up build artifacts"""
|
||||
print("\nCleaning build artifacts...")
|
||||
print(f"\n{Colors.CYAN}Cleaning build artifacts...{Colors.RESET}")
|
||||
|
||||
build_base_dir = project_dir / 'CPP' / '7zip' / 'Bundles' / 'Nsis7z' / 'Build'
|
||||
|
||||
@@ -371,11 +434,11 @@ def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None
|
||||
if dir_path.exists():
|
||||
try:
|
||||
shutil.rmtree(dir_path)
|
||||
print(f" - Cleaned: {dir_path.name}")
|
||||
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||
except Exception as e:
|
||||
print(f" - Failed to clean {dir_path.name}: {e}")
|
||||
print(f" {Colors.RED}- Failed to clean {dir_path.name}: {e}{Colors.RESET}")
|
||||
|
||||
print("Build artifacts cleaned successfully.")
|
||||
print(f"{Colors.BRIGHT_GREEN}Build artifacts cleaned successfully.{Colors.RESET}")
|
||||
|
||||
|
||||
def format_time(seconds: float) -> str:
|
||||
@@ -510,8 +573,8 @@ def _build_configs_parallel(
|
||||
in the same order as *configs*.
|
||||
"""
|
||||
n = len(configs)
|
||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
||||
print("=" * 50)
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||
|
||||
total_start = time.time()
|
||||
results_by_idx: dict = {}
|
||||
@@ -535,22 +598,26 @@ def _build_configs_parallel(
|
||||
|
||||
with _print_lock:
|
||||
all_ok = success and copy_ok
|
||||
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||
tag = "OK" if all_ok else "FAILED"
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f"[{tag}] {config.name} ({format_time(build_time)}) {size_str}")
|
||||
sys.stdout.write("\r" + " " * 80 + "\r")
|
||||
sys.stdout.flush()
|
||||
print(f"{tag_color}[{tag}]{Colors.RESET} {config.name} ({format_time(build_time)}) {size_str}")
|
||||
if dest_path:
|
||||
print(f" -> {dest_path}")
|
||||
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||
if not all_ok:
|
||||
copy_out = copy_buf.getvalue()
|
||||
if copy_out.strip():
|
||||
print(copy_out.rstrip())
|
||||
if captured.strip():
|
||||
print("--- Build output ---")
|
||||
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||
print(captured.rstrip())
|
||||
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
||||
|
||||
with Spinner(f"Building {n} configs in parallel...") as _spinner:
|
||||
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||
for fut in as_completed(futures):
|
||||
@@ -558,12 +625,12 @@ def _build_configs_parallel(
|
||||
if exc:
|
||||
idx = futures[fut]
|
||||
with _print_lock:
|
||||
print(f"ERROR: worker for config index {idx} raised: {exc}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} worker for config index {idx} raised: {exc}")
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||
|
||||
wall_time = time.time() - total_start
|
||||
print(f"\nAll {n} configs finished in {format_time(wall_time)} (wall clock)")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}All {n} configs finished in {Colors.BRIGHT_WHITE}{format_time(wall_time)}{Colors.CYAN} (wall clock){Colors.RESET}")
|
||||
return [results_by_idx[i] for i in range(n)]
|
||||
|
||||
def main():
|
||||
@@ -722,15 +789,15 @@ Examples:
|
||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||
|
||||
# Print header
|
||||
print("=" * 60)
|
||||
print(f"Building nsis7z plugin - {len(configs_to_build)} configuration(s)")
|
||||
print("=" * 60)
|
||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
||||
print(f"MSBuild: {msbuild_path}")
|
||||
print(f"Project: {project_file}")
|
||||
print(f"Plugins: {plugins_dir}")
|
||||
print(f"Rebuild: {args.rebuild}")
|
||||
print(f"Verbosity: {args.verbosity}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Building nsis7z plugin{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.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}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
# Print CPU and parallel build info
|
||||
@@ -824,12 +891,13 @@ Examples:
|
||||
total_time = time.time() - total_start_time
|
||||
|
||||
# Summary
|
||||
print("\n" + "=" * 50)
|
||||
print()
|
||||
all_success = all(success for _, success, _, _, _ in build_results)
|
||||
|
||||
if all_success:
|
||||
print("ALL BUILDS SUCCESSFUL!")
|
||||
print("=" * 50)
|
||||
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}{"="*50}{Colors.RESET}")
|
||||
print("\nPlugins copied to:")
|
||||
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'
|
||||
@@ -840,22 +908,24 @@ Examples:
|
||||
print()
|
||||
clean_build_artifacts(project_dir, configs_to_build)
|
||||
else:
|
||||
print("SOME BUILDS FAILED!")
|
||||
print("=" * 50)
|
||||
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}{"="*50}{Colors.RESET}")
|
||||
print("\nFailed configurations:")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
if not success:
|
||||
print(f" - {config.name}")
|
||||
|
||||
# Show timing summary
|
||||
print("\n" + "-" * 50)
|
||||
print("Build Summary:")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
status = "OK" if success else "FAIL"
|
||||
row_color = Colors.BRIGHT_GREEN if success else Colors.RED
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f" {status} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print("-" * 50)
|
||||
print(f"Total time: {format_time(total_time)}")
|
||||
print(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
# Pause if requested
|
||||
|
||||
@@ -21,6 +21,69 @@ from typing import List, Tuple, Optional
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Colors & Spinner
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class Colors:
|
||||
CYAN = "\033[36m"
|
||||
GREEN = "\033[32m"
|
||||
YELLOW = "\033[33m"
|
||||
RED = "\033[31m"
|
||||
GRAY = "\033[90m"
|
||||
BLUE = "\033[34m"
|
||||
RESET = "\033[0m"
|
||||
BOLD = "\033[1m"
|
||||
BRIGHT_GREEN = "\033[92m"
|
||||
BRIGHT_CYAN = "\033[96m"
|
||||
BRIGHT_WHITE = "\033[97m"
|
||||
BRIGHT_YELLOW = "\033[93m"
|
||||
BRIGHT_RED = "\033[91m"
|
||||
|
||||
|
||||
class Spinner:
|
||||
def __init__(self, message: str = "Building...", delay: float = 0.1, total: int = 0):
|
||||
self.spinner = ['\u280b', '\u2819', '\u2839', '\u2838', '\u283c', '\u2834', '\u2826', '\u2827', '\u2807', '\u280f']
|
||||
self.delay = delay
|
||||
self.message = message
|
||||
self.running = False
|
||||
self.thread = None
|
||||
self.start_time = time.time()
|
||||
|
||||
def update(self, current=None):
|
||||
pass
|
||||
|
||||
def _spin(self):
|
||||
idx = 0
|
||||
_block = '\u28ff'
|
||||
while self.running:
|
||||
elapsed = time.time() - self.start_time
|
||||
n_blocks = int(elapsed // 2)
|
||||
time_blocks = f"{Colors.YELLOW}{_block * n_blocks}{Colors.RESET}"
|
||||
spin_char = f"{Colors.YELLOW}{self.spinner[idx % len(self.spinner)]}{Colors.RESET}"
|
||||
msg = f"{Colors.BOLD}{Colors.CYAN}{self.message}{Colors.RESET}"
|
||||
time_str = f"{Colors.GREEN}{int(elapsed)}s{Colors.RESET}"
|
||||
sys.stdout.write(f"\r{msg} {time_str} {time_blocks}{spin_char} ")
|
||||
sys.stdout.flush()
|
||||
idx += 1
|
||||
time.sleep(self.delay)
|
||||
sys.stdout.write("\r" + " " * (len(self.message) + 80) + "\r")
|
||||
sys.stdout.flush()
|
||||
|
||||
def __enter__(self):
|
||||
if sys.stdout.isatty():
|
||||
self.running = True
|
||||
self.thread = threading.Thread(target=self._spin, daemon=True)
|
||||
self.thread.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
if self.running:
|
||||
self.running = False
|
||||
if self.thread:
|
||||
self.thread.join()
|
||||
|
||||
|
||||
class BuildConfig:
|
||||
"""Configuration for a single build target"""
|
||||
def __init__(self, name: str, config: str, platform: str, dest_dir: str):
|
||||
@@ -222,40 +285,40 @@ def get_memory_optimizations() -> List[str]:
|
||||
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||
"""Print CPU information for build optimization"""
|
||||
if not use_parallel:
|
||||
print("Build mode: Single-threaded")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Single-threaded{Colors.RESET}")
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||
return
|
||||
|
||||
cpu_info = get_cpu_info()
|
||||
optimal_threads = get_optimal_thread_count()
|
||||
|
||||
print("Build mode: Parallel")
|
||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||
|
||||
if cpu_info['has_hyperthreading']:
|
||||
print("Hyperthreading: ENABLED")
|
||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||
else:
|
||||
print("Hyperthreading: NOT AVAILABLE")
|
||||
print(f"Optimal threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
print(f"MSBuild threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}MSBuild threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (parallel, memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET} (parallel, memory, caching)")
|
||||
try:
|
||||
import psutil
|
||||
memory_gb = psutil.virtual_memory().total / (1024**3)
|
||||
print(f"Available memory: {memory_gb:.1f} GB")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.BRIGHT_WHITE}{memory_gb:.1f} GB{Colors.RESET}")
|
||||
except ImportError:
|
||||
print("Available memory: Unknown (install psutil for details)")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.GRAY}Unknown (install psutil for details){Colors.RESET}")
|
||||
else:
|
||||
print("Optimizations: DISABLED")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||
|
||||
if not cpu_info['has_psutil']:
|
||||
print("Note: Install 'psutil' for detailed CPU/memory info (pip install psutil)")
|
||||
print(f"{Colors.GRAY}Note: Install 'psutil' for detailed CPU/memory info (pip install psutil){Colors.RESET}")
|
||||
|
||||
print()
|
||||
|
||||
@@ -310,12 +373,12 @@ def build_configuration(
|
||||
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
||||
|
||||
if not capture_output:
|
||||
print(f"\n{'='*50}")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||
if counter:
|
||||
print(f"Building {config.name} [{counter}]")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||
else:
|
||||
print(f"Building {config.name}...")
|
||||
print('='*50)
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||
|
||||
# Execute build and measure time
|
||||
start_time = time.time()
|
||||
@@ -353,7 +416,7 @@ def copy_output(
|
||||
dest_dir = plugins_dir / config.dest_dir
|
||||
|
||||
if not output_file.exists():
|
||||
print(f"ERROR: {config.name} DLL not found at {output_file}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} {config.name} DLL not found at {output_file}")
|
||||
return False, 0, None
|
||||
|
||||
# Create destination directory
|
||||
@@ -364,16 +427,16 @@ def copy_output(
|
||||
dest_path = dest_dir / 'nsis7z.dll'
|
||||
shutil.copy2(output_file, dest_path)
|
||||
file_size = output_file.stat().st_size
|
||||
print(f"SUCCESS: {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
print(f"{Colors.BRIGHT_GREEN}SUCCESS:{Colors.RESET} {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
return True, file_size, dest_path
|
||||
except Exception as e:
|
||||
print(f"ERROR: Failed to copy {config.name}: {e}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} Failed to copy {config.name}: {e}")
|
||||
return False, 0, None
|
||||
|
||||
|
||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||
"""Clean up build artifacts"""
|
||||
print("\nCleaning build artifacts...")
|
||||
print(f"\n{Colors.CYAN}Cleaning build artifacts...{Colors.RESET}")
|
||||
|
||||
build_base_dir = project_dir / 'CPP' / '7zip' / 'Bundles' / 'Nsis7z' / 'Build'
|
||||
|
||||
@@ -387,11 +450,11 @@ def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None
|
||||
if dir_path.exists():
|
||||
try:
|
||||
shutil.rmtree(dir_path)
|
||||
print(f" - Cleaned: {dir_path.name}")
|
||||
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||
except Exception as e:
|
||||
print(f" - Failed to clean {dir_path.name}: {e}")
|
||||
print(f" {Colors.RED}- Failed to clean {dir_path.name}: {e}{Colors.RESET}")
|
||||
|
||||
print("Build artifacts cleaned successfully.")
|
||||
print(f"{Colors.BRIGHT_GREEN}Build artifacts cleaned successfully.{Colors.RESET}")
|
||||
|
||||
|
||||
def format_time(seconds: float) -> str:
|
||||
@@ -526,8 +589,8 @@ def _build_configs_parallel(
|
||||
in the same order as *configs*.
|
||||
"""
|
||||
n = len(configs)
|
||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
||||
print("=" * 50)
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||
|
||||
total_start = time.time()
|
||||
results_by_idx: dict = {}
|
||||
@@ -551,22 +614,26 @@ def _build_configs_parallel(
|
||||
|
||||
with _print_lock:
|
||||
all_ok = success and copy_ok
|
||||
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||
tag = "OK" if all_ok else "FAILED"
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f"[{tag}] {config.name} ({format_time(build_time)}) {size_str}")
|
||||
sys.stdout.write("\r" + " " * 80 + "\r")
|
||||
sys.stdout.flush()
|
||||
print(f"{tag_color}[{tag}]{Colors.RESET} {config.name} ({format_time(build_time)}) {size_str}")
|
||||
if dest_path:
|
||||
print(f" -> {dest_path}")
|
||||
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||
if not all_ok:
|
||||
copy_out = copy_buf.getvalue()
|
||||
if copy_out.strip():
|
||||
print(copy_out.rstrip())
|
||||
if captured.strip():
|
||||
print("--- Build output ---")
|
||||
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||
print(captured.rstrip())
|
||||
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
||||
|
||||
with Spinner(f"Building {n} configs in parallel...") as _spinner:
|
||||
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||
for fut in as_completed(futures):
|
||||
@@ -574,12 +641,12 @@ def _build_configs_parallel(
|
||||
if exc:
|
||||
idx = futures[fut]
|
||||
with _print_lock:
|
||||
print(f"ERROR: worker for config index {idx} raised: {exc}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} worker for config index {idx} raised: {exc}")
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||
|
||||
wall_time = time.time() - total_start
|
||||
print(f"\nAll {n} configs finished in {format_time(wall_time)} (wall clock)")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}All {n} configs finished in {Colors.BRIGHT_WHITE}{format_time(wall_time)}{Colors.CYAN} (wall clock){Colors.RESET}")
|
||||
return [results_by_idx[i] for i in range(n)]
|
||||
|
||||
def main():
|
||||
@@ -749,15 +816,15 @@ Examples:
|
||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||
|
||||
# Print header
|
||||
print("=" * 60)
|
||||
print(f"Building nsis7z plugin (VS2026) - {len(configs_to_build)} configuration(s)")
|
||||
print("=" * 60)
|
||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
||||
print(f"MSBuild: {msbuild_path}")
|
||||
print(f"Project: {project_file}")
|
||||
print(f"Plugins: {plugins_dir}")
|
||||
print(f"Rebuild: {args.rebuild}")
|
||||
print(f"Verbosity: {args.verbosity}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Building nsis7z plugin (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.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}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
# Print CPU and parallel build info
|
||||
@@ -851,12 +918,13 @@ Examples:
|
||||
total_time = time.time() - total_start_time
|
||||
|
||||
# Summary
|
||||
print("\n" + "=" * 50)
|
||||
print()
|
||||
all_success = all(success for _, success, _, _, _ in build_results)
|
||||
|
||||
if all_success:
|
||||
print("ALL BUILDS SUCCESSFUL!")
|
||||
print("=" * 50)
|
||||
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}{"="*50}{Colors.RESET}")
|
||||
print("\nPlugins copied to:")
|
||||
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'
|
||||
@@ -867,22 +935,24 @@ Examples:
|
||||
print()
|
||||
clean_build_artifacts(project_dir, configs_to_build)
|
||||
else:
|
||||
print("SOME BUILDS FAILED!")
|
||||
print("=" * 50)
|
||||
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}{"="*50}{Colors.RESET}")
|
||||
print("\nFailed configurations:")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
if not success:
|
||||
print(f" - {config.name}")
|
||||
|
||||
# Show timing summary
|
||||
print("\n" + "-" * 50)
|
||||
print("Build Summary:")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
status = "OK" if success else "FAIL"
|
||||
row_color = Colors.BRIGHT_GREEN if success else Colors.RED
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f" {status} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print("-" * 50)
|
||||
print(f"Total time: {format_time(total_time)}")
|
||||
print(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
# Pause if requested
|
||||
|
||||
@@ -24,6 +24,69 @@ from typing import List, Tuple, Optional
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Colors & Spinner
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class Colors:
|
||||
CYAN = "\033[36m"
|
||||
GREEN = "\033[32m"
|
||||
YELLOW = "\033[33m"
|
||||
RED = "\033[31m"
|
||||
GRAY = "\033[90m"
|
||||
BLUE = "\033[34m"
|
||||
RESET = "\033[0m"
|
||||
BOLD = "\033[1m"
|
||||
BRIGHT_GREEN = "\033[92m"
|
||||
BRIGHT_CYAN = "\033[96m"
|
||||
BRIGHT_WHITE = "\033[97m"
|
||||
BRIGHT_YELLOW = "\033[93m"
|
||||
BRIGHT_RED = "\033[91m"
|
||||
|
||||
|
||||
class Spinner:
|
||||
def __init__(self, message: str = "Building...", delay: float = 0.1, total: int = 0):
|
||||
self.spinner = ['\u280b', '\u2819', '\u2839', '\u2838', '\u283c', '\u2834', '\u2826', '\u2827', '\u2807', '\u280f']
|
||||
self.delay = delay
|
||||
self.message = message
|
||||
self.running = False
|
||||
self.thread = None
|
||||
self.start_time = time.time()
|
||||
|
||||
def update(self, current=None):
|
||||
pass
|
||||
|
||||
def _spin(self):
|
||||
idx = 0
|
||||
_block = '\u28ff'
|
||||
while self.running:
|
||||
elapsed = time.time() - self.start_time
|
||||
n_blocks = int(elapsed // 2)
|
||||
time_blocks = f"{Colors.YELLOW}{_block * n_blocks}{Colors.RESET}"
|
||||
spin_char = f"{Colors.YELLOW}{self.spinner[idx % len(self.spinner)]}{Colors.RESET}"
|
||||
msg = f"{Colors.BOLD}{Colors.CYAN}{self.message}{Colors.RESET}"
|
||||
time_str = f"{Colors.GREEN}{int(elapsed)}s{Colors.RESET}"
|
||||
sys.stdout.write(f"\r{msg} {time_str} {time_blocks}{spin_char} ")
|
||||
sys.stdout.flush()
|
||||
idx += 1
|
||||
time.sleep(self.delay)
|
||||
sys.stdout.write("\r" + " " * (len(self.message) + 80) + "\r")
|
||||
sys.stdout.flush()
|
||||
|
||||
def __enter__(self):
|
||||
if sys.stdout.isatty():
|
||||
self.running = True
|
||||
self.thread = threading.Thread(target=self._spin, daemon=True)
|
||||
self.thread.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
if self.running:
|
||||
self.running = False
|
||||
if self.thread:
|
||||
self.thread.join()
|
||||
|
||||
|
||||
class BuildConfig:
|
||||
"""Configuration for a single build target"""
|
||||
def __init__(self, name: str, config: str, platform: str, dest_dir: str):
|
||||
@@ -212,40 +275,40 @@ def get_memory_optimizations() -> List[str]:
|
||||
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||
"""Print CPU information for build optimization"""
|
||||
if not use_parallel:
|
||||
print("Build mode: Single-threaded")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Single-threaded{Colors.RESET}")
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||
return
|
||||
|
||||
cpu_info = get_cpu_info()
|
||||
optimal_threads = get_optimal_thread_count()
|
||||
|
||||
print("Build mode: Parallel")
|
||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
||||
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||
|
||||
if cpu_info['has_hyperthreading']:
|
||||
print("Hyperthreading: ENABLED")
|
||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||
else:
|
||||
print("Hyperthreading: NOT AVAILABLE")
|
||||
print(f"Optimal threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
print(f"MSBuild threads: {optimal_threads}")
|
||||
print(f"{Colors.CYAN}MSBuild threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET}")
|
||||
|
||||
if use_optimizations:
|
||||
print("Optimizations: ENABLED (parallel, memory, caching)")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET} (parallel, memory, caching)")
|
||||
try:
|
||||
import psutil
|
||||
memory_gb = psutil.virtual_memory().total / (1024 ** 3)
|
||||
print(f"Available memory: {memory_gb:.1f} GB")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.BRIGHT_WHITE}{memory_gb:.1f} GB{Colors.RESET}")
|
||||
except ImportError:
|
||||
print("Available memory: Unknown (install psutil for details)")
|
||||
print(f"{Colors.CYAN}Available memory:{Colors.RESET} {Colors.GRAY}Unknown (install psutil for details){Colors.RESET}")
|
||||
else:
|
||||
print("Optimizations: DISABLED")
|
||||
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||
|
||||
if not cpu_info['has_psutil']:
|
||||
print("Note: Install 'psutil' for detailed CPU/memory info (pip install psutil)")
|
||||
print(f"{Colors.GRAY}Note: Install 'psutil' for detailed CPU/memory info (pip install psutil){Colors.RESET}")
|
||||
|
||||
print()
|
||||
|
||||
@@ -295,12 +358,12 @@ def build_configuration(
|
||||
cmd.append('/p:MSBuildCacheEnabled=true')
|
||||
|
||||
if not capture_output:
|
||||
print(f"\n{'=' * 50}")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'=' * 50}{Colors.RESET}")
|
||||
if counter:
|
||||
print(f"Building {config.name} [{counter}]")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||
else:
|
||||
print(f"Building {config.name}...")
|
||||
print('=' * 50)
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'=' * 50}{Colors.RESET}")
|
||||
|
||||
start_time = time.time()
|
||||
try:
|
||||
@@ -337,7 +400,7 @@ def copy_output(
|
||||
dest_dir = plugins_dir / config.dest_dir
|
||||
|
||||
if not output_file.exists():
|
||||
print(f"ERROR: {config.name} DLL not found at {output_file}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} {config.name} DLL not found at {output_file}")
|
||||
return False, 0, None
|
||||
|
||||
dest_dir.mkdir(parents=True, exist_ok=True)
|
||||
@@ -346,16 +409,16 @@ def copy_output(
|
||||
dest_path = dest_dir / 'nsis7z.dll'
|
||||
shutil.copy2(output_file, dest_path)
|
||||
file_size = output_file.stat().st_size
|
||||
print(f"SUCCESS: {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
print(f"{Colors.BRIGHT_GREEN}SUCCESS:{Colors.RESET} {config.name} - {file_size:,} bytes - Copied to {dest_dir}")
|
||||
return True, file_size, dest_path
|
||||
except Exception as e:
|
||||
print(f"ERROR: Failed to copy {config.name}: {e}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} Failed to copy {config.name}: {e}")
|
||||
return False, 0, None
|
||||
|
||||
|
||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||
"""Clean up build artifacts"""
|
||||
print("\nCleaning build artifacts...")
|
||||
print(f"\n{Colors.CYAN}Cleaning build artifacts...{Colors.RESET}")
|
||||
|
||||
build_base_dir = (
|
||||
project_dir / 'CPP' / '7zip' / 'Bundles' / 'Nsis7z' / 'Build'
|
||||
@@ -367,11 +430,11 @@ def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None
|
||||
if dir_path.exists():
|
||||
try:
|
||||
shutil.rmtree(dir_path)
|
||||
print(f" - Cleaned: {dir_path.name}")
|
||||
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||
except Exception as e:
|
||||
print(f" - Failed to clean {dir_path.name}: {e}")
|
||||
print(f" {Colors.RED}- Failed to clean {dir_path.name}: {e}{Colors.RESET}")
|
||||
|
||||
print("Build artifacts cleaned successfully.")
|
||||
print(f"{Colors.BRIGHT_GREEN}Build artifacts cleaned successfully.{Colors.RESET}")
|
||||
|
||||
|
||||
def format_time(seconds: float) -> str:
|
||||
@@ -462,8 +525,8 @@ def _build_configs_parallel(
|
||||
) -> list:
|
||||
"""Build all configurations simultaneously, printing output atomically."""
|
||||
n = len(configs)
|
||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
||||
print("=" * 50)
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||
|
||||
total_start = time.time()
|
||||
results_by_idx: dict = {}
|
||||
@@ -486,22 +549,26 @@ def _build_configs_parallel(
|
||||
|
||||
with _print_lock:
|
||||
all_ok = success and copy_ok
|
||||
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||
tag = "OK" if all_ok else "FAILED"
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f"[{tag}] {config.name} ({format_time(build_time)}) {size_str}")
|
||||
sys.stdout.write("\r" + " " * 80 + "\r")
|
||||
sys.stdout.flush()
|
||||
print(f"{tag_color}[{tag}]{Colors.RESET} {config.name} ({format_time(build_time)}) {size_str}")
|
||||
if dest_path:
|
||||
print(f" -> {dest_path}")
|
||||
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||
if not all_ok:
|
||||
copy_out = copy_buf.getvalue()
|
||||
if copy_out.strip():
|
||||
print(copy_out.rstrip())
|
||||
if captured.strip():
|
||||
print("--- Build output ---")
|
||||
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||
print(captured.rstrip())
|
||||
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
||||
|
||||
with Spinner(f"Building {n} configs in parallel...") as _spinner:
|
||||
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||
for fut in as_completed(futures):
|
||||
@@ -509,12 +576,12 @@ def _build_configs_parallel(
|
||||
if exc:
|
||||
idx = futures[fut]
|
||||
with _print_lock:
|
||||
print(f"ERROR: worker for config index {idx} raised: {exc}")
|
||||
print(f"{Colors.RED}ERROR:{Colors.RESET} worker for config index {idx} raised: {exc}")
|
||||
with idx_lock:
|
||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||
|
||||
wall_time = time.time() - total_start
|
||||
print(f"\nAll {n} configs finished in {format_time(wall_time)} (wall clock)")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}All {n} configs finished in {Colors.BRIGHT_WHITE}{format_time(wall_time)}{Colors.CYAN} (wall clock){Colors.RESET}")
|
||||
return [results_by_idx[i] for i in range(n)]
|
||||
|
||||
|
||||
@@ -605,18 +672,15 @@ Examples:
|
||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||
|
||||
# Print header
|
||||
print("=" * 60)
|
||||
print(
|
||||
f"Building nsis7z plugin (7-Zip ZS, VS2026)"
|
||||
f" - {len(configs_to_build)} configuration(s)"
|
||||
)
|
||||
print("=" * 60)
|
||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
||||
print(f"MSBuild: {msbuild_path}")
|
||||
print(f"Project: {project_file}")
|
||||
print(f"Plugins: {plugins_dir}")
|
||||
print(f"Rebuild: {args.rebuild}")
|
||||
print(f"Verbosity: {args.verbosity}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Building nsis7z plugin (7-Zip ZS, 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.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}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
use_optimizations = not args.no_optimizations
|
||||
@@ -656,12 +720,13 @@ Examples:
|
||||
total_time = time.time() - total_start_time
|
||||
|
||||
# Summary
|
||||
print("\n" + "=" * 50)
|
||||
print()
|
||||
all_success = all(success for _, success, _, _, _ in build_results)
|
||||
|
||||
if all_success:
|
||||
print("ALL BUILDS SUCCESSFUL!")
|
||||
print("=" * 50)
|
||||
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}{"="*50}{Colors.RESET}")
|
||||
print("\nPlugins copied to:")
|
||||
for config, _, build_time, file_size, dest_path in build_results:
|
||||
dest = dest_path or plugins_dir / config.dest_dir / 'nsis7z.dll'
|
||||
@@ -670,21 +735,23 @@ Examples:
|
||||
print()
|
||||
clean_build_artifacts(project_dir, configs_to_build)
|
||||
else:
|
||||
print("SOME BUILDS FAILED!")
|
||||
print("=" * 50)
|
||||
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}{"="*50}{Colors.RESET}")
|
||||
print("\nFailed configurations:")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
if not success:
|
||||
print(f" - {config.name}")
|
||||
|
||||
print("\n" + "-" * 50)
|
||||
print("Build Summary:")
|
||||
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||
for config, success, build_time, file_size, dest_path in build_results:
|
||||
status = "OK" if success else "FAIL"
|
||||
row_color = Colors.BRIGHT_GREEN if success else Colors.RED
|
||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
||||
print(f" {status} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print("-" * 50)
|
||||
print(f"Total time: {format_time(total_time)}")
|
||||
print(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||
print()
|
||||
|
||||
if args.pause:
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
(void)lpReserved;
|
||||
g_hInstance2=(HINSTANCE)hInst;
|
||||
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
|
||||
@@ -27,12 +27,14 @@ using namespace NDir;
|
||||
|
||||
extern HWND g_hwndProgress;
|
||||
|
||||
static const UInt64 k_SizeUnknown = (UInt64)(Int64)-1;
|
||||
|
||||
void CExtractCallbackConsole::UpdateProgress()
|
||||
{
|
||||
// Prima controlla se c'è il callback con filename (nuova funzione)
|
||||
if (ProgressWithFileHandler != NULL)
|
||||
{
|
||||
if (completedSize != -1 || totalSize > 0)
|
||||
if (completedSize != k_SizeUnknown || totalSize > 0)
|
||||
ProgressWithFileHandler(completedSize, totalSize, CurrentFileName.Ptr());
|
||||
else
|
||||
ProgressWithFileHandler(0, 0, CurrentFileName.Ptr());
|
||||
@@ -40,14 +42,14 @@ void CExtractCallbackConsole::UpdateProgress()
|
||||
// Altrimenti usa il callback originale (per compatibilitĂ )
|
||||
else if (ProgressHandler != NULL)
|
||||
{
|
||||
if (completedSize != -1 || totalSize > 0)
|
||||
if (completedSize != k_SizeUnknown || totalSize > 0)
|
||||
ProgressHandler(completedSize, totalSize);
|
||||
else
|
||||
ProgressHandler(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64 val)
|
||||
Z7_COM7F_IMF(CExtractCallbackConsole::SetTotal(UInt64 val))
|
||||
{
|
||||
totalSize = val;
|
||||
UpdateProgress();
|
||||
@@ -56,7 +58,7 @@ STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64 val)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *val)
|
||||
Z7_COM7F_IMF(CExtractCallbackConsole::SetCompleted(const UInt64 *val))
|
||||
{
|
||||
completedSize = *val;
|
||||
UpdateProgress();
|
||||
@@ -65,31 +67,35 @@ STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *val)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
|
||||
Z7_COM7F_IMF(CExtractCallbackConsole::AskOverwrite(
|
||||
const wchar_t *existName, const FILETIME *, const UInt64 *,
|
||||
const wchar_t *newName, const FILETIME *, const UInt64 *,
|
||||
Int32 *answer)
|
||||
Int32 *answer))
|
||||
{
|
||||
(void)existName; (void)newName;
|
||||
*answer = NOverwriteAnswer::kYesToAll;
|
||||
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
|
||||
CurrentFileName = name;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
|
||||
Z7_COM7F_IMF(CExtractCallbackConsole::MessageError(const wchar_t *message))
|
||||
{
|
||||
(void)message;
|
||||
NumFileErrorsInCurrentArchive++;
|
||||
NumFileErrors++;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encrypted)
|
||||
Z7_COM7F_IMF(CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encrypted))
|
||||
{
|
||||
(void)encrypted;
|
||||
switch(opRes)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kOK:
|
||||
@@ -113,7 +119,7 @@ HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
|
||||
Z7_COM7F_IMF(CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password))
|
||||
{
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
@@ -127,6 +133,7 @@ STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
|
||||
|
||||
HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
|
||||
{
|
||||
(void)name; (void)testMode;
|
||||
NumArchives++;
|
||||
NumFileErrorsInCurrentArchive = 0;
|
||||
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)
|
||||
{
|
||||
(void)codecs; (void)arcLink; (void)name;
|
||||
if (result != S_OK)
|
||||
{
|
||||
NumArchiveErrors++;
|
||||
|
||||
@@ -3,7 +3,13 @@
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <Windows.h>
|
||||
#include "7zip/Bundles/Nsis7z/pluginapi.h"
|
||||
#endif
|
||||
#endif
|
||||
#include "../../Bundles/Nsis7z/pluginapi.h"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user