Skip to content

Commit

Permalink
Refactor build script for PowerShell Core compatibility
Browse files Browse the repository at this point in the history
Allows for building the project on Linux or macOS with PowerShell Core.
  • Loading branch information
Qonfused committed Aug 31, 2024
1 parent 36b00a7 commit 31680e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
23 changes: 10 additions & 13 deletions .github/scripts/run-builds.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
# [parameter(ValueFromRemainingArguments)][string[]]$arguments
# )

$buildList = @('RELEASE', 'DEBUG')
$flagsList = @(
@('--64-bit'),
@('legacy', '--32-bit'),
@('legacy', '--64-bit')
)
$buildList = 'RELEASE',
'DEBUG'
$flagsList = '--64-bit',
('--64-bit', '--legacy'),
('--32-bit', '--legacy')

foreach ($build in $buildList) {
# Prepare for each build configuration
Expand All @@ -27,16 +26,14 @@ foreach ($build in $buildList) {

# Run build for each flag configuration
foreach ($flags in $flagsList) {
$identifier = "$($flags -replace '--', '' -join '-')-$build"

# Run build script
$flags = $($flags -join ' ')
Write-Host "Starting $build build with flags: $flags"
powershell.exe "$pwd\scripts\build.ps1" $flags
Write-Host "Running $build build with flags: $flags..."
pwsh "$pwd/scripts/build.ps1" -ArgumentList "$($flags -join ' ')"

# Compress EFI directory
cp src\build.lock dist\EFI\OC\build.lock
tar.exe -czf "EFI-$env:TAG-$identifier.zip" -C dist .
cp "$pwd/src/build.lock" "$pwd/dist/EFI/OC/build.lock"
$identifier = "$($flags -replace '--', '' -join '-')-$build"
tar -czf "EFI-$env:TAG-$identifier.zip" -C dist .

# Cleanup
Remove-Item dist -Force -Recurse -ErrorAction SilentlyContinue
Expand Down
12 changes: 7 additions & 5 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ param (
function HasFlag {
param ([string]$flag)

if ($arguments -eq $flag) {
$arguments = $arguments -ne $flag
return $true
$arg_array = $arguments -split ' '
foreach ($arg in $arg_array) {
if ($arg -eq $flag) {
$arguments = ($arg_array | ? { $_ -ne $flag }) -join ' '
return $true
}
}

return $false
}


# Switches for additional '--legacy' and '--32-bit' patches
$patches = @('-p config.yml')
if (HasFlag '--legacy') { $patches += @('-p patch.legacy.yml') }
Expand All @@ -35,5 +37,5 @@ icm `

# Run the post-build script
Write-Host "`nRunning post-build script..."
powershell.exe "$PSScriptRoot\post-build.ps1"
& "$PSScriptRoot\post-build.ps1"
Write-Host "Done.`n"

0 comments on commit 31680e2

Please sign in to comment.