Created
May 9, 2022 16:04
-
-
Save NuarkNoir/af1607a73ab91651e7ce9a6a30d25993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-Folder($initialDirectory="", $Description="Select a folder") { | |
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null | |
$foldername = New-Object System.Windows.Forms.FolderBrowserDialog | |
$foldername.Description = $Description | |
$foldername.rootfolder = "MyComputer" | |
$foldername.SelectedPath = $initialDirectory | |
if($foldername.ShowDialog() -eq "OK") { | |
$folder += $foldername.SelectedPath | |
} | |
return $folder | |
} | |
Function Get-File($initialDirectory="", $Description="Select a folder") { | |
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null | |
$filename = New-Object System.Windows.Forms.OpenFileDialog | |
$filename.Title = $Description | |
$filename.InitialDirectory = $initialDirectory | |
$filename.Filter = "Файл проекта QT (*.pro)|*.pro" | |
$filename.Multiselect = $false | |
if($filename.ShowDialog() -eq "OK") { | |
$file += $filename.FileName | |
} | |
return $file | |
} | |
Function Assert-Not-Empty([string]$String="") { | |
if ($String.Length -eq 0) { | |
throw "Empty input! Exiting" | |
} | |
return $String | |
} | |
Assert-Not-Empty -String ($qtRootDir = Get-Folder -Description "Выбери директорию, куда установлен QT") | |
Write-Host "Выбрана директория QT: " $qtRootDir | |
Write-Host "Ищем qmake... " -NoNewline | |
Assert-Not-Empty -String ($qmakeExecutablePath = (gci -Path $qtRootDir -Recurse -Include qmake.exe).FullName) | |
Write-Host "Ищем windeployqt... " -NoNewline | |
Assert-Not-Empty -String ($wdqExecutablePath = (gci -Path $qtRootDir -Recurse -Include windeployqt.exe).FullName) | |
Write-Host "Ищем g++... " -NoNewline | |
Assert-Not-Empty -String ($gccExecutablePath = (gci -Path $qtRootDir -Recurse -Include g`+`+.exe).FullName) | |
$env:Path += ";" + (Split-Path -Path $gccExecutablePath) | |
Write-Host "Ищем make... " -NoNewline | |
Assert-Not-Empty -String ($makeExecutablePath = (gci -Path $qtRootDir -Recurse -Include mingw32-make.exe).FullName) | |
$env:Path += ";" + (Split-Path -Path $makeExecutablePath) | |
Assert-Not-Empty -String ($proFile = Get-File -Description "Выбери .pro файл твоего проекта (Именно проекта! Если это проект с поддирректориями - выбирай директорию того подпроекта, который надо собрать!)") | |
Write-Host "Выбран проект QT: " $proFile | |
$proFolder = Split-Path -Path $proFile | |
$proName = Split-Path -Path $proFolder -Leaf | |
Write-Host "Готовимся к сборке проекта..." | |
$buildFolder = Join-Path $proFolder "projectBuild" | |
if (Test-Path -Path $buildFolder) { | |
Remove-Item (Join-Path $buildFolder "*") -Recurse -Force | |
} | |
mkdir -Force $buildFolder | Out-Null | |
cd $buildFolder | |
Write-Host "Собираем проект..." | |
&"$qmakeExecutablePath" $proFile | |
&"$makeExecutablePath" | |
$releaseExe = [IO.Path]::Combine($PWD, "release", "$proName.exe") | |
&"$wdqExecutablePath" $releaseExe | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment