-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.ps1
85 lines (73 loc) · 2.69 KB
/
export.ps1
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
73
74
75
76
77
78
79
80
81
82
83
84
85
# Define the list of glob patterns of files that should be exported
$globPatterns = @(
"assets/CREDITS.txt",
"assets/fonts/*.ttf",
"assets/models/*.glb",
"assets/shaders/*.*",
"assets/shaders/gtao/*.*",
"assets/shaders/objects/*.*",
"assets/shaders/terrain/*.*",
"assets/shaders/water/*.*",
"assets/shaders/particles/*.*",
"assets/textures/*.png",
"assets/textures/*.f32",
"assets/textures/*.dds",
"assets/textures/skybox/*.iblenv",
"assets/textures/ui/*.png"
"assets/textures/input/*.png"
"assets/textures/input/*.atlas"
"assets/textures/particle/*.png"
"assets/audio/music/*.ogg"
"assets/audio/music/*.wav"
"assets/audio/sound/*.ogg"
"assets/audio/sound/*.wav"
)
# Define the output zip file name
$outputZipFile = "_bin/release/ptvc24-ascent.zip"
# Ensure that the directory for the output zip file exists
$outputDirectory = Split-Path -parent $outputZipFile
if (-not (Test-Path $outputDirectory)) {
New-Item -Path $outputDirectory -ItemType Directory -Force | Out-Null
}
# Check if the output zip file already exists, and delete it if it does
if (Test-Path $outputZipFile) {
Remove-Item $outputZipFile -Force
Write-Host "Deleted existing $outputZipFile"
}
# Create a new empty zip file
Add-Type -AssemblyName System.IO.Compression.FileSystem
$zipFile = [System.IO.Compression.ZipFile]::Open($outputZipFile, 'Create')
function AddFileToZip($zipFile, $file, $entryName) {
Write-Host "Packing $entryName"
$entry = $zipFile.CreateEntry($entryName)
$entryStream = $entry.Open()
$fileStream = [System.IO.File]::OpenRead($file.FullName)
$fileStream.CopyTo($entryStream)
$fileStream.Close()
$entryStream.Close()
}
# Add files matching each glob pattern to the zip file
foreach ($pattern in $globPatterns) {
$files = Get-ChildItem -Path "." -Filter $pattern -File
foreach ($file in $files) {
$entryName = $file.FullName.Substring($PWD.Path.Length + 1)
AddFileToZip $zipFile $file $entryName
}
}
AddFileToZip $zipFile (Get-ChildItem "README.md") "README.md"
AddFileToZip $zipFile (Get-ChildItem "LICENSE") "LICENSE"
# Check if the executable exists in the release directory
$exePath = "_bin/windows/release/PTVC_Project_GL.exe"
$lastCompileTime = (Get-Item $exePath).LastWriteTime
if (((Get-Date) - $lastCompileTime).TotalHours -gt 1) {
Write-Warning "The compiled exe is older than an hour, may be outdated."
}
if (-not (Test-Path $exePath)) {
Write-Host "Executable not found. Running 'make release'..."
# Run make release
./make release
}
AddFileToZip $zipFile (Get-ChildItem $exePath) "Ascent.exe"
# Close the zip file
$zipFile.Dispose()
Write-Host "Assets zipped as $outputZipFile"