diff --git a/.gitignore b/.gitignore index 2e321f4a94..6a37c85d53 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.zip release/* tools/temp +tools/armake.exe *.cache *.pbo texHeaders.bin diff --git a/make.bat b/make.bat deleted file mode 100644 index 2600c259e0..0000000000 --- a/make.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -if not exist "@ace" mkdir "@ace" -if not exist "@ace\addons" mkdir "@ace\addons" -if not exist "@ace\optionals" mkdir "@ace\optionals" - -if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (set armake=tools\armake_w64.exe) else (set armake=tools\armake_w32.exe) - -for /d %%f in (addons\*) do ( - set folder=%%f - set name=!folder:addons\=! - echo PBO @ace\addons\ace_!name!.pbo - !armake! build -i include -w unquoted-string -w redefinition-wo-undef -f !folder! @ace\addons\ace_!name!.pbo -) - -for /d %%f in (optionals\*) do ( - set folder=%%f - set name=!folder:optionals\=! - echo PBO @ace\optionals\ace_!name!.pbo - !armake! build -i include -w unquoted-string -w redefinition-wo-undef -f !folder! @ace\optionals\ace_!name!.pbo -) - -pause diff --git a/tools/armake_w32.exe b/tools/armake_w32.exe deleted file mode 100755 index 65a4a1e588..0000000000 Binary files a/tools/armake_w32.exe and /dev/null differ diff --git a/tools/armake_w64.exe b/tools/armake_w64.exe deleted file mode 100755 index 7ece97a5b7..0000000000 Binary files a/tools/armake_w64.exe and /dev/null differ diff --git a/tools/make.ps1 b/tools/make.ps1 new file mode 100644 index 0000000000..2aac0f2c9f --- /dev/null +++ b/tools/make.ps1 @@ -0,0 +1,130 @@ +$projectRoot = Split-Path -Parent $PSScriptRoot +$releasePage = "https://github.com/KoffeinFlummi/armake/releases" +$downloadPage = "https://github.com/KoffeinFlummi/armake/releases/download/v{0}/armake_v{0}.zip" +$armake = "$projectRoot\tools\armake.exe" +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + + +function Compare-VersionNewerThan { + param( + [Parameter(Mandatory=$True)] + $version1, + + [Parameter(Mandatory=$True)] + $version2 + ) + + $version1 = $version1.Split(".") | % {[int] $_} + $version2 = $version2.Split(".") | % {[int] $_} + + $newer = $False + for ($i = 0; $i -lt $version1.Length; $i++) { + if ($version1[$i] -gt $version2[$i]) { + $newer = $True + break + } + } + + $newer +} + + +function Get-InstalledArmakeVersion { + if (Test-Path $armake) { + $version = & $armake --version + $version = $version.Substring(1) + } else { + $version = "0.0.0" + } + + $version +} + + +function Get-LatestArmakeVersion { + $client = New-Object Net.WebClient + $content = $client.DownloadString($releasePage) + $client.dispose() + + $match = $content -match "" + if (!$match) { + Write-Error "Failed to find valid armake download link." + $version = "0.0.0" + } else { + $version = $matches[1] + } + + $version +} + + +function Update-Armake { + param( + [Parameter(Mandatory=$True)] + $url + ) + + New-Item "$PSScriptRoot\temp" -ItemType "directory" -Force | Out-Null + + Write-Output "Downloading armake..." + $client = New-Object Net.WebClient + $client.DownloadFile($url, "$PSScriptRoot\temp\armake.zip") + $client.dispose() + + Write-Output "Download complete, unpacking..." + Expand-Archive "$PSScriptRoot\temp\armake.zip" "$PSScriptRoot\temp\armake" + Remove-Item "$PSScriptRoot\temp\armake.zip" + + if ([Environment]::Is64BitProcess) { + $binary = Get-ChildItem -Path "$PSScriptRoot\temp\armake" -Include "*.exe" -Recurse | Where-Object {$_.Name -match ".*w64.exe"} + } else { + $binary = Get-ChildItem -Path "$PSScriptRoot\temp\armake" -Include "*.exe" -Recurse | Where-Object {$_.Name -match ".*w64.exe"} + } + Move-Item $binary.FullName $armake -Force + + Remove-Item "$PSScriptRoot\temp" -Recurse -Force +} + + +function Build-Directory { + param( + [Parameter(Mandatory=$True)] + $directory + ) + + $component = $directory.Name + $fullPath = $directory.FullName + $parent = $directory.Parent + $binPath = "$projectRoot\@ace\$parent\ace_$component.pbo" + + Write-Output " PBO $component" + & $armake build -i "$projectRoot\include" -w unquoted-string -w redefinition-wo-undef -f $fullPath $binPath + + if ($LastExitCode -ne 0) { + Write-Error "Failed to build $component." + } +} + + +function Main { + $installed = Get-InstalledArmakeVersion + $latest = Get-LatestArmakeVersion + + if (Compare-VersionNewerThan $latest $installed) { + Write-Output "Found newer version of armake:" " Installed: $installed" " Latest: $latest" + Update-Armake ($downloadPage -f $latest) + Write-Output "Update complete, armake up-to-date." + } + + $orgLocation = Get-Location + Set-Location -Path $projectRoot + foreach ($folder in "addons", "optionals") { + New-Item "$projectRoot\@ace\$folder" -ItemType "directory" -Force | Out-Null + foreach ($component in Get-ChildItem -Directory "$PSScriptRoot\..\$folder") { + Build-Directory $component + } + } + Set-Location $orgLocation +} + +Main