|
#/usr/bin/env pwsh |
|
|
|
#Requires -PSEdition Core |
|
Set-StrictMode -Version Latest |
|
|
|
# check where lazarus and visual studio buildtools are installed |
|
$pathLazarus = "C:\lazarus" |
|
$pathLazarusFpc = "C:\lazarus\fpc\3.2.2\bin\x86_64-win64" |
|
$pathVsBuildTools = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools" |
|
|
|
# paths to be set |
|
$pathList = @( |
|
"$env:Path", |
|
"$pathLazarus", |
|
"$pathLazarusFpc", |
|
"$pathVsBuildTools\Common7\Tools", |
|
"$pathVsBuildTools\MSBuild\Current\Bin", |
|
"$pathVsBuildTools\VC\Auxiliary\Build" |
|
) |
|
|
|
# projects to be compiled |
|
$projectList = @( |
|
"Cheat Engine/cheatengine.lpi", |
|
"Cheat Engine/Direct x mess/Direct x mess.sln", |
|
"Cheat Engine/DotNetCompiler/CSCompiler/CSCompiler.sln", |
|
"Cheat Engine/DotNetDataCollector/DotNetDataCollector.sln", |
|
"Cheat Engine/DotNetInvasiveDataCollector/DotNetInvasiveDataCollector.sln", |
|
"Cheat Engine/luaclient/luaclient.lpi", |
|
"Cheat Engine/MonoDataCollector/MonoDataCollector.sln", |
|
"Cheat Engine/speedhack/speedhack.lpi", |
|
"Cheat Engine/tcclib/win32/tcc/tcc.sln", |
|
"Cheat Engine/VEHDebug/vehdebug.lpi" |
|
) |
|
|
|
$env:Path = $pathList | Join-String -Separator ";" |
|
|
|
$lazbuildProjectList = $projectList | Where-Object { $_.ToLower().EndsWith(".lpi") } |
|
$msbuildProjectList = $projectList | Where-Object { $_.ToLower().EndsWith(".sln") } |
|
|
|
Launch-VsDevShell.ps1 |
|
|
|
Write-Output "`n# preparation`n" |
|
|
|
# platform toolset depending on installed version of msvc |
|
$platformToolset = ( |
|
where.exe Microsoft.VCToolsVersion.v*.txt | Sort-Object -Bottom 1 | Split-Path -Leaf | Select-String -Pattern ".*\.(v\d+)\..*" |
|
).Matches.Groups[1].Value |
|
|
|
if ($platformToolset.Length -eq 0) { |
|
Write-Output "failed to auto detect platform toolset" |
|
Write-Output "set platform toolset (e.g. v143) manually below and comment out the throw line after" |
|
Write-Output "see: https://learn.microsoft.com/cpp/build/how-to-modify-the-target-framework-and-platform-toolset#platform-toolset" |
|
|
|
# $platformToolset = "" |
|
throw "failed to auto detect platform toolset" |
|
} |
|
|
|
Write-Output "`n# done`n" |
|
|
|
Write-Output "`n# lazarus`n" |
|
|
|
foreach ($project in $lazbuildProjectList) { |
|
$buildModeList = @() |
|
|
|
if ($project.ToLower().EndsWith("cheatengine.lpi")) { |
|
$buildModeList = @("Release 64-Bit O4 AVX2", "Release 64-Bit", "Release 32-Bit") |
|
} |
|
if ($project.ToLower().EndsWith("luaclient.lpi")) { |
|
$buildModeList = @("Release 64", "Release 32") |
|
} |
|
if ($project.ToLower().EndsWith("speedhack.lpi")) { |
|
$buildModeList = @("64-bit", "32-bit") |
|
} |
|
if ($project.ToLower().EndsWith("vehdebug.lpi")) { |
|
$buildModeList = @("release 64", "release 32") |
|
} |
|
|
|
foreach ($buildMode in $buildModeList) { |
|
lazbuild --build-all --build-mode="$buildMode" "$project" |
|
Write-Output "" |
|
} |
|
} |
|
|
|
Write-Output "`n# done`n" |
|
|
|
Write-Output "`n# msbuild`n" |
|
|
|
foreach ($project in $msbuildProjectList) { |
|
# legacy .net framework fix |
|
(Get-ChildItem -Include @("*.csproj", "*.vcxproj") -Path $(Split-Path -Parent $project) -Recurse).FullName | Where-Object { |
|
Select-String -Path $_ -Pattern "<TargetFrameworkVersion>" |
|
} | ForEach-Object { |
|
$content = Get-Content -Path $_ -Raw |
|
$content = [regex]::Replace( |
|
$content, |
|
"<TargetFrameworkVersion>v4.*</TargetFrameworkVersion>", |
|
"<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>" |
|
) |
|
Set-Content -Path $_ -Value $content |
|
} |
|
|
|
$buildConfigList = @() |
|
|
|
if ($project.ToLower().EndsWith("direct x mess.sln")) { |
|
$buildConfigList = @("Release|x64", "Release|Win32") |
|
} |
|
if ($project.ToLower().EndsWith("cscompiler.sln")) { |
|
$buildConfigList = @("Release|Any CPU") |
|
} |
|
if ($project.ToLower().EndsWith("dotnetdatacollector.sln")) { |
|
$buildConfigList = @("Release|x64", "Release|Win32") |
|
} |
|
if ($project.ToLower().EndsWith("dotnetinvasivedatacollector.sln")) { |
|
$buildConfigList = @("Release|Any CPU") |
|
} |
|
if ($project.ToLower().EndsWith("monodatacollector.sln")) { |
|
$buildConfigList = @("Release|x64", "Release|Win32") |
|
} |
|
if ($project.ToLower().EndsWith("tcc.sln")) { |
|
$buildConfigList = @("Output to 64 (Release)|x64", "Output to 32 (Release)|Win32") |
|
} |
|
|
|
foreach ($buildConfig in $buildConfigList) { |
|
$configuration, $platform = $buildConfig.Split("|") |
|
msbuild -restore -p:Configuration="$configuration" -p:Platform="$platform" -p:PlatformToolset="$platformToolset" -p:WindowsTargetPlatformVersion=10.0 "$project" |
|
Write-Output "" |
|
} |
|
} |
|
|
|
Write-Output "`n# done`n" |