@@ -44,7 +44,7 @@ class BuildProject {
44
44
[string ] $buildCachePath
45
45
[string ] $cookerOutputPath
46
46
[string ] $makeFingerprintsPath
47
- [string []] $thismodpackages
47
+ [string []] $modScriptPackages
48
48
[bool ] $isHl
49
49
[bool ] $cookHL
50
50
[PSCustomObject ] $contentOptions
@@ -102,25 +102,42 @@ class BuildProject {
102
102
$this._ConfirmPaths ()
103
103
$this._SetupUtils ()
104
104
$this._LoadContentOptions ()
105
- $this._PerformStep ({ ($_ )._CleanAdditional() }, " Cleaning" , " Cleaned" , " additional mods" )
105
+
106
+ if ($this._HasScriptPackages ()) {
107
+ $this._PerformStep ({ ($_ )._CleanAdditional() }, " Cleaning" , " Cleaned" , " additional mods" )
108
+ }
109
+
106
110
$this._PerformStep ({ ($_ )._CopyModToSdk() }, " Mirroring" , " Mirrored" , " mod to SDK" )
107
111
$this._PerformStep ({ ($_ )._ConvertLocalization() }, " Converting" , " Converted" , " Localization UTF-8 -> UTF-16" )
108
- $this._PerformStep ({ ($_ )._CopyToSrc() }, " Populating" , " Populated" , " Development\Src folder" )
109
- $this._PerformStep ({ ($_ )._RunPreMakeHooks() }, " Running" , " Ran" , " Pre-Make hooks" )
110
- $this._PerformStep ({ ($_ )._CheckCleanCompiled() }, " Verifying" , " Verified" , " compiled script packages" )
111
- $this._PerformStep ({ ($_ )._RunMakeBase() }, " Compiling" , " Compiled" , " base-game script packages" )
112
- $this._PerformStep ({ ($_ )._RunMakeMod() }, " Compiling" , " Compiled" , " mod script packages" )
113
- $this._RecordCoreTimestamp ()
114
- if ($this.isHl ) {
115
- if (-not $this.debug ) {
116
- $this._PerformStep ({ ($_ )._RunCookHL() }, " Cooking" , " Cooked" , " Highlander packages" )
117
- } else {
118
- Write-Host " Skipping cooking as debug build"
112
+
113
+ if ($this._ShouldCompileBase ()) {
114
+ $this._PerformStep ({ ($_ )._CopyToSrc() }, " Populating" , " Populated" , " Development\Src folder" )
115
+ $this._PerformStep ({ ($_ )._RunPreMakeHooks() }, " Running" , " Ran" , " Pre-Make hooks" )
116
+ $this._PerformStep ({ ($_ )._CheckCleanCompiled() }, " Verifying" , " Verified" , " compiled script packages" )
117
+ $this._PerformStep ({ ($_ )._RunMakeBase() }, " Compiling" , " Compiled" , " base-game script packages" )
118
+ }
119
+
120
+ if ($this._HasScriptPackages ()) {
121
+ $this._PerformStep ({ ($_ )._RunMakeMod() }, " Compiling" , " Compiled" , " mod script packages" )
122
+ }
123
+
124
+ if ($this._ShouldCompileBase ()) {
125
+ $this._RecordCoreTimestamp ()
126
+ }
127
+
128
+ if ($this._HasScriptPackages ()) {
129
+ if ($this.isHl ) {
130
+ if (-not $this.debug ) {
131
+ $this._PerformStep ({ ($_ )._RunCookHL() }, " Cooking" , " Cooked" , " Highlander packages" )
132
+ } else {
133
+ Write-Host " Skipping HL cooking as debug build"
134
+ }
119
135
}
136
+
137
+ $this._PerformStep ({ ($_ )._CopyScriptPackages() }, " Copying" , " Copied" , " compiled script packages" )
120
138
}
121
- $this._PerformStep ({ ($_ )._CopyScriptPackages() }, " Copying" , " Copied" , " compiled script packages" )
122
-
123
- # The shader step needs to happen before cooking - precompiler gets confused by some inlined materials
139
+
140
+ # The shader step needs to happen before asset cooking - precompiler gets confused by some inlined materials
124
141
$this._PerformStep ({ ($_ )._PrecompileShaders() }, " Precompiling" , " Precompiled" , " shaders" )
125
142
126
143
$this._PerformStep ({ ($_ )._RunCookAssets() }, " Cooking" , " Cooked" , " mod assets" )
@@ -130,8 +147,10 @@ class BuildProject {
130
147
$this._PerformStep ({ ($_ )._CopyMissingUncooked() }, " Copying" , " Copied" , " requested uncooked packages" )
131
148
132
149
$this._PerformStep ({ ($_ )._FinalCopy() }, " Copying" , " Copied" , " built mod to game directory" )
150
+
133
151
$fullStopwatch.Stop ()
134
152
$this._ReportTimings ($fullStopwatch )
153
+
135
154
SuccessMessage " *** SUCCESS! ($ ( FormatElapsed $fullStopwatch.Elapsed ) ) ***" $this.modNameCanonical
136
155
}
137
156
catch {
@@ -217,7 +236,31 @@ class BuildProject {
217
236
218
237
# build package lists we'll need later and delete as appropriate
219
238
# the mod's packages
220
- $this.thismodpackages = Get-ChildItem " $ ( $this.modSrcRoot ) /Src" - Directory
239
+ $modSrcPath = " $ ( $this.modSrcRoot ) /Src"
240
+ if (Test-Path $modSrcPath ) {
241
+ $this.modScriptPackages = @ (Get-ChildItem " $ ( $this.modSrcRoot ) /Src" - Directory)
242
+ } else {
243
+ # No scripts to compile
244
+ $this.modScriptPackages = @ ()
245
+ }
246
+
247
+ if (! $this._HasScriptPackages ()) {
248
+ if ($this.clean.Length -gt 0 ) {
249
+ ThrowFailure " AddToClean is not supported when no script packages to compile"
250
+ }
251
+
252
+ if ($this.include.Length -gt 0 ) {
253
+ ThrowFailure " IncludeSrc is not supported when no script packages to compile"
254
+ }
255
+
256
+ if ($this.preMakeHooks.Length -gt 0 ) {
257
+ ThrowFailure " AddPreMakeHook is not supported when no script packages to compile"
258
+ }
259
+
260
+ if ($this.debug ) {
261
+ ThrowFailure " Debug build enabled but no script packages to compile"
262
+ }
263
+ }
221
264
222
265
$this.isHl = $this._HasNativePackages ()
223
266
$this.cookHL = $this.isHl -and -not $this.debug
@@ -308,7 +351,9 @@ class BuildProject {
308
351
Robocopy.exe " $ ( $this.modSrcRoot ) " " $ ( $this.stagingPath ) " * .* $global :def_robocopy_args / XF @xf / XD " ContentForCook"
309
352
Write-Host " Copied project to staging."
310
353
311
- New-Item " $ ( $this.stagingPath ) /Script" - ItemType Directory
354
+ if ($this._HasScriptPackages ()) {
355
+ New-Item " $ ( $this.stagingPath ) /Script" - ItemType Directory
356
+ }
312
357
313
358
# read mod metadata from the x2proj file
314
359
Write-Host " Reading mod metadata from $ ( $this.modX2ProjPath ) "
@@ -369,10 +414,12 @@ class BuildProject {
369
414
}
370
415
Write-Host " Copied dependency sources to Src."
371
416
372
- # copying the mod's scripts to the script staging location
373
- Write-Host " Copying the mod's sources to Src..."
374
- $this._CopySrcFolder (" $ ( $this.modSrcRoot ) \Src" )
375
- Write-Host " Copied mod sources to Src."
417
+ if ($this._HasScriptPackages ()) {
418
+ # copying the mod's scripts to the script staging location
419
+ Write-Host " Copying the mod's sources to Src..."
420
+ $this._CopySrcFolder (" $ ( $this.modSrcRoot ) \Src" )
421
+ Write-Host " Copied mod sources to Src."
422
+ }
376
423
}
377
424
378
425
[void ]_CopySrcFolder([string ] $includeDir ) {
@@ -523,7 +570,7 @@ class BuildProject {
523
570
[bool ]_HasNativePackages() {
524
571
# Check if this is a Highlander and we need to cook things
525
572
$anynative = $false
526
- foreach ($name in $this.thismodpackages )
573
+ foreach ($name in $this.modScriptPackages )
527
574
{
528
575
if ($global :nativescriptpackages.Contains ($name )) {
529
576
$anynative = $true
@@ -533,9 +580,26 @@ class BuildProject {
533
580
return $anynative
534
581
}
535
582
583
+ [bool ] _HasScriptPackages () {
584
+ return $this.modScriptPackages.Length -gt 0
585
+ }
586
+
587
+ [bool ] _ShouldCompileBase () {
588
+ if ($this._HasScriptPackages ()) {
589
+ return $true
590
+ }
591
+
592
+ # We need to compile base game scripts if cooking assets, otherwise the cooker will just crash if the SDK was cleaned beforehand
593
+ if ($this._AnyAssetsToCook ()) {
594
+ return $true
595
+ }
596
+
597
+ return $false
598
+ }
599
+
536
600
[void ]_CopyScriptPackages() {
537
601
# copy packages to staging
538
- foreach ($name in $this.thismodpackages ) {
602
+ foreach ($name in $this.modScriptPackages ) {
539
603
if ($this.cookHL -and $global :nativescriptpackages.Contains ($name ))
540
604
{
541
605
# This is a native (cooked) script package -- copy important upks
@@ -787,6 +851,10 @@ class BuildProject {
787
851
$exitCode = $process.ExitCode
788
852
$receiver.Finish ($exitCode )
789
853
}
854
+
855
+ [bool ] _AnyAssetsToCook () {
856
+ return ($this.contentOptions.sfStandalone.Length -gt 0 ) -or ($this.contentOptions.sfMaps.Length -gt 0 ) -or ($this.contentOptions.sfCollectionMaps.Length -gt 0 )
857
+ }
790
858
}
791
859
792
860
class ModAssetsCookStep {
@@ -818,7 +886,7 @@ class ModAssetsCookStep {
818
886
}
819
887
820
888
[void ] Execute() {
821
- if (( $this.project.contentOptions.sfStandalone.Length -lt 1 ) -and ( $this .project.contentOptions.sfMaps.Length -lt 1 ) -and ( $this .project.contentOptions.sfCollectionMaps.Length -lt 1 )) {
889
+ if (! $this.project._AnyAssetsToCook ( )) {
822
890
Write-Host " No asset cooking is requested, skipping"
823
891
return
824
892
0 commit comments