Changeset View
Changeset View
Standalone View
Standalone View
0ad-download-compile-install-wxwidgets.ps1
- This file was added.
# Copyright (C) 2020 Wildfire Games. | |||||
# This file is part of 0 A.D. | |||||
# | |||||
# 0 A.D. is free software: you can redistribute it and/or modify | |||||
# it under the terms of the GNU General Public License as published by | |||||
# the Free Software Foundation, either version 2 of the License, or | |||||
# (at your option) any later version. | |||||
# | |||||
# 0 A.D. is distributed in the hope that it will be useful, | |||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
# GNU General Public License for more details. | |||||
# | |||||
# You should have received a copy of the GNU General Public License | |||||
# along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | |||||
param ([int] $jobs = 2, [string] $wxwidgetsVersion = "3.1.4", [bool] $deleteFiles = $False) | |||||
$PSScriptRootFixed = "$PSScriptRoot" -replace "\\", "/" | |||||
Write-Output "Analysing $PSScriptRootFixed with $jobs job(s)." | |||||
$buildlogfilename = "$PSScriptRootFixed/buildlog-wxwidgets.log" | |||||
$destinationRoot = "$PSScriptRootFixed" | |||||
$output_directory = "$destinationRoot-$wxwidgetsVersion" | |||||
$zip_file = "$output_directory.zip" | |||||
$solution_name = "wx_vc15.sln" | |||||
$configurations = @("Debug","Release") | |||||
function get_elapsed_time($start_time) | |||||
{ | |||||
Write-Output "Time taken: $((Get-Date).Subtract($start_time).Minutes) minutes(s) $((Get-Date).Subtract($start_time).Seconds) second(s)" | |||||
} | |||||
if (!(Test-Path $zip_file)) { | |||||
Write-Host "Downloading WXWidgets v$wxwidgetsVersion..." | |||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |||||
$url = "https://github.com/wxWidgets/wxWidgets/releases/download/v$wxwidgetsVersion/wxWidgets-$wxwidgetsVersion.zip" | |||||
$start_time = Get-Date | |||||
$wc = New-Object System.Net.WebClient | |||||
$wc.DownloadFile($url, $zip_file) | |||||
get_elapsed_time($start_time) | |||||
} | |||||
else { | |||||
Write-Host "Already downloaded WXWidgets v$wxwidgetsVersion." | |||||
} | |||||
if (Test-Path $zip_file) { | |||||
if (!(Test-Path $output_directory)) { | |||||
Write-Host "Extracting WXWidgets..." | |||||
$start_time = Get-Date | |||||
Expand-Archive $zip_file -DestinationPath $output_directory -Force | |||||
get_elapsed_time($start_time) | |||||
} | |||||
else { | |||||
Write-Host "Already extracted WXWidgets v$wxwidgetsVersion.zip." | |||||
} | |||||
} | |||||
if(Test-Path $output_directory) | |||||
{ | |||||
Set-Location "$output_directory\build\msw" | |||||
Write-Host "Building wxwidgets..." | |||||
Foreach($configuration in $configurations) | |||||
{ | |||||
$start_time = Get-Date | |||||
Write-Host "Building $configuration configuration..." | |||||
& MSBuild.exe $solution_name /p:PlatformToolset=v141_xp /m:${jobs} /m /p:Configuration=$configuration /v:q /t:Clean,Rebuild /p:WarningLevel=4 | Out-File -Encoding UTF8 -FilePath "$buildlogfilename" | |||||
get_elapsed_time($start_time) | |||||
} | |||||
} | |||||
Set-Location ..\..\ | |||||
if (Test-Path $output_directory) { | |||||
$start_time = Get-Date | |||||
Write-Host "Copying files..." | |||||
Copy-Item -Path "$output_directory\lib" -Recurse -Destination "$destinationRoot" -Container | |||||
Copy-Item -Path "$output_directory\include" -Recurse -Destination "$destinationRoot" -Container | |||||
get_elapsed_time($start_time) | |||||
} | |||||
if($deleteFiles) | |||||
{ | |||||
Write-Host "Cleaning up" | |||||
Remove-Item -Path $output_directory -Recurse -Force | |||||
Remove-Item -Path $zip_file -Recurse -Force | |||||
} | |||||
Set-Location $PSScriptRootFixed |
Wildfire Games · Phabricator