Skip to content

Commit

Permalink
deps: Update Windows build script with explicit package names
Browse files Browse the repository at this point in the history
Default dependencies and Qt are separates package names that can be
explicitly identified throughout the script and handled in explicit
blocks.
  • Loading branch information
PatTheMav committed Sep 20, 2023
1 parent 371ee59 commit 017f8f5
Showing 1 changed file with 29 additions and 45 deletions.
74 changes: 29 additions & 45 deletions Build-Dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
param(
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
[string] $Configuration = 'Release',
[ValidateSet('dependencies', 'qt')]
[string] $PackageName = 'dependencies',
[string[]] $Dependencies,
[ValidateSet('x86', 'x64')]
[string] $Target,
Expand Down Expand Up @@ -114,34 +116,25 @@ function Run-Stages {
}

function Package-Dependencies {
if ( $script:PackageName -like 'qt*' ) {
$ArchiveFileName = "windows-deps-${PackageName}-${CurrentDate}-${Target}-${Configuration}.zip"
} else {
$ArchiveFileName = "windows-${PackageName}-${CurrentDate}-${Target}.zip"
}

Push-Location -Stack BuildTemp
Set-Location $ConfigData.OutputPath
Push-Location -Stack BuildTemp -Path $ConfigData.OutputPath

Log-Information "Cleanup unnecessary files"
$Items = @(
"./bin/bison.exe"
"./bin/libiconv2.dll"
"./bin/libintl3.dll"
"./bin/m4.exe"
"./bin/pcre2*"
"./bin/regex2.dll"
"./cmake/pcre2*"
"./include/pcre2*"
"./lib/pcre2*"
"./lib/pkgconfig/libpcre2*"
"./man1/pcre2*"
"./man3/pcre2*"
"./share/bison"
"./share/doc/pcre2"
)

Remove-Item -ErrorAction 'SilentlyContinue' -Path $Items -Force -Recurse

switch ( $PackageName ) {
dependencies {
Get-ChildItem ./bin/*.lib | Move-Item -Destination ./lib
Get-ChildItem ./bin/* -Exclude 'libcurl.dll','lua51.*,','Lib','swig.exe' | Remove-Item
Get-ChildItem ./cmake/pcre2*,./lib/pcre2* | Remove-Item
Remove-Item -Recurse ./lib/pkgconfig
Remove-Item -Recurse ./man
Get-ChildItem ./share/* -Exclude 'nlohmann?json*' | Remove-Item -Recurse
Remove-Item ./share/bison,./share/doc,./nlohmann_json.natvis
$ArchiveFileName = "windows-deps-${CurrentDate}-${Target}.zip"
}
qt {
$ArchiveFileName = "windows-deps-qt6-${CurrentDate}-${Target}-${Configuration}.zip"
}
}

$Params = @{
ErrorAction = "SilentlyContinue"
Expand All @@ -154,20 +147,20 @@ function Package-Dependencies {

New-Item @Params *> $null

"$(Get-Date -Format "yyyy-MM-dd")" > share/obs-deps/VERSION
Get-Date -Format "yyyy-MM-dd" | Set-Content -Path share/obs-deps/VERSION

Log-Information "Package dependencies"

$Params = @{
Path = (Get-ChildItem -Path $(Get-Location))
Path = (Get-ChildItem -Exclude $ArchiveFileName)
DestinationPath = $ArchiveFileName
CompressionLevel = "Optimal"
}

Log-Information "Create archive ${ArchiveFileName}"
Compress-Archive @Params

Move-Item -Force -Path $ArchiveFileName -Destination ..
Move-Item -Force -Path $ArchiveFileName -Destination (Split-Path -Parent (Get-Location))

Pop-Location -Stack BuildTemp
}
Expand All @@ -182,16 +175,6 @@ function Build-Main {
exit 2
}

$script:PackageName = ((Get-Item $PSCommandPath).Basename).Split('-')[1]
if ( $script:PackageName -eq 'Dependencies' ) {
$script:PackageName = 'deps'
}
if ( $Dependencies -eq 'qt5' ) {
$script:PackageName = 'qt5'
} elseif ( $Dependencies -eq 'qt6' ) {
$script:PackageName = 'qt6'
}

$UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse

foreach($Utility in $UtilityFunctions) {
Expand All @@ -201,11 +184,10 @@ function Build-Main {

Bootstrap

$SubDir = ''
if ( $script:PackageName -like 'qt*' ) {
$SubDir = 'deps.qt'
$SubDir = if ( $PackageName -eq 'dependencies' ) {
'deps.windows'
} else {
$SubDir = 'deps.windows'
"deps.${PackageName}"
}

if ( $Dependencies.Count -eq 0 ) {
Expand All @@ -231,8 +213,10 @@ function Build-Main {

Pop-Location -Stack BuildTemp

if ( $Dependencies.Count -eq 0 -or $script:PackageName -like 'qt*' ) {
Package-Dependencies
if ( $Dependencies.Count -eq 0 -or $PackageName -eq 'qt' ) {
if ( Test-Path -Path $ConfigData.OutputPath ) {
Package-Dependencies
}
}

Write-Host '---------------------------------------------------------------------------------------------------'
Expand Down

0 comments on commit 017f8f5

Please sign in to comment.