forked from BGforgeNet/Fallout2_Restoration_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
110 lines (84 loc) · 2.85 KB
/
build.ps1
File metadata and controls
110 lines (84 loc) · 2.85 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#Requires -Version 7.0
<#
.SYNOPSIS
Builds the mcmiria.int script from mcmiria.ssl using the sslc compiler.
.DESCRIPTION
Downloads compile.exe and parser.dll from the sslc GitHub release,
then compiles scripts_src/modoc/mcmiria.ssl into mcmiria.int.
#>
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$sslcTag = '2026-02-07-11-20-26'
$baseUrl = "https://github.com/sfall-team/sslc/releases/download/$sslcTag"
$repoRoot = $PSScriptRoot
# --- Step 1: Download compile.exe and parser.dll to a temp folder ---
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) "sslc-$sslcTag"
if (-not (Test-Path $tempDir)) {
try {
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
}
catch {
Write-Error "Failed to create temp directory '$tempDir': $_"
exit 1
}
}
$files = @('compile.exe', 'parser.dll')
foreach ($file in $files) {
$url = "$baseUrl/$file"
$dest = Join-Path $tempDir $file
if (Test-Path $dest) {
Write-Host "Already downloaded: $dest"
continue
}
Write-Host "Downloading $url ..."
try {
Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing
}
catch {
Write-Error "Failed to download '$url'. Check your internet connection and that the release exists.`n$_"
exit 1
}
if (-not (Test-Path $dest)) {
Write-Error "Download appeared to succeed but '$dest' was not found on disk."
exit 1
}
Write-Host "Saved: $dest"
}
$compilePath = Join-Path $tempDir 'compile.exe'
# --- Step 2: Change to scripts_src/modoc ---
$modocDir = Join-Path $repoRoot 'scripts_src' 'modoc'
if (-not (Test-Path $modocDir)) {
Write-Error "Source directory not found: '$modocDir'. Make sure you are running this script from the repository root."
exit 1
}
Push-Location $modocDir
Write-Host "Working directory: $modocDir"
try {
# --- Step 3: Compile mcmiria.ssl ---
$sslFile = 'mcmiria.ssl'
$intFile = 'mcmiria.int'
if (-not (Test-Path $sslFile)) {
Write-Error "Source file '$sslFile' not found in '$modocDir'."
exit 1
}
# Remove stale output if present
if (Test-Path $intFile) {
Remove-Item $intFile -Force
}
Write-Host "Compiling $sslFile ..."
& $compilePath -p -l -O2 -s -q -n $sslFile -o $intFile
if ($LASTEXITCODE -ne 0) {
Write-Error "Compilation failed with exit code $LASTEXITCODE."
exit 1
}
# --- Step 4: Verify output ---
if (-not (Test-Path $intFile)) {
Write-Error "Compilation appeared to succeed (exit code 0) but '$intFile' was not created in '$modocDir'."
exit 1
}
$fullIntPath = (Resolve-Path $intFile).Path
Write-Host "Build successful: $fullIntPath"
}
finally {
Pop-Location
}