|
| 1 | +# MIT License |
| 2 | + |
| 3 | +# Copyright (c) 2020 Jean Philippe |
| 4 | + |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | + |
| 12 | +# The above copyright notice and this permission notice shall be included in all |
| 13 | +# copies or substantial portions of the Software. |
| 14 | + |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | +# SOFTWARE. |
| 22 | + |
| 23 | +#Requires -PSEdition Core |
| 24 | + |
| 25 | +param ( |
| 26 | + [Parameter(HelpMessage="SystemName type to build, default to Windows")] |
| 27 | + [ValidateSet('Windows', 'Darwin', 'Linux')] |
| 28 | + [string[]] $SystemName = 'Windows', |
| 29 | + |
| 30 | + [Parameter(HelpMessage = "Architecture to build")] |
| 31 | + [ValidateSet('x64', 'arm64')] |
| 32 | + [string] $Architecture = 'x64', |
| 33 | + |
| 34 | + [Parameter(HelpMessage="Configuration type to build, default to Debug")] |
| 35 | + [ValidateSet('Debug', 'Release')] |
| 36 | + [string[]] $Configurations = 'Debug', |
| 37 | + |
| 38 | + [Parameter(HelpMessage = "Build Launcher only")] |
| 39 | + [switch] $LauncherOnly |
| 40 | +) |
| 41 | + |
| 42 | +$ErrorActionPreference = "Stop" |
| 43 | +$TargetFramework = 'net8.0' |
| 44 | + |
| 45 | +[string]$RepoRoot = [IO.Path]::Combine($PSScriptRoot, "..") |
| 46 | +[string]$OuputBuildDirectory = If($IsWindows) { |
| 47 | + [IO.Path]::Combine($RepoRoot, "Result.Windows.x64.MultiConfig") |
| 48 | +} Else { |
| 49 | + [IO.Path]::Combine($RepoRoot, "Result.$SystemName.x64.$Configurations") |
| 50 | +} |
| 51 | + |
| 52 | +if($LauncherOnly) { |
| 53 | + Write-Host "Skipping resources copy..." |
| 54 | + return; |
| 55 | +} |
| 56 | + |
| 57 | +$ContentsToProcess = @( |
| 58 | + @{ |
| 59 | + Name = "Resources" |
| 60 | + IsDirectory = $true |
| 61 | + Contents = @( |
| 62 | + switch ($SystemName) { |
| 63 | + "Windows" { |
| 64 | + @{ From = "$RepoRoot\Resources\Shaders"; To = "$OuputBuildDirectory\Obelisk\$Configurations\Shaders"} |
| 65 | + @{ From = "$RepoRoot\Resources\Editor\Settings"; To = "$OuputBuildDirectory\Obelisk\$Configurations\Settings"} |
| 66 | + } |
| 67 | + "Darwin" { |
| 68 | + @{ From = "$RepoRoot\Resources\Shaders"; To = "$OuputBuildDirectory\Obelisk\$Configurations\Shaders"} |
| 69 | + @{ From = "$RepoRoot\Resources\Editor\Settings"; To = "$OuputBuildDirectory\Obelisk\$Configurations\Settings"} |
| 70 | + } |
| 71 | + "Linux" { |
| 72 | + @{ From = "$RepoRoot\Resources\Shaders"; To = "$OuputBuildDirectory\Obelisk\Shaders"} |
| 73 | + @{ From = "$RepoRoot\Resources\Editor\Settings"; To = "$OuputBuildDirectory\Obelisk\Settings"} |
| 74 | + } |
| 75 | + Default { |
| 76 | + throw 'This system is not supported' |
| 77 | + } |
| 78 | + } |
| 79 | + ) |
| 80 | + }, |
| 81 | + @{ |
| 82 | + Name = "Obelisk" |
| 83 | + IsDirectory = $true |
| 84 | + Contents = @( |
| 85 | + switch ($SystemName) { |
| 86 | + "Windows" { |
| 87 | + @{ From = "$OuputBuildDirectory\Obelisk\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\win-$Architecture\Editor"} |
| 88 | + @{ From = "$OuputBuildDirectory\Obelisk\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\win-$Architecture\publish\Editor"} |
| 89 | + } |
| 90 | + "Darwin" { |
| 91 | + switch ($Architecture) { |
| 92 | + "x64" { |
| 93 | + @{ From = "$OuputBuildDirectory\Obelisk\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\osx-$Architecture\Editor"} |
| 94 | + @{ From = "$OuputBuildDirectory\Obelisk\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\osx-$Architecture\publish\Editor"} |
| 95 | + } |
| 96 | + "arm64" { |
| 97 | + @{ From = "$OuputBuildDirectory\Obelisk\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\osx-$Architecture\Editor"} |
| 98 | + @{ From = "$OuputBuildDirectory\Obelisk\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\osx-$Architecture\publish\Editor"} |
| 99 | + } |
| 100 | + Default { |
| 101 | + throw 'This architecture is not supported' |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + "Linux" { |
| 106 | + @{ From = "$OuputBuildDirectory\Obelisk"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\Editor"} |
| 107 | + @{ From = "$OuputBuildDirectory\Obelisk"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\Editor"} |
| 108 | + } |
| 109 | + Default { |
| 110 | + throw 'This system is not supported' |
| 111 | + } |
| 112 | + } |
| 113 | + ) |
| 114 | + } |
| 115 | +) |
| 116 | + |
| 117 | +foreach ($item in $ContentsToProcess) { |
| 118 | + foreach($content in $item.Contents) { |
| 119 | + |
| 120 | + if($item.IsDirectory -eq $true) { |
| 121 | + |
| 122 | + # Delete if directories or files already exist |
| 123 | + # |
| 124 | + if(Test-Path $content.To) { |
| 125 | + Remove-Item $content.To -Recurse -Force |
| 126 | + } |
| 127 | + Copy-Item -Path $content.From -Destination $content.To -Recurse -Force |
| 128 | + } |
| 129 | + else { |
| 130 | + Copy-Item -Path $content.From -Destination $content.To -Force |
| 131 | + } |
| 132 | + |
| 133 | + [string]$name = $item.Name |
| 134 | + [string]$ToDirectory = $content.To |
| 135 | + Write-Host "Copied $name --> $ToDirectory" |
| 136 | + } |
| 137 | +} |
0 commit comments