You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the readme for the asio setup which involves multiple steps.
It worked fine for me.
Then I've also written a PowerShell script to automatize it a bit.
I'd like to share it here maybe it will be useful to someone.
This is not a suggestion for adoption but it makes things easier in development.
Also it is a bit annoying that we can do pre-build scripts in rust build system, it would have been useful for such cases.
All the best.
Write-Output"============================================================================="Write-Output"Pre build script for cpal asio feature."Write-Output"Make sure that you have sourced this script instead of directly executing it."Write-Output"============================================================================="functionInvoke-VcVars {
<#.SYNOPSIS This function sets the Visual Studio build environment for the current session..DESCRIPTION The function first determines the system architecture. It then searches for the vcvarsall.bat file specific to the detected architecture and executes it to set the Visual Studio build environment for the current session.#># Determine the system architectureWrite-Output"Determining system architecture..."$arch=if ([Environment]::Is64BitOperatingSystem) {
switch-Wildcard ((Get-CimInstance-ClassName Win32_Processor).Description) {
"*ARM64*"{ "arm64" }
"*ARM*"{ "arm" }
default { "amd64" }
}
} else {
"x86"
}
Write-Output"Architecture detected as $arch."# Define search paths based on architecture$paths=if ($arch-eq'amd64') {
@('C:\Program Files (x86)\Microsoft Visual Studio\','C:\Program Files\Microsoft Visual Studio\')
} else {
@('C:\Program Files\Microsoft Visual Studio\')
}
# Search for vcvarsall.bat and execute the first instance found with the appropriate architecture argumentWrite-Output"Searching for vcvarsall.bat..."foreach ($pathin$paths) {
$vcvarsPath=Get-ChildItem$path-Recurse -Filter vcvarsall.bat-ErrorAction SilentlyContinue |Select-Object-First 1if ($vcvarsPath) {
Write-Output"Found vcvarsall.bat at $($vcvarsPath.FullName). Initializing environment..."$cmdOutput= cmd /c """$($vcvarsPath.FullName)""$arch && set"foreach ($linein$cmdOutput) {
if ($line-match"^(.*?)=(.*)$") {
$varName=$matches[1]
$varValue=$matches[2]
[System.Environment]::SetEnvironmentVariable($varName,$varValue,"Process")
}
}
return
}
}
Write-Error"Error: Could not find vcvarsall.bat. Please install the latest version of Visual Studio."exit1
}
# Main script begins here# Ensure execution policy allows for script executionif (-not (Get-ExecutionPolicy-Scope CurrentUser) -eq"Unrestricted") {
Set-ExecutionPolicy-Scope CurrentUser Unrestricted
}
# Check if running on Windowsif ($env:OS-match"Windows") {
Write-Output"Detected Windows OS."# Directory to store the ASIO SDK$out_dir= [System.IO.Path]::GetTempPath()
$asio_dir=Join-Path$out_dir"asio_sdk"if (-not (Test-Path$asio_dir)) {
Write-Output"ASIO SDK not found. Downloading..."# Download the ASIO SDK$asio_zip_path=Join-Path$out_dir"asio_sdk.zip"Invoke-WebRequest-Uri "https://www.steinberg.net/asiosdk"-OutFile $asio_zip_path# Unzip the ASIO SDKWrite-Output"Unzipping ASIO SDK..."Expand-Archive-Path $asio_zip_path-DestinationPath $out_dir-Force
# Move the contents of the inner directory (like asiosdk_2.3.3_2019-06-14) to $asio_dir$innerDir=Get-ChildItem-Path $out_dir-Directory |Where-Object { $_.Name-match'asio.*' } |Select-Object-First 1Move-Item-Path "$($innerDir.FullName)\*"-Destination $asio_dir-Force
} else {
Write-Output"ASIO SDK already exists. Skipping download."
}
# Set the CPAL_ASIO_DIR environment variableWrite-Output"Setting CPAL_ASIO_DIR environment variable..."$env:CPAL_ASIO_DIR=$asio_dir# Check if LIBCLANG_PATH is setif (-not$env:LIBCLANG_PATH) {
Write-Error"Error: LIBCLANG_PATH is not set!"Write-Output"Please ensure LLVM is installed and set the LIBCLANG_PATH environment variable."exit1
} else {
Write-Output"LIBCLANG_PATH is set to $env:LIBCLANG_PATH."
}
# Run the vcvars functionInvoke-VcVars
} else {
Write-Output"This setup script is intended for Windows only."
}
The text was updated successfully, but these errors were encountered:
Hey 👋
I followed the readme for the asio setup which involves multiple steps.
It worked fine for me.
Then I've also written a PowerShell script to automatize it a bit.
I'd like to share it here maybe it will be useful to someone.
This is not a suggestion for adoption but it makes things easier in development.
Also it is a bit annoying that we can do pre-build scripts in rust build system, it would have been useful for such cases.
All the best.
The text was updated successfully, but these errors were encountered: