-
Notifications
You must be signed in to change notification settings - Fork 6
/
!Rebuild.ps1
476 lines (405 loc) · 18.5 KB
/
!Rebuild.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
#Requires -Version 5
# args
param(
[switch]$Bootstrap,
[switch]$Update,
[switch]$WhatIf,
[ValidateSet('AE', 'SE', 'VR', 'ALL', 'PRE-AE', 'FLATRIM')][string]$Runtime = 'ALL',
[Alias('C', 'Custom')][switch]$CustomCLib,
[Alias('N', 'NoBuild')][switch]$NoPrebuild,
[Alias('DBG')][string[]]$EnableDebugger,
[Alias('D')][string[]]$ExtraCMakeArgument
)
$ErrorActionPreference = 'Stop'
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
$env:DKScriptVersion = '23626'
$env:RebuildInvoke = $true
$env:ScriptCulture = (Get-Culture).Name -eq 'zh-CN'
function L {
param (
[Parameter(Mandatory)][string]$en,
[string]$zh = ''
)
process {
if ($env:ScriptCulture -and $zh) {
return $zh
}
else {
return $en
}
}
}
[IO.Directory]::SetCurrentDirectory($PSScriptRoot)
Set-Location $PSScriptRoot
# @@BOOTSTRAP
if ($Bootstrap) {
function Initialize-Repo {
param (
[string]$EnvName,
[string]$RepoName,
[string]$Token,
[string]$Path,
[string]$RemoteUrl
)
process {
if (Test-Path "$PSScriptRoot/$Path/$Token" -PathType Leaf) {
Write-Host "`n`t* Located local $RepoName " -ForegroundColor Green
}
else {
Remove-Item "$PSScriptRoot/$Path" -Recurse -Force -Confirm:$false -ErrorAction:SilentlyContinue
Write-Host "`n`t- Bootstrapping $RepoName..." -ForegroundColor Yellow -NoNewline
& git clone $RemoteUrl $Path -q
Write-Host "`r`t- Installed $RepoName " -ForegroundColor Green
}
$CurrentEnv = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$PSScriptRoot/$Path")
Write-Host "`t`t- Mapping path, please wait..." -NoNewline
Start-Job {
if ($RepoName -notlike '*CommonLib*') {
Push-Location $using:CurrentEnv
& git checkout -f master -q
Pop-Location
}
[System.Environment]::SetEnvironmentVariable($using:EnvName, $using:CurrentEnv, [System.EnvironmentVariableTarget]::Machine)
} | Out-Null
Write-Host "`r`t`t- $EnvName has been set to [$CurrentEnv] "
}
}
function Find-Game {
param (
[string]$EnvName,
[string]$GameName
)
process {
Write-Host "`n`t! Missing $GameName" -ForegroundColor Red -NoNewline
$Result = [Microsoft.VisualBasic.Interaction]::MsgBox("Add build support for $($GameName)?`n`nMake sure to select correct version of game if proceeding.", 'YesNo,MsgBoxSetForeground,Question', 'Game Build Support')
while ($Result -eq 6) {
$SkyrimFile = New-Object System.Windows.Forms.OpenFileDialog -Property @{
Title = "Select $($GameName) Executable"
Filter = 'Skyrim Game (SkyrimSE.exe) | SkyrimSE.exe'
}
$SkyrimFile.ShowDialog() | Out-Null
if (Test-Path $SkyrimFile.Filename -PathType Leaf) {
$CurrentEnv = Split-Path $SkyrimFile.Filename
Write-Host "`r`t* Located $GameName " -ForegroundColor Green
Write-Host "`t`t- Mapping path, please wait..." -NoNewline
Start-Job { [System.Environment]::SetEnvironmentVariable($using:EnvName, $using:CurrentEnv, [System.EnvironmentVariableTarget]::Machine) } | Out-Null
Write-Host "`r`t`t- $EnvName has been set to [$CurrentEnv] "
break
}
else {
$Result = [Microsoft.VisualBasic.Interaction]::MsgBox("Unable to locate $($GameName), try again?", 'YesNo,MsgBoxSetForeground,Exclamation', 'Game Build Support')
}
}
$MO2EnvName = 'MO2' + $EnvName
$Result = [Microsoft.VisualBasic.Interaction]::MsgBox("Enable MO2 support for $($GameName)?`n`nMO2 Support: Allows plugin to be directly copied to MO2 directory for faster debugging.", 'YesNo,MsgBoxSetForeground,Question', 'MO2 Support')
$MO2Dir = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{
Description = "Select MO2 directory for $($GameName), containing /mods, /profiles, and /override folders."
ShowNewFolderButton = $false
}
while ($Result -eq 6) {
$MO2Dir.ShowDialog() | Out-Null
if (Test-Path "$($MO2Dir.SelectedPath)/mods" -PathType Container) {
Write-Host "`tMapping path, please wait..." -NoNewline
$MO2Dir = $MO2Dir.SelectedPath
Start-Job { [System.Environment]::SetEnvironmentVariable($using:MO2EnvName, $using:MO2Dir, [System.EnvironmentVariableTarget]::Machine) } | Out-Null
Write-Host "`r`t* Enabled MO2 support for $GameName " -ForegroundColor Green
break
}
else {
$Result = [Microsoft.VisualBasic.Interaction]::MsgBox("Not a valid MO2 path, try again?`n`nMO2 directory contains /mods, /profiles, and /override folders", 'YesNo,MsgBoxSetForeground,Exclamation', 'MO2 Support')
}
}
}
}
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$admin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (!$admin) {
Write-Host "`tExecute with admin privilege to continue!" -ForegroundColor Red
Exit
}
$Signature = Get-AuthenticodeSignature "$PSScriptRoot\!Rebuild.ps1"
if ($Signature.Status -ne 'Valid') {
Write-Host "`t! Self signing updating..." -ForegroundColor Yellow -NoNewline
Get-ChildItem Cert:\LocalMachine -Recurse | Where-Object { $_.Subject -eq 'CN=DKScriptSelfCert' } | Remove-Item -Force -ErrorAction:SilentlyContinue
$authenticode = New-SelfSignedCertificate -Subject 'DKScriptSelfCert' -CertStoreLocation Cert:\LocalMachine\My -Type CodeSigningCert
foreach ($store in @([System.Security.Cryptography.X509Certificates.StoreName]::Root, [System.Security.Cryptography.X509Certificates.StoreName]::TrustedPublisher)) {
$Cert = [System.Security.Cryptography.X509Certificates.X509Store]::new($store, [System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine)
$Cert.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
$Cert.Add($authenticode)
$Cert.Close()
}
$scriptCert = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Subject -eq 'CN=DKScriptSelfCert' }
@('!MakeNew.ps1', '!Rebuild.ps1', '!Update.ps1') | ForEach-Object {
Set-AuthenticodeSignature "$PSScriptRoot/$_" -Certificate $scriptCert -TimeStampServer 'http://timestamp.digicert.com' | Out-Null
}
$Signature = Get-AuthenticodeSignature "$PSScriptRoot/!Rebuild.ps1"
if ($Signature.Status -ne 'Valid') {
Write-Host "`r`t! Failed to complete self signing process! " -ForegroundColor Red
Exit
}
else {
Write-Host "`r`t* Self signing complete `n" -ForegroundColor Green
}
$OldPolicy = Get-ExecutionPolicy -Scope LocalMachine
if ($OldPolicy -eq 'Restricted') {
Write-Host "`t* Updated ExecutionPolicy to [RemoteSigned] on [LocalMachine]"
Set-ExecutionPolicy RemoteSigned -Scope LocalMachine
}
}
if ($Update.IsPresent) {
Exit
}
Add-Type -AssemblyName Microsoft.VisualBasic
Add-Type -AssemblyName System.Windows.Forms
Write-Host "`tBOOTSTRAP initiating, please wait..." -ForegroundColor Red -NoNewline
foreach ($env in @('CommonLibSSEPath', 'CustomCommonLibSSEPath', 'DKUtilPath', 'SkyrimSEPath', 'SkyrimAEPath', 'SkyrimVRPath', 'MO2SkyrimSEPath', 'MO2SkyrimAEPath', 'MO2SkyrimVRPath', 'SKSETemplatePath', 'SKSEPluginAuthor')) {
Start-Job { [Environment]::SetEnvironmentVariable($using:env, $null, [System.EnvironmentVariableTarget]::Machine) } | Out-Null
}
Get-Job | Wait-Job | Out-Null
Write-Host "`r`tBOOTSTRAP initiated! " -ForegroundColor Yellow
Write-Host "`t>>> Checking out requirements... <<<" -ForegroundColor Yellow
# VCPKG_ROOT
if (Test-Path "$env:VCPKG_ROOT/vcpkg.exe" -PathType Leaf) {
Write-Host "`n`t* Located local VCPKG" -ForegroundColor Green
}
else {
Initialize-Repo 'VCPKG_ROOT' 'VCPKG' 'vcpkg.exe' 'vcpkg' 'https://github.com/microsoft/vcpkg'
& $PSScriptRoot/vcpkg/bootstrap-vcpkg.bat | Out-Null
& $PSScriptRoot/vcpkg/vcpkg.exe integrate install | Out-Null
}
# CommonLibSSEPath
Initialize-Repo 'CommonLibSSEPath' 'CommonLibSSE-NG' 'CMakeLists.txt' 'Library/CommonLibSSE-NG' 'https://github.com/CharmedBaryon/CommonLibSSE-NG'
$Result = [Microsoft.VisualBasic.Interaction]::MsgBox("Enable custom CLib support?`n`nThis is for people who maintain their own modification of CommonLibSSE-NG", 'YesNo,MsgBoxSetForeground,Question', 'Custom CLib support')
while ($Result -eq 6) {
$CustomCLibDir = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{
Description = 'Select custom CommonLibSSE directory, containing CMakeLists.txt'
}
$CustomCLibDir.ShowDialog() | Out-Null
if (Test-Path "$($CustomCLibDir.SelectedPath)/CMakeLists.txt" -PathType Leaf) {
Write-Host "`n`t* Enabled custom CommonLibSSE" -ForegroundColor Green
$CustomCLibDir = $CustomCLibDir.SelectedPath
Start-Job { [System.Environment]::SetEnvironmentVariable('CustomCommonLibSSEPath', $using:CustomCLibDir, [System.EnvironmentVariableTarget]::Machine) } | Out-Null
Write-Host "`t`t- CustomCommonLibSSEPath has been set to [$($CustomCLibDir)]"
Write-Host "`t`t# To use custom CommonLibSSE-NG in build, append switch parameter '-C', '-Custom', or '-CustomCLib' to the !Rebuild command."
break
}
else {
$Result = [Microsoft.VisualBasic.Interaction]::MsgBox('Unable to locate valid CMakeLists.txt, try again?', 'YesNo,MsgBoxSetForeground,Exclamation', 'Custom CLib support')
}
}
# DKUtilPath
Initialize-Repo 'DKUtilPath' 'DKUtil' 'CMakeLists.txt' 'Library/DKUtil' 'https://github.com/gottyduke/DKUtil'
# SKSETemplatePath
Initialize-Repo 'SKSETemplatePath' 'SKSETemplate' 'CMakeLists.txt' 'Plugins/Template' 'https://github.com/gottyduke/Template'
# SkyrimSEPath
Find-Game 'SkyrimSEPath' 'Skyrim Special Edition (1.5.97)'
# SkyrimAEPath
Find-Game 'SkyrimAEPath' 'Skyrim Anniversary Edition (1.6.xxx)'
# SkyrimAEPath
Find-Game 'SkyrimVRPath' 'Skyrim VR (1.3.64)'
$Author = $null
while (!$Author) {
$Author = [Microsoft.VisualBasic.Interaction]::InputBox("Input the plugin author name:`n`nThis cannot be null", 'Author', 'ToddHoward')
}
Start-Job { [System.Environment]::SetEnvironmentVariable('SKSEPluginAuthor', $using:Author, [System.EnvironmentVariableTarget]::Machine) } | Out-Null
Write-Host "`n`t* Plugin author: $Author" -ForegroundColor Magenta
# TODO setup bethesda scripts
# TODO setup versionlib support
Write-Host "`n`t>>> Bootstrapping finishing up... <<<" -ForegroundColor Green
Get-Job | Wait-Job | Out-Null
Get-Job | Remove-Job | Out-Null
Write-Host "`n`tRestart current command line interface to complete BOOTSTRAP."
Exit
}
function Normalize ($text) {
return $text -replace '\\', '/'
}
function Add-Subdirectory ($Name, $Path) {
return Normalize "message(CHECK_START `"Rebuilding $Name`")`nadd_subdirectory($Path)`nmessage(CHECK_PASS `"Complete`")"
}
function Restore {
Copy-Item "$env:CommonLibSSEPath/CMakeLists.txt.disabled" "$env:CommonLibSSEPath/CMakeLists.txt" -Force -Confirm:$false -ErrorAction:SilentlyContinue | Out-Null
Remove-Item "$env:CommonLibSSEPath/CMakeLists.txt.disabled" -Force -Confirm:$false -ErrorAction:SilentlyContinue | Out-Null
Exit
}
Write-Host "`tDKScriptVersion $env:DKScriptVersion`t$Runtime`n"
# @@CLib
$CMakeLists = [System.Collections.ArrayList]::new(256)
$CLibType = 'NG'
if ($CustomCLib -and !(Test-Path "$env:CustomCommonLibSSEPath/CMakeLists.txt" -PathType Leaf)) {
$CustomCLib = $false
Write-Host "`t! CustomCLib invoked but target path does not contain valid CMakeLists!`n`t`t# Path: $($env:CustomCommonLibSSEPath)`n`tFallback to default CLib..." -ForegroundColor Orange
}
if ($CustomCLib) {
$env:CommonLibSSEPath = $env:CustomCommonLibSSEPath
$CLibType = 'Custom'
}
elseif (!(Test-Path "$env:CommonLibSSEPath/CMakeLists.txt" -PathType Leaf)) {
Write-Host "`tNone of the CLib paths is valid!`n`tOR`n`tIncorrect Bootstrap" -ForegroundColor Red
Exit
}
$CMakeLists.Add("`nset(`ENV{CommonLibSSEPath} `"$(Normalize $env:CommonLibSSEPath)`")`n") | Out-Null
$CMakeLists.Add((Add-Subdirectory "CommonLib-$CLibType" '$ENV{CommonLibSSEPath} "CLib"')) | Out-Null
Write-Host "`t===> Rebasing for [$Runtime] Runtime <===`n" -ForegroundColor DarkYellow
Copy-Item "$env:CommonLibSSEPath/CMakeLists.txt" "$env:CommonLibSSEPath/CMakeLists.txt.disabled" -Force -Confirm:$false -ErrorAction:SilentlyContinue | Out-Null
Copy-Item "$PSScriptRoot/cmake/SKSE.CMakeLists.CLib.txt" "$env:CommonLibSSEPath/CMakeLists.txt" -Force -Confirm:$false -ErrorAction:SilentlyContinue | Out-Null
# @@Patch : Disable Visual Studio 17.6.0+ <BuildStlModules> using c++23 standard
$VSBuildVer = 0.0
$VSWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $VSWhere -PathType Leaf) {
$VSBuildVer = & $VSWhere -latest -property catalog_buildBranch
[single]$VSBuildVer = $VSBuildVer.Substring(1)
}
if ($VSBuildVer -ge 17.6) {
[xml]$stl = @"
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<BuildStlModules>false</BuildStlModules>
</ClCompile>
</ItemDefinitionGroup>
</Project>
"@
$stl.Save("$PSScriptRoot/build_stl_modules.props")
$CMakeLists.Add((Normalize "set_property(TARGET CommonLibSSE PROPERTY VS_USER_PROPS `"$PSScriptRoot/build_stl_modules.props`")")) | Out-Null
}
# @@CMake Targets
$AcceptedSubfolder = @('Library', 'Plugins')
$ExcludedSubfolder = 'Template|CommonLib'
Write-Host "`tFinding CMake targets..."
$ProjectVCPKG = [IO.File]::ReadAllText("$PSScriptRoot/cmake/vcpkg.json.in") | ConvertFrom-Json
foreach ($subfolder in $AcceptedSubfolder) {
$CMakeLists.Add("`nset(GROUP `"$subfolder`")`n") | Out-Null
Get-ChildItem "$PSScriptRoot/$subfolder" -Directory | Where-Object {
$_.Name -notmatch $ExcludedSubfolder
} | Resolve-Path -Relative | ForEach-Object {
if (Test-Path "$_/CMakeLists.txt" -PathType Leaf) {
$TargetPath = $_.Substring(2)
$TargetName = $_.Substring(10)
Write-Host "`t`t[ $TargetName ]"
$vcpkg = [IO.File]::ReadAllText("$_/vcpkg.json") | ConvertFrom-Json
$ProjectVCPKG.dependencies += $vcpkg.'dependencies'
if ($EnableDebugger -and $EnableDebugger.Contains($TargetName)) {
$TargetName += 'Debugger'
}
$CMakeLists.Add((Add-Subdirectory $TargetPath $TargetPath)) | Out-Null
$CMakeLists.Add((Normalize "fipch($TargetName $TargetPath)")) | Out-Null
$CMakeLists.Add((Normalize "define_external($TargetName)")) | Out-Null
# @@Temp fix
if ($VSBuildVer -ge 17.6) {
$CMakeLists.Add((Normalize "set_property(TARGET $TargetName PROPERTY VS_USER_PROPS `"$PSScriptRoot/build_stl_modules.props`")")) | Out-Null
}
}
}
}
$Deps = @()
foreach ($dep in $ProjectVCPKG.dependencies) {
$tmp = $dep
if ($dep.name) {
$tmp = $dep.name
}
if ($dep.features) {
$tmp += " <$($dep.features)>"
}
$Deps += $tmp
}
$Deps = $Deps | Sort-Object -Unique
$Header = @((Get-Date -UFormat '# !Rebuild generated @ %R %B %d'), "# DKScriptVersion $env:DKScriptVersion")
$Boiler = [IO.File]::ReadAllLines("$PSScriptRoot/cmake/SKSE.CMakeLists.txt")
$CMakeLists = $Header + $Boiler + $CMakeLists
$CMakeLists = $CMakeLists -replace '\sskse64', "`tSKSE64_$($Runtime.ToUpper())"
[IO.File]::WriteAllLines("$PSScriptRoot/CMakeLists.txt", $CMakeLists)
$ProjectVCPKG.dependencies = $ProjectVCPKG.dependencies | Sort-Object -Unique
$ProjectVCPKG = $ProjectVCPKG | ConvertTo-Json -Depth 9
[IO.File]::WriteAllText("$PSScriptRoot/vcpkg.json", $ProjectVCPKG)
# @@Debugger
if ($EnableDebugger.Count) {
Write-Host "`tEnabled debugger:"
foreach ($enabledDebugger in $EnableDebugger) {
Write-Host "`t`t- $enabledDebugger"
}
}
# @@WhatIf
if ($WhatIf) {
Write-Host "`tPrebuild complete" -ForegroundColor Green
Invoke-Item "$PSScriptRoot/CMakeLists.txt"
}
# @@CMake Generator
Remove-Item "$PSScriptRoot/Build" -Recurse -Force -Confirm:$false -ErrorAction:Ignore | Out-Null
Write-Host "`tCleaned build folder"
$Arguments = @(
'-Wno-dev'
)
foreach ($enabledDebugger in $EnableDebugger) {
$Arguments += "-D$($enabledDebugger.ToUpper())_DEBUG_BUILD:BOOL=1"
}
foreach ($extraArg in $ExtraCMakeArgument) {
$Arguments += "-D$extraArg"
}
$CurProject = $null
Write-Host "`tListing vcpkg dependencies: "
$Deps | ForEach-Object {
"`t`t[ $_ ]"
}
Write-Host "`tBuilding dependencies & generating solution..."
$CMake = & cmake.exe -B $PSScriptRoot/Build -S $PSScriptRoot --preset=$($Runtime.ToUpper()) $Arguments | ForEach-Object {
if ($_.StartsWith('-- Rebuilding ') -and !($_.EndsWith(' - Complete'))) {
$CurProject = $_.Substring(14)
Write-Host "`t`t! [Building] $CurProject" -ForegroundColor Yellow -NoNewline
}
elseif ($_.Contains('CMake Error')) {
Write-Host "`r`t`t* [Failed] $CurProject " -ForegroundColor Red
}
elseif ($_.StartsWith('-- Rebuilding ') -and $_.EndsWith(' - Complete')) {
Write-Host "`r`t`t* [Complete] $CurProject " -ForegroundColor Cyan
}
$_
}
if ($CMake[-2] -notlike '*Generating done*') {
Write-Host "`tFailed generating solution!" -ForegroundColor Red
$CMake
}
else {
Write-Host "`tFinished generating solution!`n`n`tYou may open the skse64.sln and starting coding." -ForegroundColor Green
Invoke-Item "$PSScriptRoot/Build"
if ($VSBuildVer -ge 17.6) {
Write-Host "`n`tPatched project files for Visual Studio 17.6+ version, regarding c++23 std modules. `n`thttps://gitlab.kitware.com/cmake/cmake/-/issues/24922`n" -ForegroundColor Yellow
}
# @@Compile
if (!$NoPrebuild) {
Write-Host "`n`tCompiling CommonLib in the background.`n`t# To disable this behavior, append switch `-N` or `-NoBuild` to the !Rebuild command."
Write-Host "`n`tDo not close the compiler windows! Wait for background compilers to finish." -ForegroundColor Red
Start-Process cmd.exe -ArgumentList "/k cmake.exe --build Build/CLib --config Debug && exit"
Start-Process cmd.exe -ArgumentList "/k cmake.exe --build Build/CLib --config Release && exit"
}
# @@QuickBuild
$Invocation = "@echo off`n" + 'powershell -ExecutionPolicy Bypass -Command "& %~dp0/!Rebuild.ps1 '
$Invocation += " $($Runtime)"
if ($CustomCLib) {
$Invocation += " -custom"
}
if ($NoPrebuild) {
$Invocation += " -nobuild"
}
if ($EnableDebugger) {
$Invocation += " -dbg"
foreach ($enabledDebugger in $EnableDebugger) {
$Invocation += " $($enabledDebugger)"
}
}
if ($ExtraCMakeArgument) {
$Invocation += " -d"
foreach ($extraArg in $ExtraCMakeArgument) {
$Invocation += " $($extraArg)"
}
}
$Invocation += '"'
$Batch = Get-ChildItem "$PSSciptRoot" -File | Where-Object { ($_.Extension -eq '.cmd') -and ($_.BaseName.StartsWith('!_LAST_')) } | ForEach-Object {
Remove-Item "$_" -Confirm:$false -Force -ErrorAction:SilentlyContinue | Out-Null
}
$Batch = "!_LAST_$($Runtime.ToUpper())$(if ($CustomCLib) {"_CUSTOM"}).cmd"
[IO.File]::WriteAllText("$PSScriptRoot/$Batch", $Invocation)
Write-Host "`tTo rebuild with same configuration, use the generated batch file.`n`t* $Batch *" -ForegroundColor Green
Write-Host "`n`t!Rebuild will now exit." -ForegroundColor Green
}