Skip to content

Commit 2f3640e

Browse files
committed
deps: Update Windows build script with explicit package names
Default dependencies and Qt are separates package names that can be explicitly identified throughout the script and handled in explicit blocks.
1 parent e1d4ddd commit 2f3640e

File tree

1 file changed

+29
-45
lines changed

1 file changed

+29
-45
lines changed

Build-Dependencies.ps1

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
param(
33
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
44
[string] $Configuration = 'Release',
5+
[ValidateSet('dependencies', 'qt')]
6+
[string] $PackageName = 'dependencies',
57
[string[]] $Dependencies,
68
[ValidateSet('x86', 'x64')]
79
[string] $Target,
@@ -114,34 +116,25 @@ function Run-Stages {
114116
}
115117

116118
function Package-Dependencies {
117-
if ( $script:PackageName -like 'qt*' ) {
118-
$ArchiveFileName = "windows-deps-${PackageName}-${CurrentDate}-${Target}-${Configuration}.zip"
119-
} else {
120-
$ArchiveFileName = "windows-${PackageName}-${CurrentDate}-${Target}.zip"
121-
}
122-
123-
Push-Location -Stack BuildTemp
124-
Set-Location $ConfigData.OutputPath
119+
Push-Location -Stack BuildTemp -Path $ConfigData.OutputPath
125120

126121
Log-Information "Cleanup unnecessary files"
127-
$Items = @(
128-
"./bin/bison.exe"
129-
"./bin/libiconv2.dll"
130-
"./bin/libintl3.dll"
131-
"./bin/m4.exe"
132-
"./bin/pcre2*"
133-
"./bin/regex2.dll"
134-
"./cmake/pcre2*"
135-
"./include/pcre2*"
136-
"./lib/pcre2*"
137-
"./lib/pkgconfig/libpcre2*"
138-
"./man1/pcre2*"
139-
"./man3/pcre2*"
140-
"./share/bison"
141-
"./share/doc/pcre2"
142-
)
143-
144-
Remove-Item -ErrorAction 'SilentlyContinue' -Path $Items -Force -Recurse
122+
123+
switch ( $PackageName ) {
124+
dependencies {
125+
Get-ChildItem ./bin/*.lib | Move-Item -Destination ./lib
126+
Get-ChildItem ./bin -Exclude 'lua51.dll','libcurl.dll','swig.exe','Lib','datachannel.dll' | Remove-Item
127+
Get-ChildItem ./cmake/pcre2*,./lib/pcre2* | Remove-Item
128+
Remove-Item -Recurse ./lib/pkgconfig
129+
Remove-Item -Recurse ./man
130+
Get-ChildItem ./share -Exclude 'cmake' | Remove-Item -Recurse
131+
Get-ChildItem ./share/cmake -Exclude 'nlohmann_json*' | Remove-Item -Recurse
132+
$ArchiveFileName = "windows-deps-${CurrentDate}-${Target}.zip"
133+
}
134+
qt {
135+
$ArchiveFileName = "windows-deps-qt6-${CurrentDate}-${Target}-${Configuration}.zip"
136+
}
137+
}
145138

146139
$Params = @{
147140
ErrorAction = "SilentlyContinue"
@@ -154,20 +147,20 @@ function Package-Dependencies {
154147

155148
New-Item @Params *> $null
156149

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

159152
Log-Information "Package dependencies"
160153

161154
$Params = @{
162-
Path = (Get-ChildItem -Path $(Get-Location))
155+
Path = (Get-ChildItem -Exclude $ArchiveFileName)
163156
DestinationPath = $ArchiveFileName
164157
CompressionLevel = "Optimal"
165158
}
166159

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

170-
Move-Item -Force -Path $ArchiveFileName -Destination ..
163+
Move-Item -Force -Path $ArchiveFileName -Destination (Split-Path -Parent (Get-Location))
171164

172165
Pop-Location -Stack BuildTemp
173166
}
@@ -182,16 +175,6 @@ function Build-Main {
182175
exit 2
183176
}
184177

185-
$script:PackageName = ((Get-Item $PSCommandPath).Basename).Split('-')[1]
186-
if ( $script:PackageName -eq 'Dependencies' ) {
187-
$script:PackageName = 'deps'
188-
}
189-
if ( $Dependencies -eq 'qt5' ) {
190-
$script:PackageName = 'qt5'
191-
} elseif ( $Dependencies -eq 'qt6' ) {
192-
$script:PackageName = 'qt6'
193-
}
194-
195178
$UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse
196179

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

202185
Bootstrap
203186

204-
$SubDir = ''
205-
if ( $script:PackageName -like 'qt*' ) {
206-
$SubDir = 'deps.qt'
187+
$SubDir = if ( $PackageName -eq 'dependencies' ) {
188+
'deps.windows'
207189
} else {
208-
$SubDir = 'deps.windows'
190+
"deps.${PackageName}"
209191
}
210192

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

232214
Pop-Location -Stack BuildTemp
233215

234-
if ( $Dependencies.Count -eq 0 -or $script:PackageName -like 'qt*' ) {
235-
Package-Dependencies
216+
if ( $Dependencies.Count -eq 0 -or $PackageName -eq 'qt' ) {
217+
if ( Test-Path -Path $ConfigData.OutputPath ) {
218+
Package-Dependencies
219+
}
236220
}
237221

238222
Write-Host '---------------------------------------------------------------------------------------------------'

0 commit comments

Comments
 (0)