forked from Naxela/The_Lightmapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
72 lines (63 loc) · 3.14 KB
/
Copy pathbuild.ps1
File metadata and controls
72 lines (63 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Build an installable Blender addon zip for The_Lightmapper fork.
# The runtime module name MUST be "thelightmapper" because the background-bake
# subprocess does `import thelightmapper` (see addon/utility/build.py).
#
# Usage:
# ./build.ps1 # produces dist/thelightmapper.zip
# ./build.ps1 -Install # also installs+enables it into Blender 4.5 (headless test)
# ./build.ps1 -Blender "C:\path\to\blender.exe"
param(
[switch]$Install,
[switch]$Test,
[string]$Blender = "C:\Program Files\Blender Foundation\Blender 5.1\blender.exe"
)
$ErrorActionPreference = "Stop"
$root = $PSScriptRoot
$dist = Join-Path $root "dist"
$staging = Join-Path $dist "thelightmapper"
$zip = Join-Path $dist "thelightmapper.zip"
# Clean staging
if (Test-Path $staging) { Remove-Item $staging -Recurse -Force }
if (Test-Path $zip) { Remove-Item $zip -Force }
New-Item -ItemType Directory -Force -Path $staging | Out-Null
# Copy runtime files (exclude dev-only: img/, dist/, .git, build script)
Copy-Item (Join-Path $root "__init__.py") $staging
Copy-Item (Join-Path $root "LICENSE") $staging -ErrorAction SilentlyContinue
Copy-Item (Join-Path $root "addon") (Join-Path $staging "addon") -Recurse
# Drop python caches
Get-ChildItem $staging -Recurse -Include "__pycache__" -Directory | Remove-Item -Recurse -Force
# Zip with thelightmapper/ as the top-level folder
Compress-Archive -Path $staging -DestinationPath $zip -Force
# OneDrive (Documents is synced) can momentarily make a freshly written file
# disappear from the filesystem view. Wait until the zip is really there, and
# re-zip if it vanishes, so -Install/-Test don't fail with "file not found".
for ($i = 0; $i -lt 20 -and -not (Test-Path $zip); $i++) {
Start-Sleep -Milliseconds 250
if (-not (Test-Path $zip)) { Compress-Archive -Path $staging -DestinationPath $zip -Force }
}
if (-not (Test-Path $zip)) { throw "Build produced no zip at $zip (OneDrive sync interference?)" }
Write-Host "Built: $zip"
if ($Install) {
if (-not (Test-Path $Blender)) { throw "Blender not found at $Blender" }
$expr = @"
import bpy
# Never persist this --factory-startup session's prefs: saving them (explicitly
# or via auto-save on exit) would overwrite the real userpref.blend with FACTORY
# defaults, resetting GPU/OptiX, theme, etc. addon_install still updates the real
# scripts/addons dir (so the addon updates), and the enabled state is preserved
# from the user's existing userpref.blend, which we leave untouched.
bpy.context.preferences.use_preferences_save = False
bpy.ops.preferences.addon_install(overwrite=True, filepath=r'$zip')
bpy.ops.preferences.addon_enable(module='thelightmapper')
print('TLM_ADDON_REGISTER_OK')
"@
& $Blender --background --factory-startup --python-expr $expr
}
if ($Test) {
if (-not (Test-Path $Blender)) { throw "Blender not found at $Blender" }
foreach ($t in @("tests\smoketest.py", "tests\smoketest_atlas.py", "tests\smoketest_enableset.py", "tests\smoketest_denoise.py")) {
Write-Host "=== $t ==="
& $Blender --background --python (Join-Path $root $t) 2>&1 |
Select-String -Pattern "OK:|FAIL:|manifest:|SMOKETEST_RESULT"
}
}