diff --git a/scripts/build.ps1 b/scripts/build.ps1 new file mode 100644 index 00000000..17c7f326 --- /dev/null +++ b/scripts/build.ps1 @@ -0,0 +1,16 @@ +Clear-Host + +$path_root = git rev-parse --show-toplevel + +if ($IsWindows) { + $devshell = Join-Path $path_root 'scripts/helpers/devshell.ps1' + # This HandmadeHero implementation is only designed for 64-bit systems + & $devshell -arch amd64 +} + +Push-Location $path_root + +$build_bat = Join-Path $path_root 'build.bat' +& $build_bat @args + +Pop-Location diff --git a/scripts/clean.ps1 b/scripts/clean.ps1 new file mode 100644 index 00000000..15c1b5b9 --- /dev/null +++ b/scripts/clean.ps1 @@ -0,0 +1,10 @@ +Clear-Host +$path_root = git rev-parse --show-toplevel +$build_dir = Join-Path $path_root 'build' + +if (Test-Path $build_dir) { + Get-ChildItem -Path $build_dir -Recurse | Remove-Item -Force -Recurse + Write-Host "Build directory cleaned." +} else { + Write-Host "Build directory does not exist." +} diff --git a/scripts/helpers/devshell.ps1 b/scripts/helpers/devshell.ps1 new file mode 100644 index 00000000..33ca0ce4 --- /dev/null +++ b/scripts/helpers/devshell.ps1 @@ -0,0 +1,28 @@ +if ($env:VCINSTALLDIR) { + return +} + +$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 +} + +# Launch the Visual Studio Developer Shell +Push-Location +write-host @args +& $vs_devshell @args +Pop-Location