Skip to content

Commit

Permalink
Move from .bat to .ps1 for build script, improve Qt finding
Browse files Browse the repository at this point in the history
  • Loading branch information
Atari2 committed Nov 4, 2023
1 parent 5125e2d commit 9cd68b1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 9 deletions.
5 changes: 1 addition & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
image: Visual Studio 2022

on_finish:
- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

build_script:
- cmd: .\build_script.bat
- pwsh: .\build_script.ps1

after_build:
- ps: py .\zip_script.py
Expand Down
5 changes: 0 additions & 5 deletions build_script.bat

This file was deleted.

61 changes: 61 additions & 0 deletions build_script.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
function SetupMSVC {
param (
[PSDefaultValue(Help = "x64")]
[string]$Arch = "x64",
[PSDefaultValue(Help = "false")]
[switch]$Pre
)

$moduleAlreadyLoaded = Get-Module Microsoft.VisualStudio.DevShell
if ($moduleAlreadyLoaded) {
Write-Error "Module with the same name already loaded, cannot load another one because there will be assemblies conflicts"
return
}
$assemblyPresent = [System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.FullName -like '*Microsoft.VisualStudio.DevShell*' }
if ($assemblyPresent) {
Write-Error "Assembly with the same name already loaded, cannot load another one because there will be assemblies conflicts"
return
}

if ($Pre) {
$vsPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -prerelease -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationpath
}
else {
$vsPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationpath
}
$commonLocation = "$vsPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
if (Test-Path $commonLocation) {
$dllPath = $commonLocation
}
else {
$dllPath = (Get-ChildItem $vsPath -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName
}
Import-Module -Force $dllPath
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=$Arch"
}

function FindQt6 {
$versions = Get-ChildItem -Path "C:\Qt" -Directory -Filter "6.*" -Attributes !ReparsePoint | Select-Object -ExpandProperty Name | Sort-Object -Descending
if ($versions.Length -eq 0) {
Write-Error "No Qt6 installation found"
return
}
$qtPath = "C:\Qt\$($versions[0])\msvc2019_64"
if (Test-Path $qtPath) {
return $qtPath
}
else {
Write-Error "No Qt6 installation found"
return
}
}

SetupMSVC
$qtPath = FindQt6
if (!$qtPath) {
return
}
Write-Output "Using Qt6 from $qtPath"
cmake.exe -S . -B build -GNinja -DCMAKE_BUILD_TYPE:String=Release -DCMAKE_PREFIX_PATH:STRING=$qtPath -DCMAKE_C_COMPILER:STRING=cl.exe -DCMAKE_CXX_COMPILER:STRING=cl.exe
Set-Location build
cmake.exe --build . --target all

0 comments on commit 9cd68b1

Please sign in to comment.