From 64ebd4e24499514ff68d2cccb8d644f3b18d19b5 Mon Sep 17 00:00:00 2001 From: Xymanek Date: Thu, 24 Jun 2021 11:18:09 +0300 Subject: [PATCH 1/9] Switched to DLC cooking functionality --- EmptyPackage | Bin 0 -> 485 bytes build_common.ps1 | 424 ++++++++++++++++++++++++++--------------------- 2 files changed, 237 insertions(+), 187 deletions(-) create mode 100644 EmptyPackage diff --git a/EmptyPackage b/EmptyPackage new file mode 100644 index 0000000000000000000000000000000000000000..4b61339029ee87c0ef6d453dfbe1a0e4691f8e69 GIT binary patch literal 485 zcmX@utToS Date: Sat, 26 Jun 2021 10:45:30 +0300 Subject: [PATCH 2/9] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f84f7f4..932c9b8 100644 --- a/README.md +++ b/README.md @@ -292,7 +292,7 @@ Assuming the file is named `ContentOptions.json`: $builder.SetContentOptionsJsonFilename("ContentOptions.json") ``` -Four options are avaliable: `missingUncooked`, `sfStandalone`, `sfMaps`, `sfCollectionMaps`. Omitting an option (or the file entirely) +Two options are avaliable: `missingUncooked` and `sfCollectionMaps`. Omitting an option (or the file entirely) is treated the same as setting it to an empty array ### Including missing uncooked @@ -313,8 +313,8 @@ Example from Covert Infiltration: ### Asset cooking -The rest of the options are for the mod assets cooking. Because it is such a complex process, the package and map configuration is -described in a separate file. See [Asset Cooking](https://github.com/X2CommunityCore/X2ModBuildCommon/wiki/Asset-cooking) for details. +The other option is for the mod assets cooking. Because it is such a complex process, the package and map configuration is +described in a separate file. See [Asset Cooking](https://github.com/X2CommunityCore/X2ModBuildCommon/wiki/Asset-cooking-(v1.2.0)) for details. # Additional features From 558596c4d9b758d2257c7dedd298d016ea081953 Mon Sep 17 00:00:00 2001 From: Xymanek Date: Sun, 27 Jun 2021 09:35:26 +0300 Subject: [PATCH 3/9] Implmented ReBuild target for ModBuddy --- XCOM2.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XCOM2.targets b/XCOM2.targets index 5c3f0bd..b3d0bd6 100644 --- a/XCOM2.targets +++ b/XCOM2.targets @@ -53,7 +53,7 @@ /> - + From 9bade25731dc9ef761ec24e0ec3853f85b669377 Mon Sep 17 00:00:00 2001 From: Xymanek Date: Sun, 27 Jun 2021 09:38:50 +0300 Subject: [PATCH 4/9] Renamed $sfCollectionMapsNames to $sfCollectionOnlyMapsNames --- build_common.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build_common.ps1 b/build_common.ps1 index b3a2983..9840eab 100644 --- a/build_common.ps1 +++ b/build_common.ps1 @@ -594,12 +594,12 @@ class BuildProject { $contentForCookPath = "$($this.modSrcRoot)\ContentForCook" - $sfCollectionMapsNames = @($this.contentOptions.sfCollectionMaps | ForEach-Object { $_.name }) + $sfCollectionOnlyMapsNames = @($this.contentOptions.sfCollectionMaps | ForEach-Object { $_.name }) $sfStandaloneNames = @() $sfMapsNames = @() if (-not(Test-Path $contentForCookPath)) { - if ($sfCollectionMapsNames.Length -lt 1) { + if ($sfCollectionOnlyMapsNames.Length -lt 1) { ThrowFailure "Collection map cooking is requested, but no ContentForCook folder is present" } @@ -611,14 +611,14 @@ class BuildProject { $sfMapsNames = @(Get-ChildItem -Path "$contentForCookPath/Maps" -Recurse -Include *.umap | ForEach-Object { $_.BaseName }) # Allow using the force-package-into-map functionality for non-empty maps - $sfCollectionMapsNames = $sfCollectionMapsNames | Where-Object { $sfMapsNames -notcontains $_ } + $sfCollectionOnlyMapsNames = $sfCollectionOnlyMapsNames | Where-Object { $sfMapsNames -notcontains $_ } } if (Test-Path "$contentForCookPath/Standalone") { $sfStandaloneNames = @(Get-ChildItem -Path "$contentForCookPath/Standalone" -Recurse -Include *.upk | ForEach-Object { $_.BaseName }) } - if (($sfMapsNames.Length -lt 1) -and ($sfStandaloneNames.Length -lt 1) -and ($sfCollectionMapsNames.Length -lt 1)) { + if (($sfMapsNames.Length -lt 1) -and ($sfStandaloneNames.Length -lt 1) -and ($sfCollectionOnlyMapsNames.Length -lt 1)) { if ((Test-Path "$contentForCookPath/Secondary") -and ($null -ne (Get-ChildItem -Path "$contentForCookPath/Secondary" -Recurse -Include *.upk))) { ThrowFailure "Found secondary packages for cooking but nothing ever could use them" } @@ -633,7 +633,7 @@ class BuildProject { # Bit of debug info Write-Host "SF Standalone: $sfStandaloneNames" Write-Host "Maps: $sfMapsNames" - Write-Host "Collection maps: $sfCollectionMapsNames" + Write-Host "Collection only maps: $sfCollectionOnlyMapsNames" # Step 0. Basic preparation @@ -681,7 +681,7 @@ class BuildProject { # Paths $newEngineLines += "[Core.System]" if ($sfMapsNames.Length -gt 0) { $newEngineLines += "+Paths=$contentForCookPath\Maps" } - if ($sfCollectionMapsNames.Length -gt 0) { $newEngineLines += "+Paths=$collectionMapsPath" } + if ($sfCollectionOnlyMapsNames.Length -gt 0) { $newEngineLines += "+Paths=$collectionMapsPath" } if (Test-Path "$contentForCookPath/Secondary") { $newEngineLines += "+Paths=$contentForCookPath\Secondary" } # Final content @@ -769,11 +769,11 @@ class BuildProject { # Prep the folder for the collection maps # Not the most efficient approach, but there are bigger time saves to be had - if ($sfCollectionMapsNames.Length -gt 0) { + if ($sfCollectionOnlyMapsNames.Length -gt 0) { Remove-Item $collectionMapsPath -Force -Recurse -WarningAction SilentlyContinue -ErrorAction SilentlyContinue New-Item -ItemType "directory" -Path $collectionMapsPath - foreach ($map in $sfCollectionMapsNames) { + foreach ($map in $sfCollectionOnlyMapsNames) { # Important: we cannot use .umap extension here - git lfs (if in use) gets confused during git subtree add # See https://github.com/X2CommunityCore/X2ModBuildCommon/wiki/Do-not-use-.umap-for-files-in-this-repo Copy-Item "$global:buildCommonSelfPath\EmptyUMap" "$collectionMapsPath\$map.umap" From f23a40ed6a62e6f4e3d54ac40a518fb07b18e064 Mon Sep 17 00:00:00 2001 From: Xymanek Date: Sun, 27 Jun 2021 09:43:17 +0300 Subject: [PATCH 5/9] Added an explanantion about the iterator guard --- build_common.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build_common.ps1 b/build_common.ps1 index 9840eab..07cca48 100644 --- a/build_common.ps1 +++ b/build_common.ps1 @@ -803,7 +803,10 @@ class BuildProject { New-Item -ItemType "directory" -Path $sdkContentModsOurDir } - # Prep the guard package + # Prep the guard package. + # When the cooker iterates the packages to decide what to cook, it will always skip the first + # one alphabetically. To counteract this, we make a dummy package which will always be + # iterated first New-Item -ItemType "directory" -Path $sdkContentModsOurGuardDir Copy-Item "$global:buildCommonSelfPath\EmptyPackage" $sdkContentModsOurGuardPackagePath } else { From 029d9e2d9c8f8282b7f26b06d47ba9f239f74bb2 Mon Sep 17 00:00:00 2001 From: Xymanek Date: Sun, 27 Jun 2021 09:47:02 +0300 Subject: [PATCH 6/9] Renamed $defaultEngine -> $sdkEngine --- build_common.ps1 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/build_common.ps1 b/build_common.ps1 index 07cca48..bd73c84 100644 --- a/build_common.ps1 +++ b/build_common.ps1 @@ -641,8 +641,8 @@ class BuildProject { $collectionMapsPath = [io.path]::combine($this.buildCachePath, 'CollectionMaps') $tfcSuffix = "_$($this.modNameCanonical)_" - $defaultEnginePath = "$($this.sdkPath)/XComGame/Config/DefaultEngine.ini" - $defaultEngineContentOriginal = Get-Content $defaultEnginePath | Out-String + $sdkEnginePath = "$($this.sdkPath)/XComGame/Config/DefaultEngine.ini" + $sdkEngineContentOriginal = Get-Content $sdkEnginePath | Out-String $cookOutputParentDir = [io.path]::combine($this.sdkPath, 'XComGame', 'Published') $cookOutputDir = [io.path]::combine($cookOutputParentDir, 'CookedPCConsole') @@ -657,7 +657,7 @@ class BuildProject { # This doesn't use locks, so it can break if multiple builds are running at the same time, # so let's hope that mod devs are smart enough to not run simultanoues builds - if ($defaultEngineContentOriginal.Contains("HACKS FOR MOD ASSETS COOKING")) + if ($sdkEngineContentOriginal.Contains("HACKS FOR MOD ASSETS COOKING")) { ThrowFailure "Another cook is already in progress (DefaultEngine.ini)" } @@ -685,8 +685,8 @@ class BuildProject { if (Test-Path "$contentForCookPath/Secondary") { $newEngineLines += "+Paths=$contentForCookPath\Secondary" } # Final content - $defaultEngineContentNew = $newEngineLines -join "`n" - $defaultEngineContentNew = "$defaultEngineContentOriginal`n$defaultEngineContentNew" + $sdkEngineContentNew = $newEngineLines -join "`n" + $sdkEngineContentNew = "$sdkEngineContentOriginal`n$sdkEngineContentNew" # Prepare the cook output folder $previousCookOutputDirPath = $null @@ -817,7 +817,7 @@ class BuildProject { } # Backup the DefaultEngine.ini - Copy-Item $defaultEnginePath "$($this.sdkPath)/XComGame/Config/DefaultEngine.ini.bak_PRE_ASSET_COOKING" + Copy-Item $sdkEnginePath "$($this.sdkPath)/XComGame/Config/DefaultEngine.ini.bak_PRE_ASSET_COOKING" # This try block needs to be kept as small as possible as it puts the SDK into a (temporary) invalid state try { @@ -833,7 +833,7 @@ class BuildProject { if ($sfStandaloneNames.Length -gt 0) { New-Junction $sdkContentModsOurStandaloneDir "$contentForCookPath/Standalone" } # Set the modified engine.ini - $defaultEngineContentNew | Set-Content $defaultEnginePath -NoNewline + $sdkEngineContentNew | Set-Content $sdkEnginePath -NoNewline # while ($true) {} @@ -850,11 +850,11 @@ class BuildProject { # Revert ini try { - $defaultEngineContentOriginal | Set-Content $defaultEnginePath -NoNewline - Write-Host "Reverted $defaultEnginePath" + $sdkEngineContentOriginal | Set-Content $sdkEnginePath -NoNewline + Write-Host "Reverted $sdkEnginePath" } catch { - FailureMessage "Failed to revert $defaultEnginePath" + FailureMessage "Failed to revert $sdkEnginePath" FailureMessage $_ } From 766a7955c3e301307941b9cc64e40cd0d3442cfa Mon Sep 17 00:00:00 2001 From: Xymanek Date: Sun, 27 Jun 2021 09:50:18 +0300 Subject: [PATCH 7/9] Moved hardcoded reused string to a variable --- build_common.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build_common.ps1 b/build_common.ps1 index bd73c84..3ab5deb 100644 --- a/build_common.ps1 +++ b/build_common.ps1 @@ -643,6 +643,7 @@ class BuildProject { $sdkEnginePath = "$($this.sdkPath)/XComGame/Config/DefaultEngine.ini" $sdkEngineContentOriginal = Get-Content $sdkEnginePath | Out-String + $sdkEngineChangesPreamble = "HACKS FOR MOD ASSETS COOKING" $cookOutputParentDir = [io.path]::combine($this.sdkPath, 'XComGame', 'Published') $cookOutputDir = [io.path]::combine($cookOutputParentDir, 'CookedPCConsole') @@ -657,7 +658,7 @@ class BuildProject { # This doesn't use locks, so it can break if multiple builds are running at the same time, # so let's hope that mod devs are smart enough to not run simultanoues builds - if ($sdkEngineContentOriginal.Contains("HACKS FOR MOD ASSETS COOKING")) + if ($sdkEngineContentOriginal.Contains($sdkEngineChangesPreamble)) { ThrowFailure "Another cook is already in progress (DefaultEngine.ini)" } @@ -666,7 +667,7 @@ class BuildProject { $newEngineLines = @() # Denote the beginning of our changes (+ used by the check above) - $newEngineLines += ";HACKS FOR MOD ASSETS COOKING - $($this.modNameCanonical)" + $newEngineLines += ";$sdkEngineChangesPreamble - $($this.modNameCanonical)" # Collection maps $newEngineLines += "[Engine.PackagesToForceCookPerMap]" From 36db8e580d976c08c765c1fbddab29f52b03c0e7 Mon Sep 17 00:00:00 2001 From: Xymanek Date: Sun, 27 Jun 2021 09:54:31 +0300 Subject: [PATCH 8/9] Explanantion of why not recursive folder removal --- build_common.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build_common.ps1 b/build_common.ps1 index 3ab5deb..a7a1747 100644 --- a/build_common.ps1 +++ b/build_common.ps1 @@ -890,7 +890,10 @@ class BuildProject { } try { - Remove-Item $sdkContentModsOurDir # Important: not recursive! + # Important: not recursive! + # If we failed to undo the Standalone junction above, we will nuke the original + # packages in the mod project if this is a recursive removal + Remove-Item $sdkContentModsOurDir Write-Host "Removed $sdkContentModsOurDir folder" } catch { From b7bf2ca9c7360c8e85417bf2de1512a929800347 Mon Sep 17 00:00:00 2001 From: Xymanek Date: Sun, 27 Jun 2021 09:58:28 +0300 Subject: [PATCH 9/9] Added `Full rebuild` task to VSCode readme section --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 932c9b8..c2281aa 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,11 @@ name in the "Clean" task): "command": "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file '${workspaceRoot}\\.scripts\\clean.ps1' -modName 'MY_MOD_NAME' -srcDirectory '${workspaceRoot}' -sdkPath '${config:xcom.highlander.sdkroot}' -gamePath '${config:xcom.highlander.gameroot}'", "group": "build", "problemMatcher": [] + }, + { + "label": "Full rebuild", + "dependsOrder": "sequence", + "dependsOn": ["Clean", "Build"] } ] }