More refactoring, getting rid of meson in favor of just powershell scripts

This commit is contained in:
2023-08-19 08:21:28 -04:00
parent aa928ff446
commit 32a910515e
25 changed files with 731 additions and 304 deletions

View File

@ -0,0 +1,31 @@
param (
[ValidateSet("x64", "x86", "arm", "arm64")]
[string]$arch = "x64"
)
$ErrorActionPreference = "Stop"
# Use vswhere to find the latest Visual Studio installation
$vswhere_out = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
if ($null -eq $vswhere_out) {
Write-Host "ERROR: Visual Studio installation not found"
exit 1
}
# Find Launch-VsDevShell.ps1 in the Visual Studio installation
$vs_path = $vswhere_out
$vs_devshell = Join-Path $vs_path "\Common7\Tools\Launch-VsDevShell.ps1"
if ( -not (Test-Path $vs_devshell) ) {
Write-Host "ERROR: Launch-VsDevShell.ps1 not found in Visual Studio installation"
Write-Host Tested path: $vs_devshell
exit 1
}
# Set the target architecture based on the parameter
$env:VSCMD_ARG_TGT_ARCH=$arch
# Launch the Visual Studio Developer Shell
Push-Location
& $vs_devshell @args
Pop-Location

View File

@ -0,0 +1,25 @@
# target_arch.psm1
function Get-TargetArchClang {
# Get the target architecture by querying clang itself
$output = & clang -v 2>&1
foreach ($line in $output) {
if ($line -like "*Target:*") {
$clangTarget = ($line -split ':')[1].Trim()
return $clangTarget
}
}
throw "Clang target architecture could not be determined."
}
function Get-TargetArchMSVC {
# Assuming you've set the Visual Studio environment variables using `vcvarsall.bat`
# This looks for the `VSCMD_ARG_TGT_ARCH` environment variable which Visual Studio sets to indicate the target architecture.
$arch = $env:VSCMD_ARG_TGT_ARCH
if (-not $arch) {
throw "MSVC target architecture could not be determined. Ensure you've initialized the Visual Studio environment."
}
return $arch
}
Export-ModuleMember -Function Get-TargetArchClang, Get-TargetArchMSVC