Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2491f0eba1 | |||
| 0053ce8fcc | |||
| 13787d1af9 | |||
| 62e066c754 | |||
| e4362a3d02 | |||
| 3c87501c40 | |||
| 68d949aa5b | |||
| da6bf4fd04 | |||
| f973bf3107 | |||
| 4f4508ccc3 | |||
| 84125ef688 | |||
| c10249d171 | |||
| 576706dc17 | |||
| b5d635d96f | |||
| 00263ec4ba | |||
| 6e91c0ac31 | |||
| df1e68b378 | |||
| e39129c300 | |||
| e64386ebe5 | |||
| cda44e07a8 | |||
| 0faf0fb360 | |||
| 9be53c7e22 | |||
| d80b025219 | |||
| 91fe17cda2 |
+48
-18
@@ -8,23 +8,26 @@
|
|||||||
# Trigger:
|
# Trigger:
|
||||||
# - push su main (incluso quello propagato dal mirror Gitea)
|
# - push su main (incluso quello propagato dal mirror Gitea)
|
||||||
# - PR aperte su GitHub
|
# - PR aperte su GitHub
|
||||||
# - run manuale via UI
|
# - run manuale via UI (senza input)
|
||||||
|
|
||||||
name: Build
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches:
|
||||||
|
- main
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches:
|
||||||
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
if: ${{ false }}
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@@ -32,24 +35,17 @@ jobs:
|
|||||||
config: [x86-ansi, x86-unicode, x64-unicode]
|
config: [x86-ansi, x86-unicode, x64-unicode]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
|
|
||||||
- name: Setup MSBuild
|
- name: Setup MSBuild
|
||||||
uses: microsoft/setup-msbuild@v2
|
uses: microsoft/setup-msbuild@v3
|
||||||
|
|
||||||
- name: Read VERSION
|
|
||||||
id: version
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
$v = (Get-Content VERSION -Raw).Trim()
|
|
||||||
"version=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
|
|
||||||
|
|
||||||
- name: Build ${{ matrix.config }}
|
- name: Build ${{ matrix.config }}
|
||||||
run: python build_plugin.py --configs ${{ matrix.config }} --verbosity normal
|
run: python build_plugin.py --configs ${{ matrix.config }} --verbosity normal
|
||||||
@@ -58,15 +54,49 @@ jobs:
|
|||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
$map = @{ 'x86-ansi' = 'x86-ansi'; 'x86-unicode' = 'x86-unicode'; 'x64-unicode' = 'amd64-unicode' }
|
$map = @{ 'x86-ansi' = 'x86-ansi'; 'x86-unicode' = 'x86-unicode'; 'x64-unicode' = 'amd64-unicode' }
|
||||||
$src = "plugins\$($map['${{ matrix.config }}'])\nsis7z.dll"
|
$dir = $map['${{ matrix.config }}']
|
||||||
$dst = "dist\${{ matrix.config }}"
|
$src = "plugins\$dir\nsis7z.dll"
|
||||||
|
$dst = "dll-bundle\$dir"
|
||||||
New-Item -ItemType Directory -Force -Path $dst | Out-Null
|
New-Item -ItemType Directory -Force -Path $dst | Out-Null
|
||||||
Copy-Item $src $dst
|
Copy-Item $src $dst
|
||||||
|
|
||||||
- name: Upload DLL
|
- name: Upload DLL
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-${{ steps.version.outputs.version }}-${{ matrix.config }}
|
name: dll-win-${{ matrix.config }}
|
||||||
path: dist/**
|
path: dll-bundle/**
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
|
||||||
|
build-linux:
|
||||||
|
if: ${{ false }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
config: [x86-ansi, x86-unicode, x64-unicode]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v6
|
||||||
|
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 }} --verbose
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+251
-45
@@ -1,18 +1,27 @@
|
|||||||
# Release (GitHub) — pipeline release primaria
|
# Release (GitHub) — pipeline release primaria
|
||||||
#
|
#
|
||||||
# Triggerata quando un tag v* viene propagato dal mirror Gitea.
|
# Strategia hosting:
|
||||||
# Costruisce gli artifact per tutte le architetture e crea la GitHub Release.
|
# - Repo primario su Gitea (push iniziale)
|
||||||
|
# - Push mirror automatico Gitea -> GitHub
|
||||||
|
# - GitHub esegue TUTTA la CI (Gitea non esegue Actions)
|
||||||
|
#
|
||||||
|
# Trigger:
|
||||||
|
# - push di un tag v* (propagato dal mirror Gitea)
|
||||||
|
#
|
||||||
|
# - run manuale via UI (con input 'tag')
|
||||||
|
|
||||||
name: Release
|
name: Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags: ['v*']
|
tags:
|
||||||
|
- 'v*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
description: 'Tag versione (es. v1.7.0)'
|
description: 'Tag versione (es. v1.7.0)'
|
||||||
required: true
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -21,79 +30,276 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
config: [x86-ansi, x86-unicode, x64-unicode]
|
config: [x86-ansi, x86-unicode, x64-unicode]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- uses: actions/setup-python@v5
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
|
|
||||||
- uses: microsoft/setup-msbuild@v2
|
- name: Setup MSBuild
|
||||||
|
uses: microsoft/setup-msbuild@v3
|
||||||
|
|
||||||
- name: Build ${{ matrix.config }}
|
- name: Build ${{ matrix.config }}
|
||||||
run: python build_plugin.py --config ${{ matrix.config }}
|
run: python build_plugin.py --configs ${{ matrix.config }} --verbosity normal
|
||||||
|
|
||||||
- name: Determine version & arch
|
- name: Collect DLL
|
||||||
id: meta
|
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
$tag = "${{ github.ref_name }}"
|
|
||||||
if ([string]::IsNullOrEmpty($tag) -or $tag -eq "main") { $tag = "${{ inputs.tag }}" }
|
|
||||||
$v = $tag -replace '^v',''
|
|
||||||
$map = @{ 'x86-ansi' = 'x86-ansi'; 'x86-unicode' = 'x86-unicode'; 'x64-unicode' = 'amd64-unicode' }
|
$map = @{ 'x86-ansi' = 'x86-ansi'; 'x86-unicode' = 'x86-unicode'; 'x64-unicode' = 'amd64-unicode' }
|
||||||
$dir = $map['${{ matrix.config }}']
|
$dir = $map['${{ matrix.config }}']
|
||||||
echo "version=$v" >> $env:GITHUB_OUTPUT
|
$src = "plugins\$dir\nsis7z.dll"
|
||||||
echo "tag=$tag" >> $env:GITHUB_OUTPUT
|
$dst = "dll-bundle\$dir"
|
||||||
echo "dir=$dir" >> $env:GITHUB_OUTPUT
|
New-Item -ItemType Directory -Force -Path $dst | Out-Null
|
||||||
|
Copy-Item $src $dst
|
||||||
|
|
||||||
- name: Package
|
- name: Upload DLL
|
||||||
shell: pwsh
|
uses: actions/upload-artifact@v7
|
||||||
run: |
|
|
||||||
$name = "${{ github.event.repository.name }}-${{ steps.meta.outputs.version }}-${{ steps.meta.outputs.dir }}"
|
|
||||||
$stage = "stage/$name"
|
|
||||||
New-Item -ItemType Directory -Force -Path $stage | Out-Null
|
|
||||||
Copy-Item "dist/${{ steps.meta.outputs.dir }}/*" $stage -Recurse
|
|
||||||
Copy-Item README.md, LICENSE, VERSION, CHANGELOG.md $stage
|
|
||||||
if (Test-Path "include") { Copy-Item "include" $stage -Recurse }
|
|
||||||
if (Test-Path "examples") { Copy-Item "examples" $stage -Recurse }
|
|
||||||
Compress-Archive -Path "$stage/*" -DestinationPath "$name.zip" -Force
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: pkg-${{ matrix.config }}
|
name: dll-win-${{ matrix.config }}
|
||||||
path: '*.zip'
|
path: dll-bundle/**
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
build-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
config: [x86-ansi, x86-unicode, x64-unicode]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v6
|
||||||
|
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 }} --verbose
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
needs: build
|
needs: [build, build-linux]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- name: Resolve release tag
|
||||||
|
id: tag
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
tag="${{ github.ref_name }}"
|
||||||
|
if [ -z "$tag" ] || [ "$tag" = "main" ]; then
|
||||||
|
tag="${{ inputs.tag }}"
|
||||||
|
fi
|
||||||
|
if [ -z "$tag" ]; then
|
||||||
|
echo "Tag non disponibile. Imposta l'input 'tag' (es. v2.2.1)." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
case "$tag" in
|
||||||
|
v*) ;;
|
||||||
|
*) tag="v$tag" ;;
|
||||||
|
esac
|
||||||
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Download DLL artifacts
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
with:
|
with:
|
||||||
path: artifacts
|
path: dll-bundle
|
||||||
|
pattern: dll-win-*
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Extract changelog section
|
||||||
|
run: |
|
||||||
|
tag="${{ steps.tag.outputs.tag }}"
|
||||||
|
version="${tag#v}"
|
||||||
|
awk -v ver="[$version]" '
|
||||||
|
/^## / && index($0, ver) { found=1; next }
|
||||||
|
found && /^## / { exit }
|
||||||
|
found { print }
|
||||||
|
' CHANGELOG.md > release_body.md
|
||||||
|
# Append Gitea notice
|
||||||
|
echo "" >> release_body.md
|
||||||
|
echo "---" >> release_body.md
|
||||||
|
echo "_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._" >> release_body.md
|
||||||
|
|
||||||
|
- name: Package plugins ZIP
|
||||||
|
id: pkg
|
||||||
|
run: |
|
||||||
|
tag="${{ steps.tag.outputs.tag }}"
|
||||||
|
version="${tag#v}"
|
||||||
|
zip_name="${{ github.event.repository.name }}-${version}-plugins.zip"
|
||||||
|
(cd dll-bundle && zip -r "../$zip_name" .)
|
||||||
|
echo "zip_name=$zip_name" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: SHA256SUMS
|
- name: SHA256SUMS
|
||||||
run: |
|
run: |
|
||||||
cd artifacts
|
sha256sum "${{ steps.pkg.outputs.zip_name }}" > SHA256SUMS.txt
|
||||||
sha256sum *.zip > SHA256SUMS.txt
|
|
||||||
cat SHA256SUMS.txt
|
cat SHA256SUMS.txt
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v3
|
||||||
with:
|
with:
|
||||||
|
tag_name: ${{ steps.tag.outputs.tag }}
|
||||||
|
name: ${{ steps.tag.outputs.tag }}
|
||||||
files: |
|
files: |
|
||||||
artifacts/*.zip
|
${{ steps.pkg.outputs.zip_name }}
|
||||||
artifacts/SHA256SUMS.txt
|
SHA256SUMS.txt
|
||||||
generate_release_notes: true
|
body_path: release_body.md
|
||||||
body: |
|
|
||||||
**Repository primario**: vedi link Gitea nel README.
|
- name: Update Gitea Release and upload assets
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
GITEA_TAG: ${{ steps.tag.outputs.tag }}
|
||||||
|
ZIP_NAME: ${{ steps.pkg.outputs.zip_name }}
|
||||||
|
run: |
|
||||||
|
python3 - <<'PY'
|
||||||
|
import json
|
||||||
|
import mimetypes
|
||||||
|
import os
|
||||||
|
import urllib.error
|
||||||
|
import urllib.request
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
base = "https://gitea.emulab.it/api/v1"
|
||||||
|
repo = "Simone/nsis-plugin-ns7zip"
|
||||||
|
tag = os.environ.get("GITEA_TAG", "").strip()
|
||||||
|
token = os.environ.get("GITEA_TOKEN", "").strip()
|
||||||
|
zip_name = os.environ.get("ZIP_NAME", "").strip()
|
||||||
|
|
||||||
|
if not tag:
|
||||||
|
raise SystemExit("Tag non disponibile: imposta input 'tag' in workflow_dispatch")
|
||||||
|
if not token:
|
||||||
|
raise SystemExit("GITEA_TOKEN is missing or empty")
|
||||||
|
|
||||||
|
with open("release_body.md", "r", encoding="utf-8") as f:
|
||||||
|
body = f.read()
|
||||||
|
|
||||||
|
def request(method, path, payload=None, auth_scheme="token"):
|
||||||
|
data = json.dumps(payload).encode("utf-8") if payload is not None else None
|
||||||
|
req = urllib.request.Request(
|
||||||
|
f"{base}{path}",
|
||||||
|
data=data,
|
||||||
|
method=method,
|
||||||
|
headers={
|
||||||
|
"Authorization": f"{auth_scheme} {token}",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Accept": "application/json",
|
||||||
|
"User-Agent": "GitHubActions-GiteaReleaseSync/1.0",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
with urllib.request.urlopen(req) as resp:
|
||||||
|
return json.loads(resp.read().decode("utf-8"))
|
||||||
|
|
||||||
|
def upload_asset(rid, path, auth_scheme):
|
||||||
|
p = Path(path)
|
||||||
|
mime = mimetypes.guess_type(p.name)[0] or "application/octet-stream"
|
||||||
|
data = p.read_bytes()
|
||||||
|
boundary = "----FormBoundary7MA4YWxkTrZu0gW"
|
||||||
|
body_parts = (
|
||||||
|
f"--{boundary}\r\n"
|
||||||
|
f'Content-Disposition: form-data; name="attachment"; filename="{p.name}"\r\n'
|
||||||
|
f"Content-Type: {mime}\r\n\r\n"
|
||||||
|
).encode() + data + f"\r\n--{boundary}--\r\n".encode()
|
||||||
|
req = urllib.request.Request(
|
||||||
|
f"{base}/repos/{repo}/releases/{rid}/assets?name={p.name}",
|
||||||
|
data=body_parts,
|
||||||
|
method="POST",
|
||||||
|
headers={
|
||||||
|
"Authorization": f"{auth_scheme} {token}",
|
||||||
|
"Content-Type": f"multipart/form-data; boundary={boundary}",
|
||||||
|
"User-Agent": "GitHubActions-GiteaReleaseSync/1.0",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
with urllib.request.urlopen(req) as resp:
|
||||||
|
return json.loads(resp.read().decode("utf-8"))
|
||||||
|
|
||||||
|
auth_scheme = None
|
||||||
|
last_error = None
|
||||||
|
for scheme in ("token", "Bearer"):
|
||||||
|
try:
|
||||||
|
user = request("GET", "/user", auth_scheme=scheme)
|
||||||
|
auth_scheme = scheme
|
||||||
|
print(f"Gitea auth OK via '{scheme}' as user: {user.get('login', '<unknown>')}")
|
||||||
|
break
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
try:
|
||||||
|
details = e.read().decode("utf-8", errors="replace")
|
||||||
|
except Exception:
|
||||||
|
details = ""
|
||||||
|
last_error = f"HTTP {e.code} {e.reason} ({scheme}) {details}".strip()
|
||||||
|
|
||||||
|
if not auth_scheme:
|
||||||
|
raise SystemExit(
|
||||||
|
"Gitea authentication failed for both 'token' and 'Bearer'. "
|
||||||
|
"Check secret GITEA_TOKEN value and permissions (Repository Read+Write). "
|
||||||
|
f"Last error: {last_error}"
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
release = request("GET", f"/repos/{repo}/releases/tags/{tag}", auth_scheme=auth_scheme)
|
||||||
|
rid = release["id"]
|
||||||
|
request("PATCH", f"/repos/{repo}/releases/{rid}", {"body": body}, auth_scheme=auth_scheme)
|
||||||
|
print(f"Updated existing Gitea release id={rid} for tag {tag}")
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
if e.code != 404:
|
||||||
|
try:
|
||||||
|
details = e.read().decode("utf-8", errors="replace")
|
||||||
|
except Exception:
|
||||||
|
details = ""
|
||||||
|
raise SystemExit(f"Gitea release lookup/update failed: HTTP {e.code} {e.reason}. {details}".strip())
|
||||||
|
|
||||||
|
created = request(
|
||||||
|
"POST",
|
||||||
|
f"/repos/{repo}/releases",
|
||||||
|
{
|
||||||
|
"tag_name": tag,
|
||||||
|
"name": tag,
|
||||||
|
"body": body,
|
||||||
|
"draft": False,
|
||||||
|
"prerelease": False,
|
||||||
|
},
|
||||||
|
auth_scheme=auth_scheme,
|
||||||
|
)
|
||||||
|
rid = created["id"]
|
||||||
|
print(f"Created Gitea release id={rid} for tag {tag}")
|
||||||
|
|
||||||
|
# Rimuovi asset giĂ presenti con lo stesso nome (retag idempotente)
|
||||||
|
existing = request("GET", f"/repos/{repo}/releases/{rid}/assets", auth_scheme=auth_scheme)
|
||||||
|
upload_names = {zip_name, "SHA256SUMS.txt"}
|
||||||
|
for asset in existing:
|
||||||
|
if asset["name"] in upload_names:
|
||||||
|
request("DELETE", f"/repos/{repo}/releases/assets/{asset['id']}", auth_scheme=auth_scheme)
|
||||||
|
print(f"Deleted existing asset: {asset['name']}")
|
||||||
|
|
||||||
|
# Carica ZIP e SHA256SUMS
|
||||||
|
for f in [zip_name, "SHA256SUMS.txt"]:
|
||||||
|
if Path(f).exists():
|
||||||
|
result = upload_asset(rid, f, auth_scheme)
|
||||||
|
print(f"Uploaded {f} -> {result.get('browser_download_url', result.get('id'))}")
|
||||||
|
else:
|
||||||
|
print(f"WARNING: {f} not found, skipping upload")
|
||||||
|
PY
|
||||||
|
|
||||||
Il mirror GitHub è generato automaticamente dal repo Gitea (sorgente di verità ).
|
|
||||||
Per issue e PR aprire ticket sul repository primario Gitea.
|
|
||||||
|
|||||||
+34
-1
@@ -7,6 +7,36 @@ e il progetto aderisce al [Semantic Versioning](https://semver.org/spec/v2.0.0.h
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [2.2.2] — 2026-05-02
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `tools/update_gitea_releases.py`: one-shot script to backfill Gitea release bodies with CHANGELOG content via the Gitea API
|
||||||
|
- `tools/release-notes/`: per-version Markdown snippets used by the backfill script
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Release workflow now extracts the relevant CHANGELOG section and uses it as the GitHub Release body (`body_path`)
|
||||||
|
- Release workflow adds a step to update the corresponding Gitea release body via API (`GITEA_TOKEN` secret)
|
||||||
|
- All GitHub Actions upgraded to node24-native major versions (no more Node 20 deprecation warnings)
|
||||||
|
|
||||||
|
## [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.2.0] — 2026-05-02
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Linux MinGW-w64 cross-build support in `build_plugin.py` via `--host linux`
|
||||||
|
- `tools/linux/build_plugin_linux.py` for standalone Linux builds
|
||||||
|
- Color output and progress spinner in all legacy build scripts
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- `build_plugin.py` now supports both Windows (MSBuild) and Linux (MinGW-w64) targets
|
||||||
|
- Windows build-script f-string fixes
|
||||||
|
|
||||||
## [2.1.0] — 2026-04-30
|
## [2.1.0] — 2026-04-30
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -36,7 +66,10 @@ e il progetto aderisce al [Semantic Versioning](https://semver.org/spec/v2.0.0.h
|
|||||||
- CI/CD via GitHub Actions (mirror automatico Gitea → GitHub)
|
- CI/CD via GitHub Actions (mirror automatico Gitea → GitHub)
|
||||||
- Documentazione completa (README, CONTRIBUTING, SECURITY)
|
- 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.2...HEAD
|
||||||
|
[2.2.2]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/compare/v2.2.1...v2.2.2
|
||||||
|
[2.2.1]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/compare/v2.2.0...v2.2.1
|
||||||
|
[2.2.0]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/compare/v2.1.0...v2.2.0
|
||||||
[2.1.0]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/compare/v2.0.1...v2.1.0
|
[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.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
|
[2.0.0]: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip/releases/tag/v2.0.0
|
||||||
|
|||||||
@@ -61,21 +61,46 @@ python build_plugin.py --7zip-version 25.01
|
|||||||
# Specific toolset (2022|2026|auto)
|
# Specific toolset (2022|2026|auto)
|
||||||
python build_plugin.py --toolset 2022
|
python build_plugin.py --toolset 2022
|
||||||
|
|
||||||
|
# Linux host path (cross-build with MinGW-w64, 26.00)
|
||||||
|
python build_plugin.py --host linux
|
||||||
|
|
||||||
# Print version and exit
|
# Print version and exit
|
||||||
python build_plugin.py --version
|
python build_plugin.py --version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Linux notes:
|
||||||
|
- Local Linux path currently supports `--7zip-version 26.00`.
|
||||||
|
- Requires MinGW-w64 toolchains (`x86_64-w64-mingw32-*` and `i686-w64-mingw32-*`) and `make`.
|
||||||
|
|
||||||
## Repository Structure
|
## Repository Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
ns7zip/
|
nsis-plugin-ns7zip/
|
||||||
├── build_plugin.py # Unified build script (all versions)
|
├── build_plugin.py # Unified build script (all versions)
|
||||||
|
├── build_zstd.cmd # Build script for 7-zip-zstd variant
|
||||||
├── rebuild_nsis7z1900-src.ps1 # Rebuilds 19.00 sources
|
├── rebuild_nsis7z1900-src.ps1 # Rebuilds 19.00 sources
|
||||||
├── 7zip-19.00/ # 7-Zip 19.00 modified
|
├── versions/
|
||||||
├── 7zip-25.01/ # 7-Zip 25.01 modified (ZIP + NSIS handler)
|
│ ├── 19.00/ # 7-Zip 19.00 modified
|
||||||
└── 7zip-26.00/ # 7-Zip 26.00 modified (ZIP + NSIS handler)
|
│ ├── 25.01/ # 7-Zip 25.01 modified (ZIP + NSIS handler)
|
||||||
|
│ ├── 26.00/ # 7-Zip 26.00 modified (ZIP + NSIS handler)
|
||||||
|
│ └── 7-zip-zstd/ # 7-Zip zstd fork (submodule)
|
||||||
|
├── plugins/ # Compiled DLLs output
|
||||||
|
├── tools/
|
||||||
|
│ ├── fix_vcxproj.py # Project file patcher
|
||||||
|
│ ├── update_gitea_releases.py # Backfill Gitea release bodies (one-shot)
|
||||||
|
│ ├── release-notes/ # Per-version Markdown snippets
|
||||||
|
│ ├── linux/ # Linux-specific build helpers
|
||||||
|
│ └── legacy/ # Old per-version build scripts
|
||||||
|
└── .github/workflows/
|
||||||
|
├── build.yml # CI: Windows + Linux matrix build
|
||||||
|
└── release.yml # Release: build artifacts + publish to GitHub & Gitea
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## CI / Release Workflow
|
||||||
|
|
||||||
|
- **build.yml** — runs on every push/PR; builds all three configs on Windows (MSBuild) and Linux (MinGW-w64) in parallel.
|
||||||
|
- **release.yml** — triggered by a `v*` tag push; builds and packages artifacts, creates a GitHub Release with the relevant CHANGELOG section as body, and updates the corresponding Gitea release body via API (`GITEA_TOKEN` secret required).
|
||||||
|
|
||||||
## Changes from Original
|
## Changes from Original
|
||||||
|
|
||||||
### NSIS Archive Handler (25.01, 26.00)
|
### NSIS Archive Handler (25.01, 26.00)
|
||||||
|
|||||||
+33
-4
@@ -61,21 +61,46 @@ python build_plugin.py --7zip-version 25.01
|
|||||||
# Toolset specifico (2022|2026|auto)
|
# Toolset specifico (2022|2026|auto)
|
||||||
python build_plugin.py --toolset 2022
|
python build_plugin.py --toolset 2022
|
||||||
|
|
||||||
|
# Path Linux (cross-build con MinGW-w64, 26.00)
|
||||||
|
python build_plugin.py --host linux
|
||||||
|
|
||||||
# Stampa versione ed esce
|
# Stampa versione ed esce
|
||||||
python build_plugin.py --version
|
python build_plugin.py --version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note Linux:
|
||||||
|
- Il path Linux locale supporta attualmente `--7zip-version 26.00`.
|
||||||
|
- Richiede toolchain MinGW-w64 (`x86_64-w64-mingw32-*` e `i686-w64-mingw32-*`) e `make`.
|
||||||
|
|
||||||
## Struttura Repository
|
## Struttura Repository
|
||||||
|
|
||||||
```
|
```
|
||||||
ns7zip/
|
nsis-plugin-ns7zip/
|
||||||
├── build_plugin.py # Script di build unificato (tutte le versioni)
|
├── build_plugin.py # Script di build unificato (tutte le versioni)
|
||||||
|
├── build_zstd.cmd # Script di build per la variante 7-zip-zstd
|
||||||
├── rebuild_nsis7z1900-src.ps1 # Ricostruisce sorgenti 19.00
|
├── rebuild_nsis7z1900-src.ps1 # Ricostruisce sorgenti 19.00
|
||||||
├── 7zip-19.00/ # 7-Zip 19.00 modificato
|
├── versions/
|
||||||
├── 7zip-25.01/ # 7-Zip 25.01 modificato (ZIP + NSIS handler)
|
│ ├── 19.00/ # 7-Zip 19.00 modificato
|
||||||
└── 7zip-26.00/ # 7-Zip 26.00 modificato (ZIP + NSIS handler)
|
│ ├── 25.01/ # 7-Zip 25.01 modificato (ZIP + NSIS handler)
|
||||||
|
│ ├── 26.00/ # 7-Zip 26.00 modificato (ZIP + NSIS handler)
|
||||||
|
│ └── 7-zip-zstd/ # Fork 7-Zip zstd (submodule)
|
||||||
|
├── plugins/ # DLL compilate
|
||||||
|
├── tools/
|
||||||
|
│ ├── fix_vcxproj.py # Patcher file di progetto
|
||||||
|
│ ├── update_gitea_releases.py # Backfill body release Gitea (one-shot)
|
||||||
|
│ ├── release-notes/ # Snippet Markdown per versione
|
||||||
|
│ ├── linux/ # Helper build Linux
|
||||||
|
│ └── legacy/ # Script di build legacy per-versione
|
||||||
|
└── .github/workflows/
|
||||||
|
├── build.yml # CI: build matrix Windows + Linux
|
||||||
|
└── release.yml # Release: build artifact + pubblicazione su GitHub e Gitea
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## CI / Workflow di Release
|
||||||
|
|
||||||
|
- **build.yml** — eseguito ad ogni push/PR; compila le tre configurazioni su Windows (MSBuild) e Linux (MinGW-w64) in parallelo.
|
||||||
|
- **release.yml** — triggerato dal push di un tag `v*`; compila e pacchettizza gli artifact, crea la GitHub Release con la sezione CHANGELOG come body, e aggiorna il body della corrispondente release Gitea via API (richiede il secret `GITEA_TOKEN`).
|
||||||
|
|
||||||
## Modifiche rispetto all'originale
|
## Modifiche rispetto all'originale
|
||||||
|
|
||||||
### NSIS Archive Handler (25.01, 26.00)
|
### NSIS Archive Handler (25.01, 26.00)
|
||||||
@@ -101,3 +126,7 @@ Aggiunto supporto per estrarre archivi `.exe` creati con NSIS (non presente nel
|
|||||||
- Igor Pavlov (7-Zip)
|
- Igor Pavlov (7-Zip)
|
||||||
- Afrow UK (Plugin originale)
|
- Afrow UK (Plugin originale)
|
||||||
- Simone (Supporto x64, VS2022/VS2026, ZIP, NSIS handler, ExtractWithFileCallback)
|
- Simone (Supporto x64, VS2022/VS2026, ZIP, NSIS handler, ExtractWithFileCallback)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Vedi [README.md](README.md) per la versione in inglese.*
|
||||||
|
|||||||
+16
-3
@@ -5,7 +5,7 @@ Wraps per-version/per-toolset build scripts.
|
|||||||
Defaults: 7-Zip 26.00, VS2026 (v145 toolset)
|
Defaults: 7-Zip 26.00, VS2026 (v145 toolset)
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import argparse, subprocess, sys
|
import argparse, platform, subprocess, sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ class Colors:
|
|||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parent
|
ROOT = Path(__file__).resolve().parent
|
||||||
SCRIPTS = {
|
WINDOWS_SCRIPTS = {
|
||||||
"19.00": {"2022": "tools/legacy/build_plugin_vs2022.py",
|
"19.00": {"2022": "tools/legacy/build_plugin_vs2022.py",
|
||||||
"2026": "tools/legacy/build_plugin_vs2026.py"},
|
"2026": "tools/legacy/build_plugin_vs2026.py"},
|
||||||
"25.01": {"2022": "tools/legacy/build_plugin_2501_vs2022.py",
|
"25.01": {"2022": "tools/legacy/build_plugin_2501_vs2022.py",
|
||||||
@@ -27,6 +27,8 @@ SCRIPTS = {
|
|||||||
"2026": "tools/legacy/build_plugin_zstd_vs2026.py"},
|
"2026": "tools/legacy/build_plugin_zstd_vs2026.py"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LINUX_SCRIPT = "tools/linux/build_plugin_linux.py"
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
parser = argparse.ArgumentParser(description="Build nsis7z NSIS plugin")
|
parser = argparse.ArgumentParser(description="Build nsis7z NSIS plugin")
|
||||||
@@ -36,6 +38,8 @@ def main() -> int:
|
|||||||
"'zstd' uses mcmilk/7-Zip-zstd submodule")
|
"'zstd' uses mcmilk/7-Zip-zstd submodule")
|
||||||
parser.add_argument("--toolset", choices=["2022", "2026", "auto"], default="auto",
|
parser.add_argument("--toolset", choices=["2022", "2026", "auto"], default="auto",
|
||||||
help="Visual Studio toolset version (default: auto)")
|
help="Visual Studio toolset version (default: auto)")
|
||||||
|
parser.add_argument("--host", choices=["auto", "windows", "linux"], default="auto",
|
||||||
|
help="Build host path (default: auto detect)")
|
||||||
parser.add_argument("--version", action="store_true",
|
parser.add_argument("--version", action="store_true",
|
||||||
help="Print plugin version and exit")
|
help="Print plugin version and exit")
|
||||||
known, rest = parser.parse_known_args()
|
known, rest = parser.parse_known_args()
|
||||||
@@ -49,11 +53,20 @@ def main() -> int:
|
|||||||
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}=== Building ns7zip v{ver} "
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}=== Building ns7zip v{ver} "
|
||||||
f"({zip_label}) ==={Colors.RESET}")
|
f"({zip_label}) ==={Colors.RESET}")
|
||||||
|
|
||||||
|
host = known.host
|
||||||
|
if host == "auto":
|
||||||
|
host = "windows" if platform.system().lower().startswith("win") else "linux"
|
||||||
|
|
||||||
|
if host == "linux":
|
||||||
|
script = ROOT / LINUX_SCRIPT
|
||||||
|
cmd = [sys.executable, str(script), "--7zip-version", known.zip_version] + rest
|
||||||
|
return subprocess.run(cmd).returncode
|
||||||
|
|
||||||
toolset = known.toolset
|
toolset = known.toolset
|
||||||
if toolset == "auto":
|
if toolset == "auto":
|
||||||
toolset = "2026"
|
toolset = "2026"
|
||||||
|
|
||||||
script_rel = SCRIPTS[known.zip_version][toolset]
|
script_rel = WINDOWS_SCRIPTS[known.zip_version][toolset]
|
||||||
if script_rel is None:
|
if script_rel is None:
|
||||||
print(f"ERROR: no {known.zip_version} script for toolset {toolset}", file=sys.stderr)
|
print(f"ERROR: no {known.zip_version} script for toolset {toolset}", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""Add missing source files to Nsis7z_vs2026.vcxproj"""
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parent.parent
|
|
||||||
vcxproj = ROOT / 'versions/zstd/CPP/7zip/Bundles/Nsis7z/Nsis7z_vs2026.vcxproj'
|
|
||||||
|
|
||||||
# Relative paths from vcxproj dir (versions/zstd/CPP/7zip/Bundles/Nsis7z/)
|
|
||||||
# 5 levels up = versions/
|
|
||||||
MISSING = [
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\CPP\Common\MyWindows.cpp',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\hashes\xxhash.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\dict_buffer.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\fl2_common.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\fl2_compress.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\fl2_pool.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\fl2_threading.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\lzma2_enc.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\radix_bitpack.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\radix_mf.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\radix_struct.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\range_enc.c',
|
|
||||||
r'..\..\..\..\..\7-zip-zstd\C\fast-lzma2\util.c',
|
|
||||||
]
|
|
||||||
|
|
||||||
content = vcxproj.read_text(encoding='utf-8')
|
|
||||||
|
|
||||||
ANCHOR = ' <ClCompile Include="..\\..\\UI\\NSIS\\ExtractCallbackConsole.cpp" />'
|
|
||||||
if ANCHOR not in content:
|
|
||||||
print('ERROR: anchor not found in vcxproj')
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
lines = [f' <ClCompile Include="{p}" />' for p in MISSING]
|
|
||||||
block = '\n'.join(lines) + '\n '
|
|
||||||
content = content.replace(ANCHOR, block + ANCHOR.lstrip())
|
|
||||||
vcxproj.write_text(content, encoding='utf-8')
|
|
||||||
print(f'Added {len(MISSING)} source files to vcxproj')
|
|
||||||
@@ -28,6 +28,69 @@ import threading
|
|||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
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
|
@dataclass
|
||||||
class BuildConfig:
|
class BuildConfig:
|
||||||
"""Build configuration settings"""
|
"""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:
|
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||||
"""Print CPU information for build optimization"""
|
"""Print CPU information for build optimization"""
|
||||||
if not use_parallel:
|
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:
|
if use_optimizations:
|
||||||
print("Optimizations: ENABLED (memory, caching)")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||||
return
|
return
|
||||||
|
|
||||||
cpu_info = get_cpu_info()
|
cpu_info = get_cpu_info()
|
||||||
optimal_threads = get_optimal_thread_count()
|
optimal_threads = get_optimal_thread_count()
|
||||||
|
|
||||||
print("Build mode: Parallel")
|
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||||
|
|
||||||
if cpu_info['has_hyperthreading']:
|
if cpu_info['has_hyperthreading']:
|
||||||
print("Hyperthreading: ENABLED")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||||
else:
|
else:
|
||||||
print("Hyperthreading: NOT AVAILABLE")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads}")
|
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:
|
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:
|
try:
|
||||||
import psutil
|
import psutil
|
||||||
memory_gb = psutil.virtual_memory().total / (1024**3)
|
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:
|
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:
|
else:
|
||||||
print("Optimizations: DISABLED")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||||
|
|
||||||
if not cpu_info['has_psutil']:
|
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()
|
print()
|
||||||
|
|
||||||
|
|
||||||
def build_configuration(
|
def build_configuration(
|
||||||
msbuild_path: Path,
|
msbuild_path: Path,
|
||||||
project_file: Path,
|
project_file: Path,
|
||||||
@@ -296,12 +357,12 @@ def build_configuration(
|
|||||||
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
||||||
|
|
||||||
if not capture_output:
|
if not capture_output:
|
||||||
print(f"\n{'='*50}")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||||
if counter:
|
if counter:
|
||||||
print(f"Building {config.name} [{counter}]")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||||
else:
|
else:
|
||||||
print(f"Building {config.name}...")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||||
print('='*50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
# Execute build and measure time
|
# Execute build and measure time
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
@@ -339,7 +400,7 @@ def copy_output(
|
|||||||
dest_dir = plugins_dir / config.dest_dir
|
dest_dir = plugins_dir / config.dest_dir
|
||||||
|
|
||||||
if not output_file.exists():
|
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
|
return False, 0, None
|
||||||
|
|
||||||
# Create destination directory
|
# Create destination directory
|
||||||
@@ -350,16 +411,16 @@ def copy_output(
|
|||||||
dest_path = dest_dir / 'nsis7z.dll'
|
dest_path = dest_dir / 'nsis7z.dll'
|
||||||
shutil.copy2(output_file, dest_path)
|
shutil.copy2(output_file, dest_path)
|
||||||
file_size = output_file.stat().st_size
|
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
|
return True, file_size, dest_path
|
||||||
except Exception as e:
|
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
|
return False, 0, None
|
||||||
|
|
||||||
|
|
||||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||||
"""Clean up build artifacts"""
|
"""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'
|
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():
|
if dir_path.exists():
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(dir_path)
|
shutil.rmtree(dir_path)
|
||||||
print(f" - Cleaned: {dir_path.name}")
|
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||||
except Exception as e:
|
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:
|
def format_time(seconds: float) -> str:
|
||||||
@@ -512,8 +573,8 @@ def _build_configs_parallel(
|
|||||||
in the same order as *configs*.
|
in the same order as *configs*.
|
||||||
"""
|
"""
|
||||||
n = len(configs)
|
n = len(configs)
|
||||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
total_start = time.time()
|
total_start = time.time()
|
||||||
results_by_idx: dict = {}
|
results_by_idx: dict = {}
|
||||||
@@ -537,22 +598,26 @@ def _build_configs_parallel(
|
|||||||
|
|
||||||
with _print_lock:
|
with _print_lock:
|
||||||
all_ok = success and copy_ok
|
all_ok = success and copy_ok
|
||||||
|
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||||
tag = "OK" if all_ok else "FAILED"
|
tag = "OK" if all_ok else "FAILED"
|
||||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
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:
|
if dest_path:
|
||||||
print(f" -> {dest_path}")
|
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||||
if not all_ok:
|
if not all_ok:
|
||||||
copy_out = copy_buf.getvalue()
|
copy_out = copy_buf.getvalue()
|
||||||
if copy_out.strip():
|
if copy_out.strip():
|
||||||
print(copy_out.rstrip())
|
print(copy_out.rstrip())
|
||||||
if captured.strip():
|
if captured.strip():
|
||||||
print("--- Build output ---")
|
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||||
print(captured.rstrip())
|
print(captured.rstrip())
|
||||||
|
|
||||||
with idx_lock:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
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:
|
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||||
for fut in as_completed(futures):
|
for fut in as_completed(futures):
|
||||||
@@ -560,12 +625,12 @@ def _build_configs_parallel(
|
|||||||
if exc:
|
if exc:
|
||||||
idx = futures[fut]
|
idx = futures[fut]
|
||||||
with _print_lock:
|
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:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||||
|
|
||||||
wall_time = time.time() - total_start
|
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)]
|
return [results_by_idx[i] for i in range(n)]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -724,15 +789,15 @@ Examples:
|
|||||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||||
|
|
||||||
# Print header
|
# Print header
|
||||||
print("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||||
print(f"Building nsis7z plugin (7-Zip 25.01) - {len(configs_to_build)} configuration(s)")
|
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("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
print(f"{Colors.CYAN}Visual Studio:{Colors.RESET} {Colors.BRIGHT_WHITE}{vs_version_name} (toolset {platform_toolset}){Colors.RESET}")
|
||||||
print(f"MSBuild: {msbuild_path}")
|
print(f"{Colors.CYAN}MSBuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{msbuild_path}{Colors.RESET}")
|
||||||
print(f"Project: {project_file}")
|
print(f"{Colors.CYAN}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||||
print(f"Plugins: {plugins_dir}")
|
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||||
print(f"Rebuild: {args.rebuild}")
|
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||||
print(f"Verbosity: {args.verbosity}")
|
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Print CPU and parallel build info
|
# Print CPU and parallel build info
|
||||||
@@ -826,12 +891,13 @@ Examples:
|
|||||||
total_time = time.time() - total_start_time
|
total_time = time.time() - total_start_time
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
print("\n" + "=" * 50)
|
print()
|
||||||
all_success = all(success for _, success, _, _, _ in build_results)
|
all_success = all(success for _, success, _, _, _ in build_results)
|
||||||
|
|
||||||
if all_success:
|
if all_success:
|
||||||
print("ALL BUILDS SUCCESSFUL!")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}{"="*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
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:")
|
print("\nPlugins copied to:")
|
||||||
for config, _, build_time, file_size, dest_path in build_results:
|
for config, _, build_time, file_size, dest_path in build_results:
|
||||||
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
||||||
@@ -842,22 +908,24 @@ Examples:
|
|||||||
print()
|
print()
|
||||||
clean_build_artifacts(project_dir, configs_to_build)
|
clean_build_artifacts(project_dir, configs_to_build)
|
||||||
else:
|
else:
|
||||||
print("SOME BUILDS FAILED!")
|
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.RED}SOME BUILDS FAILED!{Colors.RESET}")
|
||||||
|
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
||||||
print("\nFailed configurations:")
|
print("\nFailed configurations:")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
if not success:
|
if not success:
|
||||||
print(f" - {config.name}")
|
print(f" - {config.name}")
|
||||||
|
|
||||||
# Show timing summary
|
# Show timing summary
|
||||||
print("\n" + "-" * 50)
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||||
print("Build Summary:")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
status = "OK" if success else "FAIL"
|
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"
|
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(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||||
print("-" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||||
print(f"Total time: {format_time(total_time)}")
|
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Pause if requested
|
# Pause if requested
|
||||||
|
|||||||
@@ -21,6 +21,69 @@ from typing import List, Tuple, Optional
|
|||||||
import xml.etree.ElementTree as ET
|
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:
|
class BuildConfig:
|
||||||
"""Configuration for a single build target"""
|
"""Configuration for a single build target"""
|
||||||
def __init__(self, name: str, config: str, platform: str, dest_dir: str):
|
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:
|
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||||
"""Print CPU information for build optimization"""
|
"""Print CPU information for build optimization"""
|
||||||
if not use_parallel:
|
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:
|
if use_optimizations:
|
||||||
print("Optimizations: ENABLED (memory, caching)")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||||
return
|
return
|
||||||
|
|
||||||
cpu_info = get_cpu_info()
|
cpu_info = get_cpu_info()
|
||||||
optimal_threads = get_optimal_thread_count()
|
optimal_threads = get_optimal_thread_count()
|
||||||
|
|
||||||
print("Build mode: Parallel")
|
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||||
|
|
||||||
if cpu_info['has_hyperthreading']:
|
if cpu_info['has_hyperthreading']:
|
||||||
print("Hyperthreading: ENABLED")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||||
else:
|
else:
|
||||||
print("Hyperthreading: NOT AVAILABLE")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads}")
|
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:
|
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:
|
try:
|
||||||
import psutil
|
import psutil
|
||||||
memory_gb = psutil.virtual_memory().total / (1024**3)
|
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:
|
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:
|
else:
|
||||||
print("Optimizations: DISABLED")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||||
|
|
||||||
if not cpu_info['has_psutil']:
|
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()
|
print()
|
||||||
|
|
||||||
@@ -310,12 +373,12 @@ def build_configuration(
|
|||||||
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
||||||
|
|
||||||
if not capture_output:
|
if not capture_output:
|
||||||
print(f"\n{'='*50}")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||||
if counter:
|
if counter:
|
||||||
print(f"Building {config.name} [{counter}]")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||||
else:
|
else:
|
||||||
print(f"Building {config.name}...")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||||
print('='*50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
# Execute build and measure time
|
# Execute build and measure time
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
@@ -353,7 +416,7 @@ def copy_output(
|
|||||||
dest_dir = plugins_dir / config.dest_dir
|
dest_dir = plugins_dir / config.dest_dir
|
||||||
|
|
||||||
if not output_file.exists():
|
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
|
return False, 0, None
|
||||||
|
|
||||||
# Create destination directory
|
# Create destination directory
|
||||||
@@ -364,16 +427,16 @@ def copy_output(
|
|||||||
dest_path = dest_dir / 'nsis7z.dll'
|
dest_path = dest_dir / 'nsis7z.dll'
|
||||||
shutil.copy2(output_file, dest_path)
|
shutil.copy2(output_file, dest_path)
|
||||||
file_size = output_file.stat().st_size
|
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
|
return True, file_size, dest_path
|
||||||
except Exception as e:
|
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
|
return False, 0, None
|
||||||
|
|
||||||
|
|
||||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||||
"""Clean up build artifacts"""
|
"""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'
|
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():
|
if dir_path.exists():
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(dir_path)
|
shutil.rmtree(dir_path)
|
||||||
print(f" - Cleaned: {dir_path.name}")
|
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||||
except Exception as e:
|
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:
|
def format_time(seconds: float) -> str:
|
||||||
@@ -526,8 +589,8 @@ def _build_configs_parallel(
|
|||||||
in the same order as *configs*.
|
in the same order as *configs*.
|
||||||
"""
|
"""
|
||||||
n = len(configs)
|
n = len(configs)
|
||||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
total_start = time.time()
|
total_start = time.time()
|
||||||
results_by_idx: dict = {}
|
results_by_idx: dict = {}
|
||||||
@@ -551,22 +614,26 @@ def _build_configs_parallel(
|
|||||||
|
|
||||||
with _print_lock:
|
with _print_lock:
|
||||||
all_ok = success and copy_ok
|
all_ok = success and copy_ok
|
||||||
|
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||||
tag = "OK" if all_ok else "FAILED"
|
tag = "OK" if all_ok else "FAILED"
|
||||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
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:
|
if dest_path:
|
||||||
print(f" -> {dest_path}")
|
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||||
if not all_ok:
|
if not all_ok:
|
||||||
copy_out = copy_buf.getvalue()
|
copy_out = copy_buf.getvalue()
|
||||||
if copy_out.strip():
|
if copy_out.strip():
|
||||||
print(copy_out.rstrip())
|
print(copy_out.rstrip())
|
||||||
if captured.strip():
|
if captured.strip():
|
||||||
print("--- Build output ---")
|
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||||
print(captured.rstrip())
|
print(captured.rstrip())
|
||||||
|
|
||||||
with idx_lock:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
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:
|
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||||
for fut in as_completed(futures):
|
for fut in as_completed(futures):
|
||||||
@@ -574,12 +641,12 @@ def _build_configs_parallel(
|
|||||||
if exc:
|
if exc:
|
||||||
idx = futures[fut]
|
idx = futures[fut]
|
||||||
with _print_lock:
|
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:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||||
|
|
||||||
wall_time = time.time() - total_start
|
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)]
|
return [results_by_idx[i] for i in range(n)]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -749,15 +816,15 @@ Examples:
|
|||||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||||
|
|
||||||
# Print header
|
# Print header
|
||||||
print("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||||
print(f"Building nsis7z plugin (7-Zip 25.01, VS2026) - {len(configs_to_build)} configuration(s)")
|
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("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
print(f"{Colors.CYAN}Visual Studio:{Colors.RESET} {Colors.BRIGHT_WHITE}{vs_version_name} (toolset {platform_toolset}){Colors.RESET}")
|
||||||
print(f"MSBuild: {msbuild_path}")
|
print(f"{Colors.CYAN}MSBuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{msbuild_path}{Colors.RESET}")
|
||||||
print(f"Project: {project_file}")
|
print(f"{Colors.CYAN}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||||
print(f"Plugins: {plugins_dir}")
|
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||||
print(f"Rebuild: {args.rebuild}")
|
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||||
print(f"Verbosity: {args.verbosity}")
|
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Print CPU and parallel build info
|
# Print CPU and parallel build info
|
||||||
@@ -851,12 +918,13 @@ Examples:
|
|||||||
total_time = time.time() - total_start_time
|
total_time = time.time() - total_start_time
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
print("\n" + "=" * 50)
|
print()
|
||||||
all_success = all(success for _, success, _, _, _ in build_results)
|
all_success = all(success for _, success, _, _, _ in build_results)
|
||||||
|
|
||||||
if all_success:
|
if all_success:
|
||||||
print("ALL BUILDS SUCCESSFUL!")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}{"="*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
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:")
|
print("\nPlugins copied to:")
|
||||||
for config, _, build_time, file_size, dest_path in build_results:
|
for config, _, build_time, file_size, dest_path in build_results:
|
||||||
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
||||||
@@ -867,22 +935,24 @@ Examples:
|
|||||||
print()
|
print()
|
||||||
clean_build_artifacts(project_dir, configs_to_build)
|
clean_build_artifacts(project_dir, configs_to_build)
|
||||||
else:
|
else:
|
||||||
print("SOME BUILDS FAILED!")
|
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.RED}SOME BUILDS FAILED!{Colors.RESET}")
|
||||||
|
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
||||||
print("\nFailed configurations:")
|
print("\nFailed configurations:")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
if not success:
|
if not success:
|
||||||
print(f" - {config.name}")
|
print(f" - {config.name}")
|
||||||
|
|
||||||
# Show timing summary
|
# Show timing summary
|
||||||
print("\n" + "-" * 50)
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||||
print("Build Summary:")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
status = "OK" if success else "FAIL"
|
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"
|
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(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||||
print("-" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||||
print(f"Total time: {format_time(total_time)}")
|
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Pause if requested
|
# Pause if requested
|
||||||
|
|||||||
@@ -21,6 +21,69 @@ from typing import List, Tuple, Optional
|
|||||||
import xml.etree.ElementTree as ET
|
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:
|
class BuildConfig:
|
||||||
"""Configuration for a single build target"""
|
"""Configuration for a single build target"""
|
||||||
def __init__(self, name: str, config: str, platform: str, dest_dir: str):
|
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:
|
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||||
"""Print CPU information for build optimization"""
|
"""Print CPU information for build optimization"""
|
||||||
if not use_parallel:
|
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:
|
if use_optimizations:
|
||||||
print("Optimizations: ENABLED (memory, caching)")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||||
return
|
return
|
||||||
|
|
||||||
cpu_info = get_cpu_info()
|
cpu_info = get_cpu_info()
|
||||||
optimal_threads = get_optimal_thread_count()
|
optimal_threads = get_optimal_thread_count()
|
||||||
|
|
||||||
print("Build mode: Parallel")
|
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||||
|
|
||||||
if cpu_info['has_hyperthreading']:
|
if cpu_info['has_hyperthreading']:
|
||||||
print("Hyperthreading: ENABLED")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||||
else:
|
else:
|
||||||
print("Hyperthreading: NOT AVAILABLE")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads}")
|
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:
|
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:
|
try:
|
||||||
import psutil
|
import psutil
|
||||||
memory_gb = psutil.virtual_memory().total / (1024**3)
|
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:
|
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:
|
else:
|
||||||
print("Optimizations: DISABLED")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||||
|
|
||||||
if not cpu_info['has_psutil']:
|
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()
|
print()
|
||||||
|
|
||||||
@@ -312,12 +375,12 @@ def build_configuration(
|
|||||||
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
||||||
|
|
||||||
if not capture_output:
|
if not capture_output:
|
||||||
print(f"\n{'='*50}")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||||
if counter:
|
if counter:
|
||||||
print(f"Building {config.name} [{counter}]")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||||
else:
|
else:
|
||||||
print(f"Building {config.name}...")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||||
print('='*50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
# Execute build and measure time
|
# Execute build and measure time
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
@@ -355,7 +418,7 @@ def copy_output(
|
|||||||
dest_dir = plugins_dir / config.dest_dir
|
dest_dir = plugins_dir / config.dest_dir
|
||||||
|
|
||||||
if not output_file.exists():
|
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
|
return False, 0, None
|
||||||
|
|
||||||
# Create destination directory
|
# Create destination directory
|
||||||
@@ -366,16 +429,16 @@ def copy_output(
|
|||||||
dest_path = dest_dir / 'nsis7z.dll'
|
dest_path = dest_dir / 'nsis7z.dll'
|
||||||
shutil.copy2(output_file, dest_path)
|
shutil.copy2(output_file, dest_path)
|
||||||
file_size = output_file.stat().st_size
|
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
|
return True, file_size, dest_path
|
||||||
except Exception as e:
|
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
|
return False, 0, None
|
||||||
|
|
||||||
|
|
||||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||||
"""Clean up build artifacts"""
|
"""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'
|
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():
|
if dir_path.exists():
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(dir_path)
|
shutil.rmtree(dir_path)
|
||||||
print(f" - Cleaned: {dir_path.name}")
|
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||||
except Exception as e:
|
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:
|
def format_time(seconds: float) -> str:
|
||||||
@@ -529,8 +592,8 @@ def _build_configs_parallel(
|
|||||||
in the same order as *configs*.
|
in the same order as *configs*.
|
||||||
"""
|
"""
|
||||||
n = len(configs)
|
n = len(configs)
|
||||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
total_start = time.time()
|
total_start = time.time()
|
||||||
results_by_idx: dict = {}
|
results_by_idx: dict = {}
|
||||||
@@ -554,22 +617,26 @@ def _build_configs_parallel(
|
|||||||
|
|
||||||
with _print_lock:
|
with _print_lock:
|
||||||
all_ok = success and copy_ok
|
all_ok = success and copy_ok
|
||||||
|
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||||
tag = "OK" if all_ok else "FAILED"
|
tag = "OK" if all_ok else "FAILED"
|
||||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
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:
|
if dest_path:
|
||||||
print(f" -> {dest_path}")
|
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||||
if not all_ok:
|
if not all_ok:
|
||||||
copy_out = copy_buf.getvalue()
|
copy_out = copy_buf.getvalue()
|
||||||
if copy_out.strip():
|
if copy_out.strip():
|
||||||
print(copy_out.rstrip())
|
print(copy_out.rstrip())
|
||||||
if captured.strip():
|
if captured.strip():
|
||||||
print("--- Build output ---")
|
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||||
print(captured.rstrip())
|
print(captured.rstrip())
|
||||||
|
|
||||||
with idx_lock:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
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:
|
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||||
for fut in as_completed(futures):
|
for fut in as_completed(futures):
|
||||||
@@ -577,12 +644,12 @@ def _build_configs_parallel(
|
|||||||
if exc:
|
if exc:
|
||||||
idx = futures[fut]
|
idx = futures[fut]
|
||||||
with _print_lock:
|
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:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||||
|
|
||||||
wall_time = time.time() - total_start
|
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)]
|
return [results_by_idx[i] for i in range(n)]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -744,15 +811,15 @@ Examples:
|
|||||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||||
|
|
||||||
# Print header
|
# Print header
|
||||||
print("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*60}{Colors.RESET}")
|
||||||
print(f"Building nsis7z plugin (7-Zip 26.00, VS2026) - {len(configs_to_build)} configuration(s)")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Building nsis7z plugin (7-Zip 26.00, VS2026){Colors.RESET} - {Colors.BRIGHT_WHITE}{len(configs_to_build)}{Colors.RESET} configuration(s)")
|
||||||
print("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*60}{Colors.RESET}")
|
||||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
print(f"{Colors.CYAN}Visual Studio:{Colors.RESET} {Colors.BRIGHT_WHITE}{vs_version_name} (toolset {platform_toolset}){Colors.RESET}")
|
||||||
print(f"MSBuild: {msbuild_path}")
|
print(f"{Colors.CYAN}MSBuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{msbuild_path}{Colors.RESET}")
|
||||||
print(f"Project: {project_file}")
|
print(f"{Colors.CYAN}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||||
print(f"Plugins: {plugins_dir}")
|
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||||
print(f"Rebuild: {args.rebuild}")
|
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||||
print(f"Verbosity: {args.verbosity}")
|
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Print CPU and parallel build info
|
# Print CPU and parallel build info
|
||||||
@@ -850,12 +917,13 @@ Examples:
|
|||||||
total_time = time.time() - total_start_time
|
total_time = time.time() - total_start_time
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
print("\n" + "=" * 50)
|
print()
|
||||||
all_success = all(success for _, success, _, _, _ in build_results)
|
all_success = all(success for _, success, _, _, _ in build_results)
|
||||||
|
|
||||||
if all_success:
|
if all_success:
|
||||||
print("ALL BUILDS SUCCESSFUL!")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}{'='*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
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:")
|
print("\nPlugins copied to:")
|
||||||
for config, _, build_time, file_size, dest_path in build_results:
|
for config, _, build_time, file_size, dest_path in build_results:
|
||||||
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
||||||
@@ -866,22 +934,24 @@ Examples:
|
|||||||
print()
|
print()
|
||||||
clean_build_artifacts(project_dir, configs_to_build)
|
clean_build_artifacts(project_dir, configs_to_build)
|
||||||
else:
|
else:
|
||||||
print("SOME BUILDS FAILED!")
|
print(f"{Colors.BOLD}{Colors.RED}{'='*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.RED}SOME BUILDS FAILED!{Colors.RESET}")
|
||||||
|
print(f"{Colors.BOLD}{Colors.RED}{'='*50}{Colors.RESET}")
|
||||||
print("\nFailed configurations:")
|
print("\nFailed configurations:")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
if not success:
|
if not success:
|
||||||
print(f" - {config.name}")
|
print(f" - {config.name}")
|
||||||
|
|
||||||
# Show timing summary
|
# Show timing summary
|
||||||
print("\n" + "-" * 50)
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{'-'*50}{Colors.RESET}")
|
||||||
print("Build Summary:")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
status = "OK" if success else "FAIL"
|
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"
|
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(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||||
print("-" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'-'*50}{Colors.RESET}")
|
||||||
print(f"Total time: {format_time(total_time)}")
|
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Pause if requested
|
# Pause if requested
|
||||||
|
|||||||
@@ -18,6 +18,69 @@ from typing import List, Tuple, Optional
|
|||||||
import xml.etree.ElementTree as ET
|
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:
|
class BuildConfig:
|
||||||
"""Configuration for a single build target"""
|
"""Configuration for a single build target"""
|
||||||
def __init__(self, name: str, config: str, platform: str, dest_dir: str):
|
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:
|
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||||
"""Print CPU information for build optimization"""
|
"""Print CPU information for build optimization"""
|
||||||
if not use_parallel:
|
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:
|
if use_optimizations:
|
||||||
print("Optimizations: ENABLED (memory, caching)")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||||
return
|
return
|
||||||
|
|
||||||
cpu_info = get_cpu_info()
|
cpu_info = get_cpu_info()
|
||||||
optimal_threads = get_optimal_thread_count()
|
optimal_threads = get_optimal_thread_count()
|
||||||
|
|
||||||
print("Build mode: Parallel")
|
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||||
|
|
||||||
if cpu_info['has_hyperthreading']:
|
if cpu_info['has_hyperthreading']:
|
||||||
print("Hyperthreading: ENABLED")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||||
else:
|
else:
|
||||||
print("Hyperthreading: NOT AVAILABLE")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads}")
|
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:
|
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:
|
try:
|
||||||
import psutil
|
import psutil
|
||||||
memory_gb = psutil.virtual_memory().total / (1024**3)
|
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:
|
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:
|
else:
|
||||||
print("Optimizations: DISABLED")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||||
|
|
||||||
if not cpu_info['has_psutil']:
|
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()
|
print()
|
||||||
|
|
||||||
@@ -294,12 +357,12 @@ def build_configuration(
|
|||||||
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
||||||
|
|
||||||
if not capture_output:
|
if not capture_output:
|
||||||
print(f"\n{'='*50}")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||||
if counter:
|
if counter:
|
||||||
print(f"Building {config.name} [{counter}]")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||||
else:
|
else:
|
||||||
print(f"Building {config.name}...")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||||
print('='*50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
# Execute build and measure time
|
# Execute build and measure time
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
@@ -337,7 +400,7 @@ def copy_output(
|
|||||||
dest_dir = plugins_dir / config.dest_dir
|
dest_dir = plugins_dir / config.dest_dir
|
||||||
|
|
||||||
if not output_file.exists():
|
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
|
return False, 0, None
|
||||||
|
|
||||||
# Create destination directory
|
# Create destination directory
|
||||||
@@ -348,16 +411,16 @@ def copy_output(
|
|||||||
dest_path = dest_dir / 'nsis7z.dll'
|
dest_path = dest_dir / 'nsis7z.dll'
|
||||||
shutil.copy2(output_file, dest_path)
|
shutil.copy2(output_file, dest_path)
|
||||||
file_size = output_file.stat().st_size
|
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
|
return True, file_size, dest_path
|
||||||
except Exception as e:
|
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
|
return False, 0, None
|
||||||
|
|
||||||
|
|
||||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||||
"""Clean up build artifacts"""
|
"""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'
|
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():
|
if dir_path.exists():
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(dir_path)
|
shutil.rmtree(dir_path)
|
||||||
print(f" - Cleaned: {dir_path.name}")
|
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||||
except Exception as e:
|
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:
|
def format_time(seconds: float) -> str:
|
||||||
@@ -510,8 +573,8 @@ def _build_configs_parallel(
|
|||||||
in the same order as *configs*.
|
in the same order as *configs*.
|
||||||
"""
|
"""
|
||||||
n = len(configs)
|
n = len(configs)
|
||||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
total_start = time.time()
|
total_start = time.time()
|
||||||
results_by_idx: dict = {}
|
results_by_idx: dict = {}
|
||||||
@@ -535,22 +598,26 @@ def _build_configs_parallel(
|
|||||||
|
|
||||||
with _print_lock:
|
with _print_lock:
|
||||||
all_ok = success and copy_ok
|
all_ok = success and copy_ok
|
||||||
|
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||||
tag = "OK" if all_ok else "FAILED"
|
tag = "OK" if all_ok else "FAILED"
|
||||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
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:
|
if dest_path:
|
||||||
print(f" -> {dest_path}")
|
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||||
if not all_ok:
|
if not all_ok:
|
||||||
copy_out = copy_buf.getvalue()
|
copy_out = copy_buf.getvalue()
|
||||||
if copy_out.strip():
|
if copy_out.strip():
|
||||||
print(copy_out.rstrip())
|
print(copy_out.rstrip())
|
||||||
if captured.strip():
|
if captured.strip():
|
||||||
print("--- Build output ---")
|
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||||
print(captured.rstrip())
|
print(captured.rstrip())
|
||||||
|
|
||||||
with idx_lock:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
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:
|
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||||
for fut in as_completed(futures):
|
for fut in as_completed(futures):
|
||||||
@@ -558,12 +625,12 @@ def _build_configs_parallel(
|
|||||||
if exc:
|
if exc:
|
||||||
idx = futures[fut]
|
idx = futures[fut]
|
||||||
with _print_lock:
|
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:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||||
|
|
||||||
wall_time = time.time() - total_start
|
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)]
|
return [results_by_idx[i] for i in range(n)]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -722,15 +789,15 @@ Examples:
|
|||||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||||
|
|
||||||
# Print header
|
# Print header
|
||||||
print("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||||
print(f"Building nsis7z plugin - {len(configs_to_build)} configuration(s)")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Building nsis7z plugin{Colors.RESET} - {Colors.BRIGHT_WHITE}{len(configs_to_build)}{Colors.RESET} configuration(s)")
|
||||||
print("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
print(f"{Colors.CYAN}Visual Studio:{Colors.RESET} {Colors.BRIGHT_WHITE}{vs_version_name} (toolset {platform_toolset}){Colors.RESET}")
|
||||||
print(f"MSBuild: {msbuild_path}")
|
print(f"{Colors.CYAN}MSBuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{msbuild_path}{Colors.RESET}")
|
||||||
print(f"Project: {project_file}")
|
print(f"{Colors.CYAN}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||||
print(f"Plugins: {plugins_dir}")
|
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||||
print(f"Rebuild: {args.rebuild}")
|
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||||
print(f"Verbosity: {args.verbosity}")
|
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Print CPU and parallel build info
|
# Print CPU and parallel build info
|
||||||
@@ -824,12 +891,13 @@ Examples:
|
|||||||
total_time = time.time() - total_start_time
|
total_time = time.time() - total_start_time
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
print("\n" + "=" * 50)
|
print()
|
||||||
all_success = all(success for _, success, _, _, _ in build_results)
|
all_success = all(success for _, success, _, _, _ in build_results)
|
||||||
|
|
||||||
if all_success:
|
if all_success:
|
||||||
print("ALL BUILDS SUCCESSFUL!")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}{"="*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
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:")
|
print("\nPlugins copied to:")
|
||||||
for config, _, build_time, file_size, dest_path in build_results:
|
for config, _, build_time, file_size, dest_path in build_results:
|
||||||
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
||||||
@@ -840,22 +908,24 @@ Examples:
|
|||||||
print()
|
print()
|
||||||
clean_build_artifacts(project_dir, configs_to_build)
|
clean_build_artifacts(project_dir, configs_to_build)
|
||||||
else:
|
else:
|
||||||
print("SOME BUILDS FAILED!")
|
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.RED}SOME BUILDS FAILED!{Colors.RESET}")
|
||||||
|
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
||||||
print("\nFailed configurations:")
|
print("\nFailed configurations:")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
if not success:
|
if not success:
|
||||||
print(f" - {config.name}")
|
print(f" - {config.name}")
|
||||||
|
|
||||||
# Show timing summary
|
# Show timing summary
|
||||||
print("\n" + "-" * 50)
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||||
print("Build Summary:")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
status = "OK" if success else "FAIL"
|
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"
|
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(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||||
print("-" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||||
print(f"Total time: {format_time(total_time)}")
|
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Pause if requested
|
# Pause if requested
|
||||||
|
|||||||
@@ -21,6 +21,69 @@ from typing import List, Tuple, Optional
|
|||||||
import xml.etree.ElementTree as ET
|
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:
|
class BuildConfig:
|
||||||
"""Configuration for a single build target"""
|
"""Configuration for a single build target"""
|
||||||
def __init__(self, name: str, config: str, platform: str, dest_dir: str):
|
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:
|
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||||
"""Print CPU information for build optimization"""
|
"""Print CPU information for build optimization"""
|
||||||
if not use_parallel:
|
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:
|
if use_optimizations:
|
||||||
print("Optimizations: ENABLED (memory, caching)")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||||
return
|
return
|
||||||
|
|
||||||
cpu_info = get_cpu_info()
|
cpu_info = get_cpu_info()
|
||||||
optimal_threads = get_optimal_thread_count()
|
optimal_threads = get_optimal_thread_count()
|
||||||
|
|
||||||
print("Build mode: Parallel")
|
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||||
|
|
||||||
if cpu_info['has_hyperthreading']:
|
if cpu_info['has_hyperthreading']:
|
||||||
print("Hyperthreading: ENABLED")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||||
else:
|
else:
|
||||||
print("Hyperthreading: NOT AVAILABLE")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads}")
|
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:
|
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:
|
try:
|
||||||
import psutil
|
import psutil
|
||||||
memory_gb = psutil.virtual_memory().total / (1024**3)
|
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:
|
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:
|
else:
|
||||||
print("Optimizations: DISABLED")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||||
|
|
||||||
if not cpu_info['has_psutil']:
|
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()
|
print()
|
||||||
|
|
||||||
@@ -310,12 +373,12 @@ def build_configuration(
|
|||||||
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
cmd.append(f'/p:MSBuildCacheEnabled=true')
|
||||||
|
|
||||||
if not capture_output:
|
if not capture_output:
|
||||||
print(f"\n{'='*50}")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||||
if counter:
|
if counter:
|
||||||
print(f"Building {config.name} [{counter}]")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||||
else:
|
else:
|
||||||
print(f"Building {config.name}...")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||||
print('='*50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
# Execute build and measure time
|
# Execute build and measure time
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
@@ -353,7 +416,7 @@ def copy_output(
|
|||||||
dest_dir = plugins_dir / config.dest_dir
|
dest_dir = plugins_dir / config.dest_dir
|
||||||
|
|
||||||
if not output_file.exists():
|
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
|
return False, 0, None
|
||||||
|
|
||||||
# Create destination directory
|
# Create destination directory
|
||||||
@@ -364,16 +427,16 @@ def copy_output(
|
|||||||
dest_path = dest_dir / 'nsis7z.dll'
|
dest_path = dest_dir / 'nsis7z.dll'
|
||||||
shutil.copy2(output_file, dest_path)
|
shutil.copy2(output_file, dest_path)
|
||||||
file_size = output_file.stat().st_size
|
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
|
return True, file_size, dest_path
|
||||||
except Exception as e:
|
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
|
return False, 0, None
|
||||||
|
|
||||||
|
|
||||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||||
"""Clean up build artifacts"""
|
"""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'
|
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():
|
if dir_path.exists():
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(dir_path)
|
shutil.rmtree(dir_path)
|
||||||
print(f" - Cleaned: {dir_path.name}")
|
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||||
except Exception as e:
|
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:
|
def format_time(seconds: float) -> str:
|
||||||
@@ -526,8 +589,8 @@ def _build_configs_parallel(
|
|||||||
in the same order as *configs*.
|
in the same order as *configs*.
|
||||||
"""
|
"""
|
||||||
n = len(configs)
|
n = len(configs)
|
||||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
total_start = time.time()
|
total_start = time.time()
|
||||||
results_by_idx: dict = {}
|
results_by_idx: dict = {}
|
||||||
@@ -551,22 +614,26 @@ def _build_configs_parallel(
|
|||||||
|
|
||||||
with _print_lock:
|
with _print_lock:
|
||||||
all_ok = success and copy_ok
|
all_ok = success and copy_ok
|
||||||
|
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||||
tag = "OK" if all_ok else "FAILED"
|
tag = "OK" if all_ok else "FAILED"
|
||||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
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:
|
if dest_path:
|
||||||
print(f" -> {dest_path}")
|
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||||
if not all_ok:
|
if not all_ok:
|
||||||
copy_out = copy_buf.getvalue()
|
copy_out = copy_buf.getvalue()
|
||||||
if copy_out.strip():
|
if copy_out.strip():
|
||||||
print(copy_out.rstrip())
|
print(copy_out.rstrip())
|
||||||
if captured.strip():
|
if captured.strip():
|
||||||
print("--- Build output ---")
|
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||||
print(captured.rstrip())
|
print(captured.rstrip())
|
||||||
|
|
||||||
with idx_lock:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
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:
|
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||||
for fut in as_completed(futures):
|
for fut in as_completed(futures):
|
||||||
@@ -574,12 +641,12 @@ def _build_configs_parallel(
|
|||||||
if exc:
|
if exc:
|
||||||
idx = futures[fut]
|
idx = futures[fut]
|
||||||
with _print_lock:
|
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:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||||
|
|
||||||
wall_time = time.time() - total_start
|
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)]
|
return [results_by_idx[i] for i in range(n)]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -749,15 +816,15 @@ Examples:
|
|||||||
configs_to_build = [CONFIGS[name] for name in args.configs]
|
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||||
|
|
||||||
# Print header
|
# Print header
|
||||||
print("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||||
print(f"Building nsis7z plugin (VS2026) - {len(configs_to_build)} configuration(s)")
|
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("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
print(f"{Colors.CYAN}Visual Studio:{Colors.RESET} {Colors.BRIGHT_WHITE}{vs_version_name} (toolset {platform_toolset}){Colors.RESET}")
|
||||||
print(f"MSBuild: {msbuild_path}")
|
print(f"{Colors.CYAN}MSBuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{msbuild_path}{Colors.RESET}")
|
||||||
print(f"Project: {project_file}")
|
print(f"{Colors.CYAN}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||||
print(f"Plugins: {plugins_dir}")
|
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||||
print(f"Rebuild: {args.rebuild}")
|
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||||
print(f"Verbosity: {args.verbosity}")
|
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Print CPU and parallel build info
|
# Print CPU and parallel build info
|
||||||
@@ -851,12 +918,13 @@ Examples:
|
|||||||
total_time = time.time() - total_start_time
|
total_time = time.time() - total_start_time
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
print("\n" + "=" * 50)
|
print()
|
||||||
all_success = all(success for _, success, _, _, _ in build_results)
|
all_success = all(success for _, success, _, _, _ in build_results)
|
||||||
|
|
||||||
if all_success:
|
if all_success:
|
||||||
print("ALL BUILDS SUCCESSFUL!")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}{"="*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
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:")
|
print("\nPlugins copied to:")
|
||||||
for config, _, build_time, file_size, dest_path in build_results:
|
for config, _, build_time, file_size, dest_path in build_results:
|
||||||
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
dest = dest_path if dest_path else plugins_dir / config.dest_dir / 'nsis7z.dll'
|
||||||
@@ -867,22 +935,24 @@ Examples:
|
|||||||
print()
|
print()
|
||||||
clean_build_artifacts(project_dir, configs_to_build)
|
clean_build_artifacts(project_dir, configs_to_build)
|
||||||
else:
|
else:
|
||||||
print("SOME BUILDS FAILED!")
|
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.RED}SOME BUILDS FAILED!{Colors.RESET}")
|
||||||
|
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
||||||
print("\nFailed configurations:")
|
print("\nFailed configurations:")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
if not success:
|
if not success:
|
||||||
print(f" - {config.name}")
|
print(f" - {config.name}")
|
||||||
|
|
||||||
# Show timing summary
|
# Show timing summary
|
||||||
print("\n" + "-" * 50)
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||||
print("Build Summary:")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
status = "OK" if success else "FAIL"
|
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"
|
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(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||||
print("-" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||||
print(f"Total time: {format_time(total_time)}")
|
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Pause if requested
|
# Pause if requested
|
||||||
|
|||||||
@@ -24,6 +24,69 @@ from typing import List, Tuple, Optional
|
|||||||
import xml.etree.ElementTree as ET
|
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:
|
class BuildConfig:
|
||||||
"""Configuration for a single build target"""
|
"""Configuration for a single build target"""
|
||||||
def __init__(self, name: str, config: str, platform: str, dest_dir: str):
|
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:
|
def print_cpu_info(use_parallel: bool, use_optimizations: bool = True) -> None:
|
||||||
"""Print CPU information for build optimization"""
|
"""Print CPU information for build optimization"""
|
||||||
if not use_parallel:
|
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:
|
if use_optimizations:
|
||||||
print("Optimizations: ENABLED (memory, caching)")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.BRIGHT_WHITE}ENABLED{Colors.RESET} (memory, caching)")
|
||||||
return
|
return
|
||||||
|
|
||||||
cpu_info = get_cpu_info()
|
cpu_info = get_cpu_info()
|
||||||
optimal_threads = get_optimal_thread_count()
|
optimal_threads = get_optimal_thread_count()
|
||||||
|
|
||||||
print("Build mode: Parallel")
|
print(f"{Colors.CYAN}Build mode:{Colors.RESET} {Colors.BRIGHT_WHITE}Parallel{Colors.RESET}")
|
||||||
print(f"Logical cores: {cpu_info['logical_cores']}")
|
print(f"{Colors.CYAN}Logical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['logical_cores']}{Colors.RESET}")
|
||||||
print(f"Physical cores: {cpu_info['physical_cores']}")
|
print(f"{Colors.CYAN}Physical cores:{Colors.RESET} {Colors.BRIGHT_WHITE}{cpu_info['physical_cores']}{Colors.RESET}")
|
||||||
|
|
||||||
if cpu_info['has_hyperthreading']:
|
if cpu_info['has_hyperthreading']:
|
||||||
print("Hyperthreading: ENABLED")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.BRIGHT_GREEN}ENABLED{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads} (using physical cores)")
|
print(f"{Colors.CYAN}Optimal threads:{Colors.RESET} {Colors.BRIGHT_WHITE}{optimal_threads}{Colors.RESET} (using physical cores)")
|
||||||
else:
|
else:
|
||||||
print("Hyperthreading: NOT AVAILABLE")
|
print(f"{Colors.CYAN}Hyperthreading:{Colors.RESET} {Colors.GRAY}NOT AVAILABLE{Colors.RESET}")
|
||||||
print(f"Optimal threads: {optimal_threads}")
|
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:
|
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:
|
try:
|
||||||
import psutil
|
import psutil
|
||||||
memory_gb = psutil.virtual_memory().total / (1024 ** 3)
|
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:
|
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:
|
else:
|
||||||
print("Optimizations: DISABLED")
|
print(f"{Colors.CYAN}Optimizations:{Colors.RESET} {Colors.RED}DISABLED{Colors.RESET}")
|
||||||
|
|
||||||
if not cpu_info['has_psutil']:
|
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()
|
print()
|
||||||
|
|
||||||
@@ -295,12 +358,12 @@ def build_configuration(
|
|||||||
cmd.append('/p:MSBuildCacheEnabled=true')
|
cmd.append('/p:MSBuildCacheEnabled=true')
|
||||||
|
|
||||||
if not capture_output:
|
if not capture_output:
|
||||||
print(f"\n{'=' * 50}")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'=' * 50}{Colors.RESET}")
|
||||||
if counter:
|
if counter:
|
||||||
print(f"Building {config.name} [{counter}]")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name} [{counter}]{Colors.RESET}")
|
||||||
else:
|
else:
|
||||||
print(f"Building {config.name}...")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_WHITE}Building {config.name}...{Colors.RESET}")
|
||||||
print('=' * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_YELLOW}{'=' * 50}{Colors.RESET}")
|
||||||
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
try:
|
try:
|
||||||
@@ -337,7 +400,7 @@ def copy_output(
|
|||||||
dest_dir = plugins_dir / config.dest_dir
|
dest_dir = plugins_dir / config.dest_dir
|
||||||
|
|
||||||
if not output_file.exists():
|
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
|
return False, 0, None
|
||||||
|
|
||||||
dest_dir.mkdir(parents=True, exist_ok=True)
|
dest_dir.mkdir(parents=True, exist_ok=True)
|
||||||
@@ -346,16 +409,16 @@ def copy_output(
|
|||||||
dest_path = dest_dir / 'nsis7z.dll'
|
dest_path = dest_dir / 'nsis7z.dll'
|
||||||
shutil.copy2(output_file, dest_path)
|
shutil.copy2(output_file, dest_path)
|
||||||
file_size = output_file.stat().st_size
|
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
|
return True, file_size, dest_path
|
||||||
except Exception as e:
|
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
|
return False, 0, None
|
||||||
|
|
||||||
|
|
||||||
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
def clean_build_artifacts(project_dir: Path, configs: List[BuildConfig]) -> None:
|
||||||
"""Clean up build artifacts"""
|
"""Clean up build artifacts"""
|
||||||
print("\nCleaning build artifacts...")
|
print(f"\n{Colors.CYAN}Cleaning build artifacts...{Colors.RESET}")
|
||||||
|
|
||||||
build_base_dir = (
|
build_base_dir = (
|
||||||
project_dir / 'CPP' / '7zip' / 'Bundles' / 'Nsis7z' / 'Build'
|
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():
|
if dir_path.exists():
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(dir_path)
|
shutil.rmtree(dir_path)
|
||||||
print(f" - Cleaned: {dir_path.name}")
|
print(f" {Colors.GRAY}- Cleaned: {dir_path.name}{Colors.RESET}")
|
||||||
except Exception as e:
|
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:
|
def format_time(seconds: float) -> str:
|
||||||
@@ -462,8 +525,8 @@ def _build_configs_parallel(
|
|||||||
) -> list:
|
) -> list:
|
||||||
"""Build all configurations simultaneously, printing output atomically."""
|
"""Build all configurations simultaneously, printing output atomically."""
|
||||||
n = len(configs)
|
n = len(configs)
|
||||||
print(f"\nParallel-configs: launching {n} builds simultaneously...")
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}Parallel-configs:{Colors.RESET} launching {Colors.BRIGHT_WHITE}{n}{Colors.RESET} builds simultaneously...")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{'='*50}{Colors.RESET}")
|
||||||
|
|
||||||
total_start = time.time()
|
total_start = time.time()
|
||||||
results_by_idx: dict = {}
|
results_by_idx: dict = {}
|
||||||
@@ -486,22 +549,26 @@ def _build_configs_parallel(
|
|||||||
|
|
||||||
with _print_lock:
|
with _print_lock:
|
||||||
all_ok = success and copy_ok
|
all_ok = success and copy_ok
|
||||||
|
tag_color = Colors.BRIGHT_GREEN if all_ok else Colors.RED
|
||||||
tag = "OK" if all_ok else "FAILED"
|
tag = "OK" if all_ok else "FAILED"
|
||||||
size_str = f"{file_size:,} bytes" if file_size > 0 else "N/A"
|
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:
|
if dest_path:
|
||||||
print(f" -> {dest_path}")
|
print(f" {Colors.GRAY}-> {dest_path}{Colors.RESET}")
|
||||||
if not all_ok:
|
if not all_ok:
|
||||||
copy_out = copy_buf.getvalue()
|
copy_out = copy_buf.getvalue()
|
||||||
if copy_out.strip():
|
if copy_out.strip():
|
||||||
print(copy_out.rstrip())
|
print(copy_out.rstrip())
|
||||||
if captured.strip():
|
if captured.strip():
|
||||||
print("--- Build output ---")
|
print(f"{Colors.YELLOW}--- Build output ---{Colors.RESET}")
|
||||||
print(captured.rstrip())
|
print(captured.rstrip())
|
||||||
|
|
||||||
with idx_lock:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (config, success and copy_ok, build_time, file_size, dest_path)
|
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:
|
with ThreadPoolExecutor(max_workers=n) as executor:
|
||||||
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
futures = {executor.submit(_build_one, i, cfg): i for i, cfg in enumerate(configs)}
|
||||||
for fut in as_completed(futures):
|
for fut in as_completed(futures):
|
||||||
@@ -509,12 +576,12 @@ def _build_configs_parallel(
|
|||||||
if exc:
|
if exc:
|
||||||
idx = futures[fut]
|
idx = futures[fut]
|
||||||
with _print_lock:
|
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:
|
with idx_lock:
|
||||||
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
results_by_idx[idx] = (configs[idx], False, 0.0, 0, None)
|
||||||
|
|
||||||
wall_time = time.time() - total_start
|
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)]
|
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]
|
configs_to_build = [CONFIGS[name] for name in args.configs]
|
||||||
|
|
||||||
# Print header
|
# Print header
|
||||||
print("=" * 60)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||||
print(
|
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)")
|
||||||
f"Building nsis7z plugin (7-Zip ZS, VS2026)"
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"="*60}{Colors.RESET}")
|
||||||
f" - {len(configs_to_build)} configuration(s)"
|
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("=" * 60)
|
print(f"{Colors.CYAN}Project:{Colors.RESET} {Colors.BRIGHT_WHITE}{project_file}{Colors.RESET}")
|
||||||
print(f"Visual Studio: {vs_version_name} (toolset {platform_toolset})")
|
print(f"{Colors.CYAN}Plugins:{Colors.RESET} {Colors.BRIGHT_WHITE}{plugins_dir}{Colors.RESET}")
|
||||||
print(f"MSBuild: {msbuild_path}")
|
print(f"{Colors.CYAN}Rebuild:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.rebuild}{Colors.RESET}")
|
||||||
print(f"Project: {project_file}")
|
print(f"{Colors.CYAN}Verbosity:{Colors.RESET} {Colors.BRIGHT_WHITE}{args.verbosity}{Colors.RESET}")
|
||||||
print(f"Plugins: {plugins_dir}")
|
|
||||||
print(f"Rebuild: {args.rebuild}")
|
|
||||||
print(f"Verbosity: {args.verbosity}")
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
use_optimizations = not args.no_optimizations
|
use_optimizations = not args.no_optimizations
|
||||||
@@ -656,12 +720,13 @@ Examples:
|
|||||||
total_time = time.time() - total_start_time
|
total_time = time.time() - total_start_time
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
print("\n" + "=" * 50)
|
print()
|
||||||
all_success = all(success for _, success, _, _, _ in build_results)
|
all_success = all(success for _, success, _, _, _ in build_results)
|
||||||
|
|
||||||
if all_success:
|
if all_success:
|
||||||
print("ALL BUILDS SUCCESSFUL!")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_GREEN}{"="*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
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:")
|
print("\nPlugins copied to:")
|
||||||
for config, _, build_time, file_size, dest_path in build_results:
|
for config, _, build_time, file_size, dest_path in build_results:
|
||||||
dest = dest_path or plugins_dir / config.dest_dir / 'nsis7z.dll'
|
dest = dest_path or plugins_dir / config.dest_dir / 'nsis7z.dll'
|
||||||
@@ -670,21 +735,23 @@ Examples:
|
|||||||
print()
|
print()
|
||||||
clean_build_artifacts(project_dir, configs_to_build)
|
clean_build_artifacts(project_dir, configs_to_build)
|
||||||
else:
|
else:
|
||||||
print("SOME BUILDS FAILED!")
|
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
||||||
print("=" * 50)
|
print(f"{Colors.BOLD}{Colors.RED}SOME BUILDS FAILED!{Colors.RESET}")
|
||||||
|
print(f"{Colors.BOLD}{Colors.RED}{"="*50}{Colors.RESET}")
|
||||||
print("\nFailed configurations:")
|
print("\nFailed configurations:")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
if not success:
|
if not success:
|
||||||
print(f" - {config.name}")
|
print(f" - {config.name}")
|
||||||
|
|
||||||
print("\n" + "-" * 50)
|
print(f"\n{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||||
print("Build Summary:")
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}Build Summary:{Colors.RESET}")
|
||||||
for config, success, build_time, file_size, dest_path in build_results:
|
for config, success, build_time, file_size, dest_path in build_results:
|
||||||
status = "OK" if success else "FAIL"
|
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"
|
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(f" {row_color}{status}{Colors.RESET} {config.name:15s} - {format_time(build_time):8s} - {size_str}")
|
||||||
print("-" * 50)
|
print(f"{Colors.BOLD}{Colors.BRIGHT_CYAN}{"-"*50}{Colors.RESET}")
|
||||||
print(f"Total time: {format_time(total_time)}")
|
print(f"Total time: {Colors.BRIGHT_WHITE}{format_time(total_time)}{Colors.RESET}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
if args.pause:
|
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,54 @@
|
|||||||
|
# update_gitea_releases.py
|
||||||
|
|
||||||
|
Script one-shot per aggiornare il body delle release Gitea esistenti con il testo del CHANGELOG.
|
||||||
|
|
||||||
|
## Quando usarlo
|
||||||
|
|
||||||
|
Il workflow `release.yml` aggiorna automaticamente il body delle release **nuove** su Gitea.
|
||||||
|
Questo script serve per le release **giĂ esistenti**, create prima che quella funzionalitĂ fosse aggiunta.
|
||||||
|
|
||||||
|
## Prerequisiti
|
||||||
|
|
||||||
|
- Python 3.8+
|
||||||
|
- Un Gitea API token con permesso **Repository → Read and Write**
|
||||||
|
|
||||||
|
### Creare il token su Gitea
|
||||||
|
|
||||||
|
1. Gitea → avatar → **Settings** → **Applications**
|
||||||
|
2. Sezione **"Manage Access Tokens"** → nome a piacere (es. `release-body-update`)
|
||||||
|
3. Permission: **Repository** → `Read and Write`
|
||||||
|
4. **Generate Token** → copia il valore (mostrato una sola volta)
|
||||||
|
|
||||||
|
## Uso
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Tramite variabile d'ambiente
|
||||||
|
GITEA_TOKEN=<token> python3 tools/update_gitea_releases.py
|
||||||
|
|
||||||
|
# Tramite argomento
|
||||||
|
python3 tools/update_gitea_releases.py --token <token>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Output atteso
|
||||||
|
|
||||||
|
```
|
||||||
|
[v2.0.0] recupero release... id=1, aggiorno body... OK
|
||||||
|
[v2.0.1] recupero release... id=2, aggiorno body... OK
|
||||||
|
[v2.1.0] recupero release... id=3, aggiorno body... OK
|
||||||
|
[v2.2.0] recupero release... id=4, aggiorno body... OK
|
||||||
|
[v2.2.1] recupero release... id=5, aggiorno body... OK
|
||||||
|
```
|
||||||
|
|
||||||
|
Se una release non esiste su Gitea per quel tag, la riga mostra `SALTATO`.
|
||||||
|
|
||||||
|
## Come funziona
|
||||||
|
|
||||||
|
Per ogni file `tools/release-notes/vX.Y.Z.md`:
|
||||||
|
|
||||||
|
1. Chiama `GET /api/v1/repos/{owner}/{repo}/releases/tags/vX.Y.Z` per ottenere l'ID
|
||||||
|
2. Chiama `PATCH /api/v1/repos/{owner}/{repo}/releases/{id}` con il body del file `.md`
|
||||||
|
|
||||||
|
## Aggiungere nuove versioni
|
||||||
|
|
||||||
|
Crea un file `tools/release-notes/vX.Y.Z.md` con il contenuto desiderato, poi riesegui lo script.
|
||||||
|
Per le release future il workflow lo fa automaticamente — questo script non è necessario.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
### Added
|
||||||
|
- Prima release come repository indipendente
|
||||||
|
- Build script unificato (`build_plugin.py`) con CLI canonica
|
||||||
|
- CI/CD via GitHub Actions (mirror automatico Gitea → GitHub)
|
||||||
|
- Documentazione completa (README, CONTRIBUTING, SECURITY)
|
||||||
|
|
||||||
|
---
|
||||||
|
_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
### Fixed
|
||||||
|
- Restored `tools/legacy/` build scripts lost from repository
|
||||||
|
- Fixed `UnicodeEncodeError` on CI: replaced Unicode checkmarks with ASCII OK/FAIL in build summary
|
||||||
|
- Fixed MSB8020 toolset error on GitHub Actions: `build_plugin_2600_vs2026.py` now detects the installed VS toolset dynamically (falls back to v143 on VS2022 runners)
|
||||||
|
- Build script for 26.00 selects `Nsis7z_vs2026.vcxproj` (v145) or `Nsis7z.vcxproj` (v143) based on detected toolset
|
||||||
|
|
||||||
|
---
|
||||||
|
_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
### Added
|
||||||
|
- NSIS plugin API (`pluginapi.cpp`/`pluginapi.h`) for 7-Zip zstd build
|
||||||
|
- `ExtractCallbackConsole` class for extraction progress and user input
|
||||||
|
- Main extraction logic (`Main.cpp`, `MainAr.cpp`) for the zstd bundle
|
||||||
|
- User input utilities (`UserInputUtils2`) for password handling and prompts
|
||||||
|
- Break signal handling (`NSISBreak`) for graceful interruption
|
||||||
|
- `Nsis7z_vs2026.vcxproj` (v145 toolset) for Visual Studio 2026 builds
|
||||||
|
- `tools/fix_vcxproj.py` helper for project file patching
|
||||||
|
- `versions/7-zip-zstd` submodule added
|
||||||
|
- `build_zstd.cmd` top-level build script for the zstd variant
|
||||||
|
|
||||||
|
---
|
||||||
|
_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
### Added
|
||||||
|
- Linux MinGW-w64 cross-build support in `build_plugin.py` via `--host linux`
|
||||||
|
- `tools/linux/build_plugin_linux.py` for standalone Linux builds
|
||||||
|
- Color output and progress spinner in all legacy build scripts
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- `build_plugin.py` now supports both Windows (MSBuild) and Linux (MinGW-w64) targets
|
||||||
|
- Windows build-script f-string fixes
|
||||||
|
|
||||||
|
---
|
||||||
|
_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
### 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
|
||||||
|
|
||||||
|
---
|
||||||
|
_Repository primario: vedi link Gitea nel README. Il mirror GitHub è generato automaticamente._
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
One-shot script: aggiorna il body delle release Gitea esistenti
|
||||||
|
con i file in tools/release-notes/.
|
||||||
|
|
||||||
|
Uso:
|
||||||
|
GITEA_TOKEN=<token> python3 tools/update_gitea_releases.py
|
||||||
|
oppure:
|
||||||
|
python3 tools/update_gitea_releases.py --token <token>
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
GITEA_BASE = "https://gitea.emulab.it/api/v1"
|
||||||
|
REPO = "Simone/nsis-plugin-ns7zip"
|
||||||
|
NOTES_DIR = Path(__file__).parent / "release-notes"
|
||||||
|
|
||||||
|
|
||||||
|
def api(method: str, path: str, token: str, data: dict | None = None) -> dict:
|
||||||
|
url = f"{GITEA_BASE}{path}"
|
||||||
|
body = json.dumps(data).encode() if data else None
|
||||||
|
req = urllib.request.Request(
|
||||||
|
url,
|
||||||
|
data=body,
|
||||||
|
method=method,
|
||||||
|
headers={
|
||||||
|
"Authorization": f"token {token}",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Accept": "application/json",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(req) as resp:
|
||||||
|
return json.loads(resp.read())
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
print(f" HTTP {e.code} {e.reason} — {e.read().decode()}", file=sys.stderr)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
parser = argparse.ArgumentParser(description="Update Gitea release bodies")
|
||||||
|
parser.add_argument("--token", default=os.environ.get("GITEA_TOKEN"), help="Gitea API token")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if not args.token:
|
||||||
|
sys.exit("Errore: token mancante. Usa --token oppure imposta GITEA_TOKEN.")
|
||||||
|
|
||||||
|
note_files = sorted(NOTES_DIR.glob("v*.md"))
|
||||||
|
if not note_files:
|
||||||
|
sys.exit(f"Nessun file trovato in {NOTES_DIR}")
|
||||||
|
|
||||||
|
for note_path in note_files:
|
||||||
|
tag = note_path.stem # es. v2.2.1
|
||||||
|
body = note_path.read_text(encoding="utf-8").strip()
|
||||||
|
|
||||||
|
print(f"[{tag}] recupero release...", end=" ", flush=True)
|
||||||
|
try:
|
||||||
|
release = api("GET", f"/repos/{REPO}/releases/tags/{tag}", args.token)
|
||||||
|
except urllib.error.HTTPError:
|
||||||
|
print("SALTATO (release non trovata)")
|
||||||
|
continue
|
||||||
|
|
||||||
|
release_id = release["id"]
|
||||||
|
print(f"id={release_id}, aggiorno body...", end=" ", flush=True)
|
||||||
|
try:
|
||||||
|
api("PATCH", f"/repos/{REPO}/releases/{release_id}", args.token, {"body": body})
|
||||||
|
print("OK")
|
||||||
|
except urllib.error.HTTPError:
|
||||||
|
print("FALLITO")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
LIBRARY nsis7z
|
||||||
|
EXPORTS
|
||||||
|
Extract
|
||||||
|
ExtractWithDetails
|
||||||
|
ExtractWithCallback
|
||||||
|
ExtractWithFileCallback
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
PROG = nsis7z
|
||||||
|
DEF_FILE = Nsis7z.def
|
||||||
|
|
||||||
|
include ../Format7zF/Arc_gcc.mak
|
||||||
|
|
||||||
|
ifdef IS_MINGW
|
||||||
|
LOCAL_FLAGS_SYS = -DZ7_DEVICE_FILE
|
||||||
|
SYS_OBJS = \
|
||||||
|
$O/DLL.o \
|
||||||
|
$O/DllSecur.o \
|
||||||
|
$O/resource.o \
|
||||||
|
|
||||||
|
else
|
||||||
|
SYS_OBJS = \
|
||||||
|
$O/MyWindows.o \
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_FLAGS += \
|
||||||
|
$(LOCAL_FLAGS_SYS) \
|
||||||
|
$(LOCAL_FLAGS_EXTRA) \
|
||||||
|
|
||||||
|
NSIS_UI_OBJS = \
|
||||||
|
$O/NsisMain.o \
|
||||||
|
$O/NsisMainAr.o \
|
||||||
|
$O/NsisBreak.o \
|
||||||
|
$O/NsisExtractCallbackConsole.o \
|
||||||
|
$O/NsisUserInputUtils2.o \
|
||||||
|
$O/ConsoleOpenCallbackConsole.o \
|
||||||
|
$O/ConsolePercentPrinter.o \
|
||||||
|
$O/ConsoleClose.o \
|
||||||
|
$O/ConsoleUserInputUtils.o \
|
||||||
|
$O/Extract.o \
|
||||||
|
$O/HashCalc.o \
|
||||||
|
$O/OpenArchive.o \
|
||||||
|
$O/ArchiveExtractCallback.o \
|
||||||
|
$O/ArchiveOpenCallback.o \
|
||||||
|
$O/DefaultName.o \
|
||||||
|
$O/EnumDirItems.o \
|
||||||
|
$O/ExtractingFilePath.o \
|
||||||
|
$O/LoadCodecs.o \
|
||||||
|
$O/SetProperties.o \
|
||||||
|
$O/FileStreams.o \
|
||||||
|
$O/FileSystem.o \
|
||||||
|
$O/ErrorMsg.o \
|
||||||
|
$O/FileLink.o \
|
||||||
|
$O/FilePathAutoRename.o \
|
||||||
|
$O/SortUtils.o \
|
||||||
|
$O/PropIDUtils.o \
|
||||||
|
|
||||||
|
CURRENT_OBJS = \
|
||||||
|
$O/StdInStream.o \
|
||||||
|
$O/StdOutStream.o \
|
||||||
|
$O/StdAfx2.o \
|
||||||
|
$O/pluginapi.o \
|
||||||
|
$O/nsis7z.o \
|
||||||
|
|
||||||
|
OBJS = \
|
||||||
|
$(ARC_OBJS) \
|
||||||
|
$(SYS_OBJS) \
|
||||||
|
$(NSIS_UI_OBJS) \
|
||||||
|
$(CURRENT_OBJS) \
|
||||||
|
|
||||||
|
include ../../7zip_gcc.mak
|
||||||
|
|
||||||
|
$O/NsisMain.o: ../../UI/NSIS/Main.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/NsisMainAr.o: ../../UI/NSIS/MainAr.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/NsisBreak.o: ../../UI/NSIS/NSISBreak.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/NsisExtractCallbackConsole.o: ../../UI/NSIS/ExtractCallbackConsole.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/NsisUserInputUtils2.o: ../../UI/NSIS/UserInputUtils2.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/ConsoleOpenCallbackConsole.o: ../../UI/Console/OpenCallbackConsole.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/ConsolePercentPrinter.o: ../../UI/Console/PercentPrinter.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/ConsoleUserInputUtils.o: ../../UI/Console/UserInputUtils.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/StdAfx2.o: StdAfx2.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/pluginapi.o: pluginapi.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
$O/nsis7z.o: nsis7z.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $<
|
||||||
@@ -181,6 +181,7 @@ EXTRACTFUNCEND
|
|||||||
|
|
||||||
extern "C" BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
extern "C" BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
|
(void)lpReserved;
|
||||||
g_hInstance2=(HINSTANCE)hInst;
|
g_hInstance2=(HINSTANCE)hInst;
|
||||||
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,12 +27,14 @@ using namespace NDir;
|
|||||||
|
|
||||||
extern HWND g_hwndProgress;
|
extern HWND g_hwndProgress;
|
||||||
|
|
||||||
|
static const UInt64 k_SizeUnknown = (UInt64)(Int64)-1;
|
||||||
|
|
||||||
void CExtractCallbackConsole::UpdateProgress()
|
void CExtractCallbackConsole::UpdateProgress()
|
||||||
{
|
{
|
||||||
// Prima controlla se c'è il callback con filename (nuova funzione)
|
// Prima controlla se c'è il callback con filename (nuova funzione)
|
||||||
if (ProgressWithFileHandler != NULL)
|
if (ProgressWithFileHandler != NULL)
|
||||||
{
|
{
|
||||||
if (completedSize != -1 || totalSize > 0)
|
if (completedSize != k_SizeUnknown || totalSize > 0)
|
||||||
ProgressWithFileHandler(completedSize, totalSize, CurrentFileName.Ptr());
|
ProgressWithFileHandler(completedSize, totalSize, CurrentFileName.Ptr());
|
||||||
else
|
else
|
||||||
ProgressWithFileHandler(0, 0, CurrentFileName.Ptr());
|
ProgressWithFileHandler(0, 0, CurrentFileName.Ptr());
|
||||||
@@ -40,14 +42,14 @@ void CExtractCallbackConsole::UpdateProgress()
|
|||||||
// Altrimenti usa il callback originale (per compatibilitĂ )
|
// Altrimenti usa il callback originale (per compatibilitĂ )
|
||||||
else if (ProgressHandler != NULL)
|
else if (ProgressHandler != NULL)
|
||||||
{
|
{
|
||||||
if (completedSize != -1 || totalSize > 0)
|
if (completedSize != k_SizeUnknown || totalSize > 0)
|
||||||
ProgressHandler(completedSize, totalSize);
|
ProgressHandler(completedSize, totalSize);
|
||||||
else
|
else
|
||||||
ProgressHandler(0, 0);
|
ProgressHandler(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64 val)
|
Z7_COM7F_IMF(CExtractCallbackConsole::SetTotal(UInt64 val))
|
||||||
{
|
{
|
||||||
totalSize = val;
|
totalSize = val;
|
||||||
UpdateProgress();
|
UpdateProgress();
|
||||||
@@ -56,7 +58,7 @@ STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64 val)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *val)
|
Z7_COM7F_IMF(CExtractCallbackConsole::SetCompleted(const UInt64 *val))
|
||||||
{
|
{
|
||||||
completedSize = *val;
|
completedSize = *val;
|
||||||
UpdateProgress();
|
UpdateProgress();
|
||||||
@@ -65,31 +67,35 @@ STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *val)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
|
Z7_COM7F_IMF(CExtractCallbackConsole::AskOverwrite(
|
||||||
const wchar_t *existName, const FILETIME *, const UInt64 *,
|
const wchar_t *existName, const FILETIME *, const UInt64 *,
|
||||||
const wchar_t *newName, const FILETIME *, const UInt64 *,
|
const wchar_t *newName, const FILETIME *, const UInt64 *,
|
||||||
Int32 *answer)
|
Int32 *answer))
|
||||||
{
|
{
|
||||||
|
(void)existName; (void)newName;
|
||||||
*answer = NOverwriteAnswer::kYesToAll;
|
*answer = NOverwriteAnswer::kYesToAll;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 *position)
|
Z7_COM7F_IMF(CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 *position))
|
||||||
{
|
{
|
||||||
|
(void)isFolder; (void)askExtractMode; (void)position;
|
||||||
// Memorizza il nome del file corrente per passarlo al callback
|
// Memorizza il nome del file corrente per passarlo al callback
|
||||||
CurrentFileName = name;
|
CurrentFileName = name;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
|
Z7_COM7F_IMF(CExtractCallbackConsole::MessageError(const wchar_t *message))
|
||||||
{
|
{
|
||||||
|
(void)message;
|
||||||
NumFileErrorsInCurrentArchive++;
|
NumFileErrorsInCurrentArchive++;
|
||||||
NumFileErrors++;
|
NumFileErrors++;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encrypted)
|
Z7_COM7F_IMF(CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encrypted))
|
||||||
{
|
{
|
||||||
|
(void)encrypted;
|
||||||
switch(opRes)
|
switch(opRes)
|
||||||
{
|
{
|
||||||
case NArchive::NExtract::NOperationResult::kOK:
|
case NArchive::NExtract::NOperationResult::kOK:
|
||||||
@@ -113,7 +119,7 @@ HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
|
Z7_COM7F_IMF(CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password))
|
||||||
{
|
{
|
||||||
if (!PasswordIsDefined)
|
if (!PasswordIsDefined)
|
||||||
{
|
{
|
||||||
@@ -127,6 +133,7 @@ STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
|
|||||||
|
|
||||||
HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
|
HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
|
||||||
{
|
{
|
||||||
|
(void)name; (void)testMode;
|
||||||
NumArchives++;
|
NumArchives++;
|
||||||
NumFileErrorsInCurrentArchive = 0;
|
NumFileErrorsInCurrentArchive = 0;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@@ -134,6 +141,7 @@ HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
|
|||||||
|
|
||||||
HRESULT CExtractCallbackConsole::OpenResult(const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result)
|
HRESULT CExtractCallbackConsole::OpenResult(const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result)
|
||||||
{
|
{
|
||||||
|
(void)codecs; (void)arcLink; (void)name;
|
||||||
if (result != S_OK)
|
if (result != S_OK)
|
||||||
{
|
{
|
||||||
NumArchiveErrors++;
|
NumArchiveErrors++;
|
||||||
|
|||||||
@@ -3,7 +3,13 @@
|
|||||||
#ifndef __STDAFX_H
|
#ifndef __STDAFX_H
|
||||||
#define __STDAFX_H
|
#define __STDAFX_H
|
||||||
|
|
||||||
#include <Windows.h>
|
#ifdef _WIN32
|
||||||
#include "7zip/Bundles/Nsis7z/pluginapi.h"
|
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#include "../../Bundles/Nsis7z/pluginapi.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user