Skip to content

Commit fe4173e

Browse files
fix: Develop2 - VS2022 install 7zip (#2316)
1 parent 0995793 commit fe4173e

File tree

1 file changed

+44
-61
lines changed

1 file changed

+44
-61
lines changed

develop.ps1

Lines changed: 44 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,11 @@ function Find-And-Remove {
9090
[string]$relativePath = ""
9191
)
9292

93-
if (Test-Path -Path $relativePath)
94-
{
93+
if (Test-Path -Path $relativePath) {
9594
Write-Host "Existing instance of object $relativePath found, cleaning up... " @info_colors
9695
Remove-Item $relativePath -Recurse -Force
9796
}
98-
else
99-
{
97+
else {
10098
Write-Host "Existing instance of object $relativePath NOT found, could not clean up." @warn_colors
10199
}
102100
}
@@ -141,35 +139,31 @@ choco install -y cmake --version=3.30.1 --force
141139

142140
# Ensure CMake version is 3.30.1
143141
$cmakeVersion = "$(cmake --version)"
144-
if (-not ($cmakeVersion -like "*3.30.1*"))
145-
{
142+
if (-not ($cmakeVersion -like "*3.30.1*")) {
146143
choco install -y cmake.install --version=3.30.1 --force --installargs "ADD_CMAKE_TO_PATH=User"
147144
}
148145

149146
# Find git, install if not found
150147
try {
151148
& "git" --version
152149
Write-Output "Found system Git..."
153-
} catch {
150+
}
151+
catch {
154152
Write-Output "Could not find system Git - installing with Chocolatey..."
155153
choco install -y git
156154
}
157155

158156
# Find python, install if not found
159-
if (-not [string]::IsNullOrEmpty($pythonPath))
160-
{
157+
if (-not [string]::IsNullOrEmpty($pythonPath)) {
161158
Write-Output "Using Python with path $pythonPath..." @info_colors
162159
$python = $pythonPath
163160
}
164-
else
165-
{
166-
if (-not [string]::IsNullOrEmpty($forcePythonVersion))
167-
{
161+
else {
162+
if (-not [string]::IsNullOrEmpty($forcePythonVersion)) {
168163
Write-Output "Installing requested Python version $forcePythonVersion..." @info_colors
169164
choco install -y python --version=$forcePythonVersion --force
170165
}
171-
else
172-
{
166+
else {
173167
try {
174168
& "python" --version
175169
Write-Output "Found system Python..." @info_colors
@@ -179,7 +173,8 @@ else
179173
Write-Output "System Python is version $(python --version) and it is recommended to be version == 3.12 - installing with Chocolatey..." @info_colors
180174
choco install -y python --version=3.12.0
181175
}
182-
} catch {
176+
}
177+
catch {
183178
Write-Output "Could not find system Python - installing with Chocolatey..." @info_colors
184179
choco install -y python --version=3.12.0
185180
}
@@ -195,13 +190,11 @@ Write-Host "Creating a local Python virtual environment with $(& $python --versi
195190
& $python -m venv msvc-env
196191

197192
Write-Host "Checking Python compiler type... " @info_colors
198-
if ($(& $python -c "import sys; print(sys.version)") -match "MSC v\.\d+")
199-
{
193+
if ($(& $python -c "import sys; print(sys.version)") -match "MSC v\.\d+") {
200194
Write-Host " ...Python compiler type evaluated to MSC" @info_colors
201195
$pythonEnvSourceDir = "Scripts"
202196
}
203-
else
204-
{
197+
else {
205198
Write-Host " ...Python compiler type is not MSC" @info_colors
206199
$pythonEnvSourceDir = "bin"
207200
}
@@ -213,15 +206,14 @@ Write-Host "Activating Python virtual environment... " @info_colors
213206

214207
Write-Host "Installing Python packages... " @info_colors
215208
& $python -m pip install --upgrade pip
216-
& $python -m pip install aqtinstall conan==$conanVersion.*
209+
& $python -m pip install py7zr==1.1.0 aqtinstall conan==$conanVersion.*
217210

218211
$pythonEnvPath = Join-Path -Path $projectDir -ChildPath "msvc-env\$pythonEnvSourceDir"
219212

220213
# Install Qt6, or find existing system Qt6 installation
221214
$qt6CMakeDir = ""
222215

223-
if (-not [string]::IsNullOrEmpty($qtVersion))
224-
{
216+
if (-not [string]::IsNullOrEmpty($qtVersion)) {
225217
$qtInstallationDir = Join-Path -Path $dependencies -ChildPath "qt"
226218
New-Item -ItemType Directory -Path $qtInstallationDir -ErrorAction SilentlyContinue
227219

@@ -237,20 +229,17 @@ if (-not [string]::IsNullOrEmpty($qtVersion))
237229
# We attempt to use an existing installation of Qt
238230
Write-Host "Attempting to use existing system installation of Qt6... " @info_colors
239231

240-
if (-not [string]::IsNullOrEmpty($systemQt))
241-
{
242-
$qt6Version = Get-ChildItem -Path $systemQt -Directory | Where-Object { $_.Name -match '^\d+\.\d+\.\d+$'} | Select-Object -First 1
243-
$qt6ToolChain = Get-ChildItem -Path (Join-Path -Path $systemQt -ChildPath $qt6Version) -Directory | Where-Object { $_.Name -match '^msvc\d{4}_x64$'} | Select-Object -ExpandProperty Name
232+
if (-not [string]::IsNullOrEmpty($systemQt)) {
233+
$qt6Version = Get-ChildItem -Path $systemQt -Directory | Where-Object { $_.Name -match '^\d+\.\d+\.\d+$' } | Select-Object -First 1
234+
$qt6ToolChain = Get-ChildItem -Path (Join-Path -Path $systemQt -ChildPath $qt6Version) -Directory | Where-Object { $_.Name -match '^msvc\d{4}_x64$' } | Select-Object -ExpandProperty Name
244235
$qt6BinDir = "$systemQt\$($qt6Version.Name)\$qt6ToolChain\bin"
245236
$qt6CMakeDir = "$systemQt\$($qt6Version.Name)\$qt6ToolChain\lib\cmake"
246237

247-
if (-not (Test-Path -Path $qt6CMakeDir -PathType Container))
248-
{
238+
if (-not (Test-Path -Path $qt6CMakeDir -PathType Container)) {
249239
Write-Host "Attempted to find the directory $qt6CMakeDir. Could NOT find a valid Qt6 installation." @warn_colors
250240
}
251241
}
252-
else
253-
{
242+
else {
254243
Write-Host "Could NOT find a Qt6 installation. No path to Qt6 was supplied." @warn_colors
255244
}
256245
}
@@ -303,8 +292,8 @@ cmake --build . --target install --config $build
303292
$freetypeLib = "$freetypeInstall\lib"
304293
$freetypeBin = "$freetypeInstall\bin"
305294

306-
$freetypeLibPath = Join-Path -Path $projectDir -ChildPath "$dependencies\$freetypeLib"
307-
$freetypeBinPath = Join-Path -Path $projectDir -ChildPath "$dependencies\$freetypeBin"
295+
$freetypeLibPath = Join-Path -Path $projectDir -ChildPath "$dependencies\$freetypeLib"
296+
$freetypeBinPath = Join-Path -Path $projectDir -ChildPath "$dependencies\$freetypeBin"
308297

309298
$lib = [System.Environment]::GetEnvironmentVariable("LIB", [System.EnvironmentVariableTarget]::Machine)
310299

@@ -353,8 +342,8 @@ cmake --build . --target install --config $build
353342
$ftglLib = "$ftglInstall\lib"
354343
$ftglBin = "$ftglInstall\bin"
355344

356-
$ftglLibPath = Join-Path -Path $projectDir -ChildPath "$dependencies\$ftglLib"
357-
$ftglBinPath = Join-Path -Path $projectDir -ChildPath "$dependencies\$ftglBin"
345+
$ftglLibPath = Join-Path -Path $projectDir -ChildPath "$dependencies\$ftglLib"
346+
$ftglBinPath = Join-Path -Path $projectDir -ChildPath "$dependencies\$ftglBin"
358347

359348
$lib = [System.Environment]::GetEnvironmentVariable("LIB", [System.EnvironmentVariableTarget]::Machine)
360349

@@ -364,7 +353,7 @@ if ($lib -notlike "*$ftglInstall*") {
364353
}
365354

366355
$ftglInclude = "$ftglRepo\src"
367-
$ftglIncludePath = Join-Path -Path $projectDir -ChildPath "$dependencies\$ftglInclude"
356+
$ftglIncludePath = Join-Path -Path $projectDir -ChildPath "$dependencies\$ftglInclude"
368357

369358
$include = [System.Environment]::GetEnvironmentVariable("INCLUDE", [System.EnvironmentVariableTarget]::Machine)
370359

@@ -435,12 +424,12 @@ try {
435424
Write-Output "Found conan version $foundConanVersion..."
436425

437426
$conan = "conan"
438-
} catch {
427+
}
428+
catch {
439429
Write-Output "Could not find conan, adding Python scripts to path..." @info_colors
440430
$scripts = & $python -c "import sysconfig; print(sysconfig.get_path('scripts'))"
441431

442-
if ($setSystemEnvVars)
443-
{
432+
if ($setSystemEnvVars) {
444433
$systemPath = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine)
445434
[Environment]::SetEnvironmentVariable("PATH", "$scripts;$systemPath", [EnvironmentVariableTarget]::Machine)
446435
Write-Host "Python scripts path at location $scripts added to system PATH." @info_colors
@@ -486,49 +475,45 @@ if ((-not [string]::IsNullOrEmpty($msvcVersion)) -and ($generator -eq "Visual St
486475
}
487476

488477
# For MSVC version != v143 latest, and Ninja generator specified, set toolset at preset level
489-
if ((-not [string]::IsNullOrEmpty($msvcVersion)) -and ($generator -eq "Ninja"))
490-
{
478+
if ((-not [string]::IsNullOrEmpty($msvcVersion)) -and ($generator -eq "Ninja")) {
491479
$toolset = @{
492-
value = "version=$msvcVersion"
480+
value = "version=$msvcVersion"
493481
strategy = "external"
494482
}
495483
}
496484

497485
$cmakeUserPresets = [PSCustomObject]@{
498-
version = 3
486+
version = 3
499487
cmakeMinimumRequired = @{
500488
major = 3
501489
minor = 21
502490
}
503-
configurePresets = @()
491+
configurePresets = @()
504492
}
505493

506494
$presets = @(
507495
[PSCustomObject]@{
508-
name = "CLI-$build-MSVC"
496+
name = "CLI-$build-MSVC"
509497
displayName = "CLI $build Build"
510498
description = "The preset for a CLI $build build on MSVC"
511-
generator = $generator
512-
inherits = @("CLI-$build")
499+
generator = $generator
500+
inherits = @("CLI-$build")
513501
},
514502
[PSCustomObject]@{
515-
name = "GUI-$build-MSVC"
503+
name = "GUI-$build-MSVC"
516504
displayName = "GUI $build Build"
517505
description = "The preset for a GUI $build build on MSVC"
518-
generator = $generator
519-
inherits = @("GUI-$build")
506+
generator = $generator
507+
inherits = @("GUI-$build")
520508
}
521509
)
522510

523511
# Set environment variables
524-
if (-not $setSystemEnvVars)
525-
{
526-
if ([string]::IsNullOrEmpty($scripts))
527-
{
512+
if (-not $setSystemEnvVars) {
513+
if ([string]::IsNullOrEmpty($scripts)) {
528514
$scripts = ''
529515
}
530-
else
531-
{
516+
else {
532517
$scripts = "$scripts;"
533518
}
534519

@@ -553,15 +538,13 @@ foreach ($preset in $presets) {
553538
$preset | Add-Member -MemberType NoteProperty -Name cacheVariables -Value $cacheVariables
554539

555540
# Set environment variables
556-
if (-not $setSystemEnvVars)
557-
{
541+
if (-not $setSystemEnvVars) {
558542
$preset | Add-Member -MemberType NoteProperty -Name environment -Value ($environment)
559543
}
560544

561545
# Set toolset
562-
if ($toolset)
563-
{
564-
$preset | Add-Member -MemberType NoteProperty -Name toolset -Value $toolset
546+
if ($toolset) {
547+
$preset | Add-Member -MemberType NoteProperty -Name toolset -Value ($toolset)
565548
}
566549

567550
$cmakeUserPresets.configurePresets += $preset

0 commit comments

Comments
 (0)