mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Replace make.bat with more advanced make.ps1
This commit is contained in:
parent
e916f3eb5b
commit
3ebdb31a82
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
|||||||
*.zip
|
*.zip
|
||||||
release/*
|
release/*
|
||||||
tools/temp
|
tools/temp
|
||||||
|
tools/armake.exe
|
||||||
*.cache
|
*.cache
|
||||||
*.pbo
|
*.pbo
|
||||||
texHeaders.bin
|
texHeaders.bin
|
||||||
|
24
make.bat
24
make.bat
@ -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
|
|
Binary file not shown.
Binary file not shown.
130
tools/make.ps1
Normal file
130
tools/make.ps1
Normal file
@ -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 "<a href="".*?/releases/download/v(.*?)/.*?.zip"".*?>"
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user